copyTo error

asked 2014-11-05 13:39:08 -0500

Hm gravatar image

updated 2014-11-05 13:45:32 -0500

i need to copy a cropped image with different size to the center of another black image with fixed size , when i use copyTo function i have an error

the function as:

Mat black_image(55,50,CV_8UC1,Scalar(0));
crop_image.copyTo(black_image(Rect((black_image.cols - crop_image.cols )/2, (black_image.rows +crop_image.rows )/2,crop_image.cols, crop_image.rows)));

the error as:

opencv error:assertion failed obj->size size<cols,rows> core\src\matrix line 1392

edit retag flag offensive close merge delete

Comments

Where did you initiate crop_image Matrix? Try to make this: Mat crop_image= new Mat(new Size(width, height), Your type(Example CvType.CV_8U));

itay gravatar imageitay ( 2014-11-06 02:07:26 -0500 )edit

i can't change croped_ image size as it is detected area from another image and i want to put it in center of black image in order to make it with another size without using resizing as resize function make my data low accuracy

Hm gravatar imageHm ( 2014-11-06 04:08:53 -0500 )edit

I think that both matrix have to be in the same size, So what I suggest you to do, is to create another temp matrix with the same dimension like the crop matrix, than re-size this matrix and copy.

itay gravatar imageitay ( 2014-11-06 04:56:40 -0500 )edit