在 android 中捕获图像并使用 opencv 处理它们的最佳方法是什么?我应该像这里一样使用表面视图,还是应该像在 opencv 示例中一样使用 opencv 相机?以及如何加载捕获的图像并将其转换为 Mat?提前致谢
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());
}
}