Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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);
img2display(displayRegion) = img1;
cv::imshow("composed image", img2display);
cv::waitKey();

This will work if the two images (frame and img1) have the same type, otherwise, you should convert img1 to the img2display.type, using cvtColor.

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);
img2display(displayRegion) = img1;
cv::imshow("composed image", img2display);
cv::waitKey();

This will work if the two images (frame and img1) have the same type, otherwise, you should convert img1 to the img2display.type, using cvtColor.. Or even resize the image to the wanted size to display and change the displayRegion to fit that.

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);
img2display(displayRegion) = img1;
cv::addWeighted(img2display(displayRegion), 0, img1, 1, 0, img2display(displayRegion));
cv::imshow("composed image", img2display);
cv::waitKey();

This will work if the two images (frame I have tested it and img1) have the same type, otherwise, you should convert img1 to the img2display.type, using cvtColor. Or even resize the image to the wanted size to display and change the displayRegion to fit that.changed. Now it works on my computer.