Skip to content Skip to sidebar Skip to footer

How Can I Change This Project To A Opencv Realtime Face Detection App?

Project is a realtime image processer same as my Project but it uses two values wich are input and output(i remember that these projects are using frame for processing like that).

Solution 1:

Here you made some changes to the definition of the C++ method Java_com_example_nativeopencvandroidtemplate_MainActivity_adaptiveThresholdFromJNI, you will therefore have to reflect these changes on the Kotlin side, as this method is called from your MainActivity.kt using JNI. Here is the code you'll have to adapt in MainActivity.kt:

classMainActivity : Activity(), CameraBridgeViewBase.CvCameraViewListener2 {

    ...

    overridefunonCameraFrame(inputFrame: CameraBridgeViewBase.CvCameraViewFrame): Mat {
        val mat = inputFrame.gray()

        adaptiveThresholdFromJNI(mat.nativeObjAddr)

        return mat
    }

    privateexternalfunadaptiveThresholdFromJNI(matAddr: Long)

    ...

}

Here adaptiveThresholdFromJNI was adapted to handle only one argument (as you did with the C++ equivalent) and that one argument is then returned from onCameraFrame to be displayed on the screen.

I see in your C++ code that the first thing you try to do is to convert your input Mat to gray, but this is not necessary because the Mat passed to your C++ code is already gray (see val mat = inputFrame.gray()).

If you want to keep your C++ code intact, you can also pass the colorized version of the camera view frame to your C++ code by using val mat = inputFrame.rgba().

Post a Comment for "How Can I Change This Project To A Opencv Realtime Face Detection App?"