开发者

OpenCV: How to merge two static images into one and emboss text on it?

I have completed an image processing algorithm where I extract certain features from two similar images.

I'm using OpenCV2.1 and I wish to showcase a comparison between these two similar images. I wish to combine both the images into one, where the final image will have both the images next to one another. Like in the figure below. 开发者_JAVA技巧

OpenCV: How to merge two static images into one and emboss text on it?

Also, the black dots are the similarities my algorithm has found, now I want to mark them with digits. Where, point 1 on the right is the corresponding matching point on the left.**

What OpenCV functions are useful for this work?


If you really want them in the same window, and assuming they have same width and height (if they are similar they should have same width and height). You could try to create an image with a final width twice bigger than the width of your 2 similar images. And then use ROI to copy them. You can write a new function to encapsulate these (usefull) functions in one function in order to have a nice code.

Mat img1,img2; //They are previously declared and of the same width & height

Mat imgResult(img1.rows,2*img1.cols,img1.type()); // Your final image

Mat roiImgResult_Left = imgResult(Rect(0,0,img1.cols,img1.rows)); //Img1 will be on the left part
Mat roiImgResult_Right = imgResult(Rect(img1.cols,0,img2.cols,img2.rows)); //Img2 will be on the right part, we shift the roi of img1.cols on the right

Mat roiImg1 = img1(Rect(0,0,img1.cols,img1.rows));
Mat roiImg2 = img2(Rect(0,0,img2.cols,img2.rows));

roiImg1.copyTo(roiImgResult_Left); //Img1 will be on the left of imgResult
roiImg2.copyTo(roiImgResult_Right); //Img2 will be on the right of imgResult

Julien,


The easiest way I can think right now would be to create two windows instead of one. You can do it using cvNamedWindow(), and then position them side by side with cvMoveWindow().

After that if you now the position of the similarities on the images, you can draw your text near them. Take a look at cvInitFont(), cvPutText().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜