1

I have used below tutorial to detect object and get coordinates of rectangles that contain object https://docs.opencv.org/3.3.1/d2/d99/tutorial_js_face_detection.html

But I want to get all coordinates of object (not vector of rectangular coordinates) for object extraction.How can I do that?Is there any function can do that?

For example: enter image description here

my-lord
  • 2,453
  • 3
  • 12
  • 26

1 Answers1

1

Haar-cascades has been trained to return only the rectangular coordinates of the detected object and not the contour.

But try the following:

1) Create a mask with the rectangular coordinates

2) Mask out just the object region using the Mask image(check cv2.bitwise_and)

3) Edge detection using canny or threshold if it is applicable.

4) Find contours. You can use cv2.findcontours function, where you can set cv2.findcontours(..,..,method =CHAIN_APPROX_NONE) to get all the points lying on the contour.

janu777
  • 1,940
  • 11
  • 26
  • I cannot find mask() function on opencv.js for creating a mask on OPENCV.js.Is there any way to do that?I do some research find thishttps://stackoverflow.com/questions/15589517/how-to-crop-an-image-in-opencv-using-python.But this code not mask rectengular area on opencv.js – my-lord Feb 12 '18 at 14:43
  • Sorry I am not sure about js. You will need to do more research on that – janu777 Feb 12 '18 at 15:13