Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

grab() always returning false

I am trying to capture real time synchronised images with android camera, at a fixed fps. I have an algorithm for that. But the grab() feature always return a false. i.e. I cant get any image captured. what can be the possible issue??

If I use the inputframe that I get from onCameraFrame(Mat inputframe) callback of CvCameraViewListener implemented activity, it works, then why not grab()??

 public void onCameraViewStarted(int width, int height) 
{

    capturedFrame=new Mat(height, width, CvType.CV_8UC4);
    vidCapture=new VideoCapture();
    Thread captureImageThread=new Thread(new cacheFrame());
    captureImageThread.start();
    ----------
            -----------
}

   private class cacheFrame implements Runnable
{

    @Override
    public void run()
    {

        while(true)
        {
            startTime = System.currentTimeMillis();

            if(vidCapture.grab())
            {
              Log.i("sumit", "frame  retreival started at : "+System.currentTimeMillis());
              vidCapture.retrieve(capturedFrame,Highgui.CV_CAP_ANDROID_GREY_FRAME);
            }
            if(capturedFrame!=null)
            {

               frameObject.image=capturedFrame.clone();
                 ---- 
                                     -----
                                     -----
                                     -----
                }       

            }


        }