Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaCV-使用阈值图像查找凸面形状轮廓_Java_Image Processing_Opencv_Javacv - Fatal编程技术网

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

我正在使用JavaCV开发一个形状识别项目,我发现了一些OpenCV代码来识别特定阈值图像中的凸面形状。我尝试将它从openCV转换为javaCV。但当我运行代码时,它在检查轮廓时出现了停顿。有人能帮忙找出错误吗?谢谢

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();
                 }
好消息:)你不能在每个循环迭代中打印一些
轮廓的表示吗?