Ask Your Question

Revision history [back]

Android - I try to get simple access to Mat

Hello everybody, I am trying to learn using OpenCV in Android apps. I believe that my code right now go through every element of grayscale Mat (which is camera frame). My question is: Why it is so slow? I get less than 1 fps. Its strange, because Android OpenCV examples works fine on my device.

This is heart of my code:

public void onCameraViewStarted(int width, int height) {
         mGray = new Mat(height, width, CvType.CV_8U);   
     }

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {


         mGray = inputFrame.gray();

         for(int i=0; i<mGray.rows(); i++){
             for (int j=0; j<mGray.cols();j++){
                 n2Pixel = (byte) mGray.get(i, j)[0]; } }
        return mGray;
}

Everything else is the same as in the tutorial (http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html)