What is the algorithm that opencv uses for finding contours?

If you read the documentation it is mentioned this function implements the algorithm of: Suzuki, S. and Abe, K., Topological Structural Analysis of Digitized Binary Images by Border Following. CVGIP 30 1, pp 32-46 (1985) OpenCV is open source if you want to see how this is implemented just need to read the code: https://github.com/opencv/opencv/blob/master/modules/imgproc/src/contours.cpp#L1655 … Read more

Contour/imshow plot for irregular X Y Z data

Does plt.tricontourf(x,y,z) satisfy your requirements? It will plot filled contours for irregularly spaced data (non-rectilinear grid). You might also want to look into plt.tripcolor(). import numpy as np import matplotlib.pyplot as plt x = np.random.rand(100) y = np.random.rand(100) z = np.sin(x)+np.cos(y) f, ax = plt.subplots(1,2, sharex=True, sharey=True) ax[0].tripcolor(x,y,z) ax[1].tricontourf(x,y,z, 20) # choose 20 contour levels, … Read more

OpenCV’s Canny Edge Detection in C++

Change this line cvtColor( image, gray_image, CV_RGB2GRAY ); to std::vector<cv::Mat> channels; cv::Mat hsv; cv::cvtColor( image, hsv, CV_RGB2HSV ); cv::split(hsv, channels); gray_image = channels[0]; The problem seems to be that your hand in gray scale is very close to the gray background. I have applied Canny on the hue (color) because the skin color should be … Read more

Python: find contour lines from matplotlib.pyplot.contour()

You can get the vertices back by looping over collections and paths and using the iter_segments() method of matplotlib.path.Path. Here’s a function that returns the vertices as a set of nested lists of contour lines, contour sections and arrays of x,y vertices: import numpy as np def get_contour_verts(cn): contours = [] # for each contour … Read more

OpenCV Python: cv2.findContours – ValueError: too many values to unpack

I got the answer from the OpenCV Stack Exchange site. Answer THE ANSWER: I bet you are using the current OpenCV’s master branch: here the return statements have changed, see http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours. Thus, change the corresponding line to read: _, contours, _= cv2.findContours(skin_ycrcb, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) Or: since the current trunk is still not stable and you … Read more