Ask Your Question
0

How to display an image

asked 2014-10-10 06:02:08 -0500

annarose gravatar image

I want to display my image on right side of the screen within the rectangle. So for that I wrote the following code.

Rect dstRC(10,20,100,100);//The region I want to display image
Mat dstROI = frame(dstRC);
img1.copyTo(dstROI);//My image is img1.Copy to desired location
rectangle(frame1, dstRC, CV_RGB(255,0,0), 3, CV_AA);

But it shows only an empty rectangle.Why?

edit retag flag offensive close merge delete

Comments

because you did not post all your code

boaz001 gravatar imageboaz001 ( 2014-10-10 11:01:03 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-10-10 06:49:49 -0500

thdrksdfthmn gravatar image

updated 2014-10-10 09:02:03 -0500

Because the

rectangle(frame1, dstRC, CV_RGB(255,0,0), 3, CV_AA);

only draws a rectangle (dstRC) in the image (frame1).

Another thing is that you create the dstROI and set it to contain the frame(dstRC) info (so, the info in the frame at dstRC region). And then you just change it to contain the img1. (By the way, empty means what?).

I think I understand what you wanted to do. I have done it once, but I don't have the code, so I just write an untested code:

cv::Mat img2display = frame.clone();
cv::Rect displayRegion(0, 0, img1.cols, img1.rows);
cv::addWeighted(img2display(displayRegion), 0, img1, 1, 0, img2display(displayRegion));
cv::imshow("composed image", img2display);
cv::waitKey();

I have tested it and changed. Now it works on my computer.

edit flag offensive delete link more

Comments

Thank you..It works fine.

annarose gravatar imageannarose ( 2014-10-12 22:50:44 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-10-10 06:02:08 -0500

Seen: 117 times

Last updated: Oct 10 '14