我正在尝试在Android设备上使用OpenCV跟踪激光点.我想使用此激光点在我的cameraview上的画布上绘制.
我已经将我的camerapreview转换为HSV色彩空间,并使用阈值过滤(仅在H和V通道上)来分离我的Laserdot.这相当健壮.
public Mat onCameraFrame(CvCameraViewFrame cvf) {
// Grab the video frame
cvf.rgba().copyTo(originalFrame);
cvf.rgba().copyTo(frame);
// Convert it to HSV
Imgproc.cvtColor(frame, frame, Imgproc.COLOR_RGB2HSV);
// Split the frame into individual components (separate images for H, S,
// and V)
mChannels.clear();
Core.split(frame, mChannels); // Split channels: 0-H, 1-S, 2-V
frameH = mChannels.get(0);
// frameS = mChannels.get(1);
frameV = mChannels.get(2);
// Apply a threshold to each component
Imgproc.threshold(frameH, frameH, 155, 160, Imgproc.THRESH_BINARY);
// Imgproc.threshold(frameS, frameS, 0, 100, Imgproc.THRESH_BINARY);
Imgproc.threshold(frameV, frameV, 250, 256, Imgproc.THRESH_BINARY);
// Perform an AND operation
Core.bitwise_and(frameH, frameV, frame);
// Display the result.
frameH.release();
// frameS.release();
frameV.release();
frame.release();
return originalFrame;
}
现在,我试图获取激光点中心的坐标.我尝试在框架上使用findContours函数,但这会导致多个点.
我希望有人能为我指明正确的方向,并提供一些过滤器下一步使用的技巧.
以下是显示已处理帧的屏幕截图.