Ask Your Question

pkpkpk's profile - activity

2015-03-28 10:38:56 -0600 commented question Android - I try to get simple access to Mat

I want to iterate over pixels because I want to try doing my own algorithms. I was thinking that every OpenCV function (for example threshold) has to iterate over pixels :(. My goal is to find black thing (eg. square) with white frame.

2015-03-28 10:18:51 -0600 asked a question 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/...)