反投影的断言失败

时间:2015-02-05 21:25:43

标签: opencv4android

我尝试使用CamShift进行对象跟踪。 但是我收到了错误。这个错误来自反投影

以下是来自LOGCAT的错误消息

断言失败(rsz == dims * 2 ||(rsz == 2&& _1d)||(rsz == 0&& images.depth(0)== CV_8U))void cv :: calcBackProject(cv :: InputArrayOfArrays,const std :: vector&,cv :: InputArray,cv :: OutputArray,const std :: vector&,double)

这是我的代码。任何人都可以帮助我吗?(sory my poor eng)

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {

     mrgba=inputFrame.rgba();

     firstTime++;

     Mat roiHist=new Mat();

     //  set up the ROI for tracking
     // implemented only one time
    if(firstTime==2)
    {
      imgRoi=mrgba.submat(roi.x,roi.x+roi.width,roi.y,roi.y+roi.height);

      Imgproc.cvtColor(imgRoi,mHsv, Imgproc.COLOR_BGR2HSV);//hsv'yi bul     
      Core.inRange(mHsv,new Scalar(0,60,32), new Scalar(180,255,255), mask);
      roiHist=HistogramAndNormalize();
    }
    Imgproc.cvtColor(mrgba,mHsv, Imgproc.COLOR_BGR2HSV);
    List<Mat> lHSV= Arrays.asList(mHsv);
    Mat backproj = new Mat();
    Imgproc.calcBackProject(lHSV, new MatOfInt(0, 1),roiHist, backproj,new    MatOfFloat(0, 179, 0, 255), 1);
    RotatedRect rect=Video.CamShift(backproj,roi, new TermCriteria(TermCriteria.EPS,10,1));
    roi = rect.boundingRect();
    Core.rectangle( mrgba,new org.opencv.core.Point(roi.x,roi.y),new org.opencv.core.Point(roi.x+roi.width,roi.y+roi.height),
    new Scalar(0,255,0,255));   
    return mrgba;
}

0 个答案:

没有答案