Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fastest way to move image in OpenCV

I develop a simple stabilizer and I'm having difficulty with the shift of the image. Example - I have two images (A and B) are shifted relative to each other by a few pixels. I calculate the offset using phase correlations. The next step I need to move the second image by the image's offset. An example is presented on the image. How do I solve this problem?

There is link to preview image:

illustration

like image 940
iRomul Avatar asked May 05 '14 03:05

iRomul


People also ask

Can we work with vector images in OpenCV?

Opencv reads and elaborates images as numeric structures, in this case matrices (or 2 dimensional vector if you like).


1 Answers

cv::Rect and cv::Mat::copyTo

cv::Mat img=cv::imread("image.jpg");
cv::Mat imgTranslated(img.size(),img.type(),cv::Scalar::all(0));
img(cv::Rect(50,30,img.cols-50,img.rows-30)).copyTo(imgTranslated(cv::Rect(0,0,img.cols-50,img.rows-30)));
like image 101
LovaBill Avatar answered Sep 27 '22 20:09

LovaBill