简体   繁体   中英

Imgproc.convexityDefects(); In eclipse + java + opencv

I need of information about convexitydefect() function in Java language.

This is the function:

 Imgproc.convexityDefects(MatOfPoint contour, MatOfInt convexhull, MatOfInt4 convexityDefects)

The result is in convexityDefects variable:

MatOfInt4 convexityDefects;

Now in c++ the struct of convexityDefects is:

CvPoint* start; // point of the contour where the defect begins

CvPoint* end; // point of the contour where the defect ends

CvPoint* depth_point; // the farthest from the convex hull point within the defect

float depth; 

But Java retunrs 4 int for row! How can i get information about start,end,depth_point, depth in java?

The convexityDefects structure you mention is for the C API only. For C++ and Java, it's hard to answer better than the documentation already has:

In C++ and the new Python/Java interface each convexity defect is represented as 4-element integer vector (aka cv::Vec4i ): ( start_index , end_index , farthest_pt_index , fixpt_depth ), where indices are 0-based indices in the original contour of the convexity defect beginning, end and the farthest point, and fixpt_depth is fixed-point approximation (with 8 fractional bits) of the distance between the farthest contour point and the hull. That is, to get the floating-point value of the depth will be fixpt_depth/256.0 .

Thus, start and end are the first two elements of the 4 int s, and contain indices into the contour . depth_point is the third element, and is the index of the deepest point in contour . Divide the last element by 256 to get the floating-point value for the depth.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM