python - openCV better way to draw contours -
i've detected hand based on roi histograms using code provided on opencv website, , result i've obtained
based on result, want draw contour, resulting image it's not 1 need future processing.
what need in order have smoother contour? thanks!
your image has many "holes". try morphology
this c++ code, can port python. may need tweak parameters little.
#include <opencv2\opencv.hpp> using namespace cv; int main() { mat3b img = imread("path_to_image"); mat1b binary; cvtcolor(img, binary, cv_bgr2gray); threshold(binary, binary, 1, 255, thresh_binary); mat1b morph; mat kernel = getstructuringelement(morph_ellipse, size(11,11)); morphologyex(binary, morph, morph_close, kernel, point(-1,-1), 3); vector<vector<point>> contours; findcontours(morph.clone(), contours, cv_retr_ccomp, cv_chain_approx_simple); /// draw contours mat3b draw = img.clone(); (int = 0; < contours.size(); i++) { drawcontours(draw, contours, i, scalar(0,0,255), 2); } return 0; }
if close image, got better results, this:
probably need, however, better result former processing.
Comments
Post a Comment