JavaCV-使用阈值图像查找凸面形状轮廓
我正在使用JavaCV开发一个形状识别项目,我发现了一些OpenCV代码来识别特定阈值图像中的凸面形状。我尝试将它从openCV转换为javaCV。但当我运行代码时,它在检查轮廓时出现了停顿。有人能帮忙找出错误吗?谢谢JavaCV-使用阈值图像查找凸面形状轮廓,java,image-processing,opencv,javacv,Java,Image Processing,Opencv,Javacv,我正在使用JavaCV开发一个形状识别项目,我发现了一些OpenCV代码来识别特定阈值图像中的凸面形状。我尝试将它从openCV转换为javaCV。但当我运行代码时,它在检查轮廓时出现了停顿。有人能帮忙找出错误吗?谢谢 IplImage detectThrs = getThresholdImage(img); System.err.println("Stucked!!"); CvMemStorage storage = CvMe
IplImage detectThrs = getThresholdImage(img);
System.err.println("Stucked!!");
CvMemStorage storage = CvMemStorage.create();
CvSeq contour = new CvSeq(null);
cvFindContours(detectThrs, storage, contour, Loader.sizeof(CvContour.class), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
System.err.println("Stucked 2 !!");
CvSeq approx = null;
CvRect bound = null;
CvRect boundMax = null;
CvRect pos = null;
while (contour != null && !contour.isNull()) {
System.err.println("Stucked in while!!");
bound = cvBoundingRect(contour, 0);
approx = cvApproxPoly(contour, Loader.sizeof(CvContour.class), storage, CV_POLY_APPROX_DP, cvContourPerimeter(contour) * 0.02, 0);
if(cvCheckContourConvexity(approx) != 0){
if(bound.width() > 4 || bound.height() > 4){
cvRectangle(
detectThrs,
cvPoint(bound.x(), bound.y()),
cvPoint(bound.x()+bound.width(), bound.y()+bound.height()),
CvScalar.RED,4,
CV_AA, 0
);//2 is thickness CV_AA is type of line 0 means no shift
//cvSaveImage(++ii + "colorMaskTest.jpg", detectThrs);
paint(img, bound.x(), bound.y());
}
}
}
contour = contour.h_next();
}
好消息:)你不能在每个循环迭代中打印一些轮廓的表示吗?