summaryrefslogtreecommitdiff
path: root/rotord
diff options
context:
space:
mode:
Diffstat (limited to 'rotord')
-rw-r--r--rotord/cvimage.h10
-rwxr-xr-xrotord/rotor.cpp2
-rwxr-xr-xrotord/rotor.h25
3 files changed, 29 insertions, 8 deletions
diff --git a/rotord/cvimage.h b/rotord/cvimage.h
index cbf2840..6c237b4 100644
--- a/rotord/cvimage.h
+++ b/rotord/cvimage.h
@@ -85,7 +85,7 @@ namespace Rotor {
ownsRGBdata=ownsAdata=ownsZdata=false;
}
bool setup(int _w,int _h){ //set up with internal data
- rgb.create(_w,_h,CV_8UC3);
+ rgb.create(_h,_w,CV_8UC3);
RGBdata=rgb.data; //can move to use the bare pointer eventually
ownsRGBdata=false; //will not be necessary
w=_w;
@@ -108,8 +108,12 @@ namespace Rotor {
bool setup_fromRGB(int _w,int _h,uint8_t *pRGBdata,int linepadding=0){
//here the data belongs to libavcodec or other
//could move to using cv::Mat there also and just passing cv:Mat over
- std::cerr<<"creating cv::Mat with step= "<<((_w*3)+linepadding)<<std::endl;
- rgb=cv::Mat(_w,_h,CV_8UC3,pRGBdata,(_w*3)+linepadding);
+
+ //linepadding causes crash, but it doesn't seem to be necessary
+ // Mat::Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP)
+ rgb=cv::Mat(_h,_w,CV_8UC3,pRGBdata,(_w*3)+linepadding);
+ //std::cerr<<"created cv::Mat with step= "<<rgb.step<<",should be "<<((_w*3)+linepadding)<<std::endl;
+
RGBdata=rgb.data; //can move to use the bare pointer eventually
ownsRGBdata=false; //will not be necessary
w=_w;
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp
index 36ce750..90d23d9 100755
--- a/rotord/rotor.cpp
+++ b/rotord/rotor.cpp
@@ -336,7 +336,7 @@ Image* Video_loader::output(const Frame_spec &frame){
if (image.w>0) return &image; //just return the previous frame if possible
else return nullptr;
};
- cerr<<"setting up frame: lineoffset="<<(player.pFrameRGB->linesize[0]-(frame.w*3))<<endl;
+ //cerr<<"Video_loader: setting up frame: lineoffset="<<(player.pFrameRGB->linesize[0]-(frame.w*3))<<endl;
image.setup_fromRGB(frame.w,frame.h,player.pFrameRGB->data[0],player.pFrameRGB->linesize[0]-(frame.w*3));
return &image;
}
diff --git a/rotord/rotor.h b/rotord/rotor.h
index 3f51d79..f630391 100755
--- a/rotord/rotor.h
+++ b/rotord/rotor.h
@@ -1178,6 +1178,16 @@ namespace Rotor {
};
~Transform(){
};
+ void link_params() {
+ for (auto p:parameter_inputs){
+ if (p->parameter=="scale") p->receiver=&s;
+ if (p->parameter=="rotation") p->receiver=&r;
+ if (p->parameter=="transformX") p->receiver=&tX;
+ if (p->parameter=="transformY") p->receiver=&tY;
+ if (p->parameter=="originX") p->receiver=&oX;
+ if (p->parameter=="originY") p->receiver=&oY;
+ }
+ };
Transform* clone(map<string,string> &_settings) { return new Transform(_settings);};
Image *output(const Frame_spec &frame){
if (image_inputs.size()) {
@@ -1190,7 +1200,7 @@ namespace Rotor {
cv::Mat rot_mat(2,3,CV_32FC1);
cv::Mat trans_mat(2,3,CV_32FC1);
- /*
+
Image inter;
inter.setup(other->w,other->h);
// Compute matrix by creating triangle and transforming
@@ -1206,8 +1216,8 @@ namespace Rotor {
dstTri[i].y=srcTri[i].y+(tY*other->h);
}
trans_mat=getAffineTransform( srcTri, dstTri );
- warpAffine( other->rgb, inter.rgb, trans_mat, inter.rgb.size() );
- */
+ warpAffine( other->rgb, inter.rgb, trans_mat, inter.rgb.size(), cv::INTER_LINEAR, cv::BORDER_WRAP);
+
// Compute rotation matrix
//
@@ -1216,7 +1226,14 @@ namespace Rotor {
rot_mat = getRotationMatrix2D( centre, r, s );
// Do the transformation
//
- warpAffine( other->rgb, image.rgb, rot_mat, image->rgb.size() );
+ warpAffine( inter.rgb, image.rgb, rot_mat, image.rgb.size(), cv::INTER_LINEAR, cv::BORDER_WRAP);
+ //BORDER_WRAP
+
+ //INTER_NEAREST - a nearest-neighbor interpolation
+ //INTER_LINEAR - a bilinear interpolation (used by default)
+ //INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
+ //INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
+ //INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood
return &image;
}