cv2.imshow() function is opening a window that always says not responding – python opencv

You missed one more line: cv2.waitKey(0) Then the window shows the image until you press any key on keyboard. Or you can pass as following: cv2.waitKey(1000) cv2.destroyAllWindows() Here, window shows image for 1000 ms, or 1 second. After that, the window would disappear itself. But in some cases, it won’t. So you can forcefully destroy … Read more

Fit Quadrilateral (Tetragon) to a blob

I recommend the following steps: threshold() the image dilate() the image – this will remove the black line splitting the top and bottom section and also darker artifacts on the lower part findContours() using setting to retrieve only external contours(RETR_EXTERNAL) and simplify the output(CHAIN_APPROX_SIMPLE) process the contours further Step 1:threshold # threshold image ret,thresh = … Read more

OpenCV / SURF How to generate a image hash / fingerprint / signature out of the descriptors?

The feature data you mention (position, laplacian, size, orientation, hessian) is insufficient for your purpose (these are actually the less relevant parts of the descriptor if you want to do matching). The data you want to look at are the “descriptors” (the 4th argument): void cvExtractSURF(const CvArr* image, const CvArr* mask, CvSeq** keypoints, CvSeq** descriptors, … Read more

Filling gaps in shape edges

Another, simpler way, that will probably translate better into OpenCV as it uses convolution rather than sequential Perl/C code. Basically set all the black pixels to value 10, and all the white pixels to value 0, then convolve the image with the following 3×3 kernel: 1 1 1 1 10 1 1 1 1 Now, … Read more

How to crop a CvMat in OpenCV?

OpenCV has region of interest functions which you may find useful. If you are using the cv::Mat then you could use something like the following. // You mention that you start with a CVMat* imagesource CVMat * imagesource; // Transform it into the C++ cv::Mat format cv::Mat image(imagesource); // Setup a rectangle to define your … Read more