我在获取口罩(即imgThresholded )后,使用Core.inRange从实时摄像头源中检测到蓝色。当我使用bitwise_and时,它显示重叠的帧,如何才能只获得一帧?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;
}发布于 2017-09-08 21:30:45
看起来,这是因为您没有清除tempImg Mat并多次使用“旧”内容。尝试向onCameraFrame()添加tempImg.setTo(new Scalar(0,0,0,255))。大概是这样的:
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;
}https://stackoverflow.com/questions/46015299
复制相似问题