python - openCV better way to draw contours -


i've detected hand based on roi histograms using code provided on opencv website, , result i've obtainedenter image description here

based on result, want draw contour, resulting image it's not 1 need future processing. enter image description here

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:

enter image description here

probably need, however, better result former processing.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -