OpenCV.js Coordinates of points of contour corners

asked 2019-12-14 04:03:57 -0500

sundowatch gravatar image

updated 2019-12-14 08:57:42 -0500

supra56 gravatar image

Hi,

I'm using OpenCV.js with JavaScript and trying to get points of an approxPolyDP return. Here is my code:

 let src = cv.imread(imgElement);  

 let contours = new cv.MatVector();  

 let hierarchy = new cv.Mat(); 

 let poly = new cv.MatVector();

 cv.findContours(src, contours,
 hierarchy, cv.RETR_EXTERNAL,
 cv.CHAIN_APPROX_SIMPLE);

 let cnt = contours.get(0);

 cv.approxPolyDP(cnt, poly, 0.02 *
 peri, true);

That draws perfect with drawContours() function. But I want to get the coordinates of points of the corners. It's simple to get it on Python, but not JavaScript.

How can I get the points' coordinates of corners?

edit retag flag offensive close merge delete

Comments

supra56 gravatar imagesupra56 ( 2019-12-14 09:57:30 -0500 )edit