Log in

View Full Version : Convex Hull using JavaCV or WPIjavaCv


divixsoft
24-01-2013, 17:36
how would I convex hull a binary image with either JavaCV or WPIJavaCV?

Currently i am using:
public static WPIContour[] findConvexContours(WPIBinaryImage image)
{
image.validateDisposed();

IplImage tempImage = IplImage.create(image.image.cvSize(), image.image.depth(), 1);

opencv_core.cvCopy(image.image, tempImage);

CvSeq contours = new CvSeq();
opencv_imgproc.cvFindContours(tempImage, storage, contours, 256, opencv_imgproc.CV_RETR_LIST, opencv_imgproc.CV_CHAIN_APPROX_TC89_KCOS);
ArrayList<WPIContour> results = new ArrayList();
while (!WPIDisposable.isNull(contours)) {
CvSeq convexContour = opencv_imgproc.cvConvexHull2(contours, storage, opencv_imgproc.CV_CLOCKWISE, 1);
WPIContour contour = new WPIContour(opencv_core.cvCloneSeq(convexContour, storage));
results.add(contour);
contours = contours.h_next();


}

tempImage.release();
WPIContour[] array = new WPIContour[results.size()];
return results.toArray(array);
}

but it crashes the app when it runs.

Thanks,
Dimitri