Javacv Blob detection

后端 未结 2 996
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 17:53

I would like to use some blob detection in my application which is written in Java and thus using JavaCV instead of OpenCV. I found many classes like:<

2条回答
  •  旧时难觅i
    2021-02-06 18:26

    public static IplImage detectObjects(IplImage srcImage){
    
        IplImage resultImage = cvCloneImage(srcImage);
    
        CvMemStorage mem = CvMemStorage.create();
        CvSeq contours = new CvSeq();
        CvSeq ptr = new CvSeq();
    
        cvFindContours(srcImage, mem, contours, Loader.sizeof(CvContour.class) , CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));
    
        CvRect boundbox;
    
        for (ptr = contours; ptr != null; ptr = ptr.h_next()) {
            boundbox = cvBoundingRect(ptr, 0);
    
            cvRectangle( resultImage, cvPoint( boundbox.x(), boundbox.y() ), cvPoint( boundbox.x() + boundbox.width(), boundbox.y() + boundbox.height()),cvScalar( 0, 255, 255, 0 ), 3, 0, 0 ); 
        }
    
        return resultImage;
    }
    

提交回复
热议问题