Android没有检测到激光

时间:2018-03-30 16:24:19

标签: android opencv opencv4android

我是 OpenCV 的新手。

我正在尝试使用此代码检测激光点。但是输出没有变化。我发现它不是检测激光。请帮助我解决这个问题。这是我的代码

@Override
    public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
        Mat frameH;
        Mat frameV;
        Mat frameS;

        //static int a=1;
        List<Mat> mChannels= new ArrayList<>();

        Mat originalFrame=new Mat();
        Mat frame=new Mat();

        inputFrame.rgba().copyTo(originalFrame);
        inputFrame.rgba().copyTo(frame);

        mRgba = inputFrame.rgba();

        Imgproc.cvtColor(frame,frame, Imgproc.COLOR_RGB2HSV);

        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(frameV, frameV, 250, 256, Imgproc.THRESH_BINARY);

        // Perform an AND operation
        Core.bitwise_and(frameH, frameV, frame);

        frameH.release();
        frameV.release();
        frameS.release();

        frame.release();

        return originalFrame; // This function must return
    }

0 个答案:

没有答案