What is the best way to capture images in android and process them with opencv ? should i use the surface view As here or i should use the opencv camera as in opencv samples ? and how can i load the captured image and convert it to Mat? Thanks in advance
private PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
if (pictureFile == null) {
Log.d("E",
"Error creating media file, check storage permissions ");
return;
}
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
//processImage();
} catch (FileNotFoundException e) {
Log.d("E", "File not found: " + e.getMessage());
} catch (IOException e) {
Log.d("E", "Error accessing file: " + e.getMessage());
}
}