Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you want copyTo(), not a simple "=" assignment:

Mat cars = imread("cars.jpg");
Mat draw = Mat(cars.size(), cars.type(), Scalar::all(0));
Rect r1(84,81,130,76);
Rect r2(417,144,153,85);

cars(r1).copyTo(draw(r1));
cars(r2).copyTo(draw(r2));

imshow("draw",draw);
waitKey();

image description