convex-hull

android java opencv 2.4 convexhull convexdefect

独自空忆成欢 提交于 2019-11-28 00:38:02
问题 Open-CV 2.4 Android-Java: i have searched for contours (list of MatofPoint) like this: Imgproc.findContours(roi_mat, contours, hierarchy, cfg.retMode, cfg.apxMode); and then the convexhull (has to be a list of MatofInt ) for (int k=0; k < contours.size(); k++){ Imgproc.convexHull(contours.get(k), hull.get(k)); } The convexhull wants a MatofInt but the drawcontours wants a MatofPoint.. So what to do? Thx in advance.. Edit : @OpenCV4Android for (int k=0; k < contours.size(); k++){ Imgproc

How to find convex hull in a 3 dimensional space

亡梦爱人 提交于 2019-11-27 18:24:19
Given a set of points S (x, y, z) . How to find the convex hull of those points ? I tried understanding the algorithm from here , but could not get much. It says: First project all of the points onto the xy-plane, and find an edge that is definitely on the hull by selecting the point with highest y-coordinate and then doing one iteration of gift wrapping to determine the other endpoint of the edge. This is the first part of the incomplete hull. We then build the hull iteratively. Consider this first edge; now find another point in order to form the first triangular face of the hull. We do this

Converting convex hull to binary mask

白昼怎懂夜的黑 提交于 2019-11-27 16:57:51
问题 I want to generate a binary mask that has ones for all voxels inside and zeros for all voxels outside a volume. The volume is defined by the convex hull around a set of 3D coordinates (<100; some of the coordinates are inside the volume). I can get the convex hull using CONVHULLN, but how do I convert that into a binary mask? In case there is no good way to go via the convex hull, do you have any other idea how I could create the binary mask? 回答1: You can solve this problem using the

Convex hull of 4 points

断了今生、忘了曾经 提交于 2019-11-27 13:09:31
问题 I would like an algorithm to calculate the convex hull of 4 2D points. I have looked at the algorithms for the generalized problem, but I wonder if there is a simple solution for 4 points. 回答1: Take three of the points, and determine whether their triangle is clockwise or counterclockwise:: triangle_ABC= (A.y-B.y)*C.x + (B.x-A.x)*C.y + (A.x*B.y-B.x*A.y) For a right-handed coordinate system, this value will be positive if ABC is counterclockwise, negative for clockwise, and zero if they are

Convexity defects C++ OpenCv

对着背影说爱祢 提交于 2019-11-27 07:54:20
I would be grateful to you if you could help me with this issue :) Relating to this question cvConvexityDefects in OpenCV 2.X / C++? , I have the same problem. The OpenCV C++ wrapper has not the function cvConvexityDefects that appears in the C version, so I tried to write my own version. Part of the code is (please note that both countour and hull are vector< Point >, calculated separately : CvSeq* contourPoints; CvSeq* hullPoints; CvSeq* defects; CvMemStorage* storage; CvMemStorage* strDefects; CvMemStorage* contourStr; CvMemStorage* hullStr; CvConvexityDefect *defectArray = 0; strDefects =

Convex Hull on Java Android Opencv 2.3

拜拜、爱过 提交于 2019-11-27 07:08:13
问题 Please help me, I have a problem for Convex Hull on Android. I use Java and OpenCV 2.3 . Before I made it on Java, I made it on C++ with Visual Studio 2008. This code can running successfully on C++. Now, i want to convert it from C++ to Java on Android. And I found error like "force close" when i run it on SDK Android simulator. This is my code on C++: vector<vector<Point> > contours; vector<Vec4i> hierarchy; findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX

Create non-intersecting polygon passing through all given points

浪尽此生 提交于 2019-11-27 07:07:15
Suppose I have an array of points in random order, and I need to find a polygon (by sorting them, such that every adjacent pair represents a side) which passes through all of the points, and its sides are non-intersecting of course. I tried to do it by selecting a point, and adding all points to the final array which are below it, sorted left to right. Then, adding all points which are above it, sorted right to left. I've been told that I can add an additional point and sort naturally to avoid self-intersections.. I am unable to figure out that though. What's a simple way to do this? As

How to tell whether a point is to the right or left side of a line

亡梦爱人 提交于 2019-11-26 21:02:35
I have a set of points. I want to separate them into 2 distinct sets. To do this, I choose two points ( a and b ) and draw an imaginary line between them. Now I want to have all points that are left from this line in one set and those that are right from this line in the other set. How can I tell for any given point z whether it is in the left or in the right set? I tried to calculate the angle between a-z-b – angles smaller than 180 are on the right hand side, greater than 180 on the left hand side – but because of the definition of ArcCos, the calculated angles are always smaller than 180°.

What's an efficient way to find if a point lies in the convex hull of a point cloud?

时光怂恿深爱的人放手 提交于 2019-11-26 19:38:56
I have a point cloud of coordinates in numpy. For a high number of points, I want to find out if the points lie in the convex hull of the point cloud. I tried pyhull but I cant figure out how to check if a point is in the ConvexHull : hull = ConvexHull(np.array([(1, 2), (3, 4), (3, 6)])) for s in hull.simplices: s.in_simplex(np.array([2, 3])) raises LinAlgError: Array must be square. Juh_ Here is an easy solution that requires only scipy: def in_hull(p, hull): """ Test if points in `p` are in `hull` `p` should be a `NxK` coordinates of `N` points in `K` dimensions `hull` is either a scipy

How to find convex hull in a 3 dimensional space

落爺英雄遲暮 提交于 2019-11-26 19:25:36
问题 Given a set of points S (x, y, z) . How to find the convex hull of those points ? I tried understanding the algorithm from here, but could not get much. It says: First project all of the points onto the xy-plane, and find an edge that is definitely on the hull by selecting the point with highest y-coordinate and then doing one iteration of gift wrapping to determine the other endpoint of the edge. This is the first part of the incomplete hull. We then build the hull iteratively. Consider this