Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.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 opencv使用矩形跟踪移动对象_Java_Opencv_Javacv - Fatal编程技术网

使用javacv opencv使用矩形跟踪移动对象

使用javacv opencv使用矩形跟踪移动对象,java,opencv,javacv,Java,Opencv,Javacv,我目前正在做一个项目的一部分,使用javacv在视频中围绕移动对象创建矩形。我使用了这段代码,当我运行这段代码时,我得到了一个错误,称为this pointer address is null。有人能帮我吗?多谢各位 while(true) { colourImage = cvQueryFrame( capture ); if( colourImage==null ) break; //If this is the first time, initia

我目前正在做一个项目的一部分,使用javacv在视频中围绕移动对象创建矩形。我使用了这段代码,当我运行这段代码时,我得到了一个错误,称为this pointer address is null。有人能帮我吗?多谢各位

    while(true) {
        colourImage = cvQueryFrame( capture );

    if( colourImage==null ) break;

    //If this is the first time, initialize the images.
    if(first)
    {
    difference = colourImage.clone();
    temp = colourImage.clone();  

    cvConvertScale(colourImage, movingAverage, 1.0, 0.0);
first = false;
    }       

    //else, make a running average of the motion.
    else
    {

    cvRunningAvg(colourImage, movingAverage, 0.020, null);
    }


    //Convert the scale of the moving average.
    cvConvertScale(movingAverage,temp, 1.0, 0.0);

    //Minus the current frame from the moving average.
    cvAbsDiff(colourImage, temp, difference);


    //Convert the image to grayscale.
    cvCvtColor(difference,greyImage,CV_RGB2GRAY);

    //Convert the image to black and white.
    cvThreshold(greyImage, greyImage, 70, 255, CV_THRESH_BINARY);

    //Dilate and erode to get people blobs
    cvDilate(greyImage, greyImage, null, 18);

    cvErode(greyImage, greyImage, null, 10);


    CvSeq contour=new  CvSeq();
    CvMemStorage storage=CvMemStorage.create();
    cvFindContours(greyImage, storage, contour, Loader.sizeof(CvContour.class), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);

    System.out.println(contour.total());

你贴的代码有点难读。询问此问题之前是否进行了调试?当未检测到轮廓时,CVFindOnTours之后的contour.isNull可能为真。在这种情况下,contour.total将失败。这是发生错误的地方吗?