D-Alex / ropencv

ffi ruby wrapper for opencv
Other
67 stars 14 forks source link

cv::find_contours struggling with input #46

Closed dshorthouse closed 3 years ago

dshorthouse commented 3 years ago

I'm struggling with cv::find_contours and it's quite likely that I do not know how to construct the expected input params. Help for a noob would be most appreciated.

I have:

thresh = cv::Mat.new
cv::threshold(gray_blue, thresh, 10, 255, cv::THRESH_BINARY)

...which makes a nice binary image for me from my gray_blue Mat and then:

contours = Vector.new(Vector.new(cv::Point))
hierarchy = cv::Vec4i.new
cv::find_contours(thresh, contours, hierarchy, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE)

...but this fails with an ArgumentError. I'm assuming it's because of how I'm creating/passing contours or hierarchy. What's the correct way to make these to pass them into the findContours method?

dshorthouse commented 3 years ago

I should have read the docs. Found it! https://www.rubydoc.info/gems/ropencv/0.0.35/OpenCV/Cv#find_contours-class_method