OpenCV Android Background Subtraction

前端 未结 3 1580
醉梦人生
醉梦人生 2021-01-02 11:43

I am working on a robotics project using an Android phone as the main processor and the camera to detect movement. I got the Android binary package from OpenCV and got it co

3条回答
  •  生来不讨喜
    2021-01-02 12:49

    Have you tried using cvtColor with CV_RGB2RGBA and CV_RGBA2RGB. So, maybe try converting frame RGBA to RGB, then do background subtraction. Something like this:

    protected void processFrame(VideoCapture capture) {
        capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
        Mat rgb;
        Imgproc.cvtColor(mRgba, rgb, Imgproc.COLOR_RGBA2RGB);
        mBGSub.apply(rgb, mFGMask);
    }
    

    EDIT : You might check out the OpenCV unit-test for BackgroundSubtractorMOG located here. However, the test has fail("Not yet implemented"); in the main test case.

    I'm not sure if that means the test isn't complete, or the support for BackgroundSubtractorMOG is not implemented. You might try running the code contained in this unit-test to see if it actually works.

    Also, the C++ sample segment_objects.cpp might be helpful as a usage example.

    Hope that helps! :)

提交回复
热议问题