我在获取蒙版后使用Core.inRange从实时摄像头馈送中检测到蓝色,即在我按位时imgThresholded,它显示了重叠的帧,我怎么只能得到一帧?
Frames are ovelaping for the detected object

这是我的代码:

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {

     Imgproc.cvtColor(inputFrame.rgba(),imgHSV,Imgproc.COLOR_RGB2HSV);
          Core.inRange(imgHSV,new Scalar(100, 100, 100), new Scalar(120, 255,
          255),imgThresholded); // Blue Color
   Core.bitwise_and(inputFrame.rgba(),inputFrame.rgba(),tempImg,imgThresholded);
        return tempImg;
}

最佳答案

似乎是因为您没有清除tempImg Mat并多次使用“旧”内容。尝试将tempImg.setTo(new Scalar(0,0,0,255))添加到onCameraFrame()。像这样:

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {

   tempImg.setTo(new Scalar(0,0,0,255));

   Imgproc.cvtColor(inputFrame.rgba(),imgHSV,Imgproc.COLOR_RGB2HSV);
          Core.inRange(imgHSV,new Scalar(100, 100, 100), new Scalar(120, 255,
          255),imgThresholded); // Blue Color
   Core.bitwise_and(inputFrame.rgba(),inputFrame.rgba(),tempImg,imgThresholded);
        return tempImg;
}

10-08 07:39