I use NativeCameraView and want to take pictures with camera resolutions. But I can take pictures only in preview resolution. mRgba.cols() and mRgba.rows() get resolution of display but I want to capture with camera resolution and I want the user to choose camera resolution.
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
// TODO Auto-generated method stub
/*
mRgba = inputFrame.rgba();
Imgproc.cvtColor(mRgba, mRgba, Imgproc.COLOR_RGB2HSV_FULL);
return mRgba;
*/
// http://answers.opencv.org/question/12265/how-to-display-a-mat-in-imageview/
if (take_pic)
{
take_pic = false;
mRgba = inputFrame.rgba();
bitmap = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(),Bitmap.Config.ARGB_8888);
Utils.matToBitmap(mRgba, bitmap);
// http://stackoverflow.com/questions/5776684/how-can-i-convert-a-view-to-a-drawable
//v.setDrawingCacheEnabled(true);
//bitmap = Bitmap.createBitmap(v.getDrawingCache());
//Log.i(TAG,"onTouch event");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String currentDateandTime = sdf.format(new Date());
String fileName = Environment.getExternalStorageDirectory().getPath() +
"/camera" + currentDateandTime + ".jpg";
//mOpenCvCameraView.takePicture(fileName); //***
// http://stackoverflow.com/questions/4989182/converting-java-bitmap-to-byte-array
ByteArrayOutputStream stream = new ByteArrayOutputStream();;
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byteArray = stream.toByteArray();
try {
FileOutputStream fos = new FileOutputStream(fileName);
fos.write(byteArray);
fos.close();
//mCamera.startPreview();
} catch (java.io.IOException e) {
Log.e("PictureDemo", "Exception in photoCallback", e);
}
return mRgba;
}
How can I use display resolution for preview and capture with camera resolution using NativeCameraView?
And how can I find out camera resolutions for NativeCameraView (it hasn't a setResolution method like the JavaCameraView)?