Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you can't crop & save the rotatedrect directly (it's not axis-aligned), but you can save it's boundingRect:

Rect r = rrect.boundingRect();
Mat crop = rgb(r);
imsave(format("letters_%d.png", idx), crop);

you can't crop & save the rotatedrect directly (it's not axis-aligned), but you can save it's boundingRect:

Rect r = rrect.boundingRect();
Mat crop = rgb(r);
imsave(format("letters_%d.png", imsave(format("letters_%04d.png", idx), crop);

you can't crop & save the rotatedrect directly (it's not axis-aligned), but you can save it's boundingRect:

Rect r = rrect.boundingRect();
Mat crop = rgb(r);
imsave(format("letters_%04d.png", imwrite(format("letters_%04d.png", idx), crop);

you can't crop & save the rotatedrect directly (it's not axis-aligned), but you can save it's boundingRect:

Rect r = rrect.boundingRect();
Rect bounds(0,0,rgb.cols,rgb.rows);
Mat crop = rgb(r);
rgb(r & bounds);  // make sure, we stay inside the image
imwrite(format("letters_%04d.png", idx), crop);