Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

matchShapes using grayscale images opencv

According to the matchShapes documentation, the input can be either gray scale images or contours. But when I tried two gray scale images, I got an assertion failed error. Upon further exploration, I found from here that the Mat object has to be a 1D vector and of type CV_32FC2 or CV_32SC2.

Using this answer, I converted the images to vector array of float after converting them to CV_32FC2. I still get an assertion error.

Can anyone tell me how can I compare 2 grayscale images using matchShapes function?

matchShapes using grayscale images opencv

According to the matchShapes documentation, the input can be either gray scale images or contours. But when I tried two gray scale images, I got an assertion failed error. Upon further exploration, I found from here that the Mat object has to be a 1D vector and of type CV_32FC2 or CV_32SC2.

Using this answer, I converted the images to vector array of float after converting them to CV_32FC2. I still get an assertion error.

Can anyone tell me how can I compare 2 grayscale images using matchShapes function?

UPDATE

as asked in comments, I tried with 2 grayscale images. and this is the error I got

OpenCV Error: Assertion failed (contour1.checkVector(2) >= 0 && contour2.checkVector(2) >= 0 && (contour1.depth() == CV_32F || contour1.depth() == CV_32S) && contour1.depth() == contour2.depth()) in matchShapes, file /home/tonystark/Opencv/modules/imgproc/src/contours.cpp, line 1936 terminate called after throwing an instance of 'cv::Exception' what(): /home/tonystark/Opencv/modules/imgproc/src/contours.cpp:1936: error: (-215) contour1.checkVector(2) >= 0 && contour2.checkVector(2) >= 0 && (contour1.depth() == CV_32F || contour1.depth() == CV_32S) && contour1.depth() == contour2.depth() in function matchShapes

Just curious, anything to do with my opencv version? it is 2.4.9