c++ - Opencv findcontours CV_RETR_EXTERNAL not working -


i've image:

edit sorry had remove images!

i need extract contour of non-black picture, used findcontour cv_retr_external parameter, obtain this:

here's code:

static mat canny_output, grey,draw;         vector<vector<point>> contours;         cvtcolor(final_img, grey, cv_bgr2gray);         canny(grey, canny_output, 100, 200);         findcontours(canny_output, contours, cv_retr_external, cv_chain_approx_simple);          draw = mat::zeros(canny_output.size(), cv_8uc3);           (size_t = 0; < contours.size(); i++)         {             drawcontours(draw, contours, i, scalar(255, 0, 0));          } 

how can resolve?

simply add binarization minimal threshold, , remove canny:

cvtcolor(final_img, grey, cv_bgr2gray); //threshold=1: low value, anyway rest of image pure black threshold(grey, binary, 1, 255, cv_thresh_binary); findcontours(binary, contours, cv_retr_external, cv_chain_approx_simple); 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -