Android OpenCV capture image

asked 2017-06-10 21:40:11 -0600

lirus7 gravatar image

updated 2018-12-24 05:11:47 -0600

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"/>

edit retag flag offensive close merge delete