Ask Your Question

Vojta's profile - activity

2014-07-18 11:47:19 -0600 asked a question Android: unexpected behaviour (rectangles from mGrey appearing on screen)

Hi, could you please look at my problem? I am trying to make my own face detecting android app, which is based on mixed-processing and face detection tutorial. It runs super slow on my device cca 2.5 FPS on 240x160 resolution.

I was trying to find the problem and make it faster, so one of the things I made was displaying result in greyscale instead of RGB. When I changed it back, I forget to delete line where I was drawing rectangles to Greyscale Mat (mGr).

But for my surprise, those were still appearing on the screen (those were white), with approx one frame delay after red ones from the RGB Mat. So there were both. How is this possible? I did not draw into mRGB mat any white rectangles :/

Here I call it in Java:

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
    final int viewMode = mViewMode;
    switch (viewMode) {        
       case VIEW_MODE_FEATURES:
        // input frame has RGBA format
        mRgba = inputFrame.rgba();
        mGray = inputFrame.gray();

        myDetect();
        //Imgproc.cvtColor(mGray, mRgba, Imgproc.COLOR_GRAY2RGBA, 4);

        break;
    }

    return mRgba;
}

And this is how it looks like in C++ part

Mat& mGr = *(Mat*) addrGray;
Mat& mRgb = *(Mat*) addrRgba;

vector<Rect> highLight; // vector with rectangles to highlight detected items

detect(mGr, highLight, env, stages);

//highlight detected items on screen 
for (unsigned int i = 0; i < highLight.size(); i++) {
    rectangle(mRgb, highLight[i], Scalar(255, 0, 0, 255),THICKNESS);
    //rectangle(mGr, highLight[i], Scalar(255, 0, 0, 255),THICKNESS);
          // if I leave this here uncommented, white rectangle ghost will appear on my screen both with desired red ones...
}

Another thing is, that from the log, I can see that I am receiving plenty of frames, while I am still processing the first one. Could I somehow block receiving new frames till processing of present one finishes and therefore get some resources for ongoing detecting operation?

Thanks!