Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Android OpenCV capture image

I have done a lot of research on internet like probably gone through all the answers but cant find what the error is. I am trying to just save a picture if it goes above a certain value which obtained from a C++ function.But Im not able to capture that particulat frame.I am trying to use imwrite() in OnCameraFrame().The logcat shows the image has been written successfully but i cant find the image anywhere on my phone(External Storage) and below is the manifest.xml of the app(permissions) .

@Override public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) { mRgba=inputFrame.rgba(); String ans=cvClass.detect(mRgba.getNativeObjAddr()); Log.i(TAG,ans); // String filename="/home/Downloads/test1.bmp"; if(Double.parseDouble(ans)>2.5) { Log.i(TAG,"try"); String filename = "please.bmp";(tried both jpg and bmp)

    File path = Environment.getExternalStorageDirectory();
    File file = new File(path, filename);
    Boolean bool = null;
    filename = file.toString();
    bool = Imgcodecs.imwrite(filename,mRgba);

    if (bool == true){
        Log.d(TAG, "SUCCESS writing image to external storage");
        Log.d(TAG, filename);
        //this.onDestroy();
        imread(filename);
    }
    else
        Log.d(TAG, "Fail writing image to external storage");

}
return mRgba;

}

}

<uses-permission android:name="android.permission.CAMERA"/> <uses-feature android:name="android.hardware.camera"/> <uses-permissionandroid:name="android.permission.write_external_storage"/>

Android OpenCV capture image

I have done a lot of research on internet like probably gone through all the answers but cant find what the error is. I am trying to just save a picture if it goes above a certain value which obtained from a C++ function.But Im not able to capture that particulat frame.I am trying to use imwrite() in OnCameraFrame().The logcat shows the image has been written successfully but i cant find the image anywhere on my phone(External Storage) and below is the manifest.xml of the app(permissions) .

@Override public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) { mRgba=inputFrame.rgba(); String ans=cvClass.detect(mRgba.getNativeObjAddr()); Log.i(TAG,ans); // String filename="/home/Downloads/test1.bmp"; if(Double.parseDouble(ans)>2.5) { Log.i(TAG,"try"); String filename = "please.bmp";(tried both jpg and bmp)

    File path = Environment.getExternalStorageDirectory();
    File file = new File(path, filename);
    Boolean bool = null;
    filename = file.toString();
    bool = Imgcodecs.imwrite(filename,mRgba);

    if (bool == true){
        Log.d(TAG, "SUCCESS writing image to external storage");
        Log.d(TAG, filename);
        //this.onDestroy();
        imread(filename);
    }
    else
        Log.d(TAG, "Fail writing image to external storage");

}
return mRgba;

}

}

<uses-permission android:name="android.permission.CAMERA"/> <uses-feature android:name="android.hardware.camera"/> <uses-permissionandroid:name="android.permission.write_external_storage"/>