我正在使用下面的代码使用OnTouch事件捕获静态图像,但是一触摸我的应用就会崩溃:
public boolean onTouch(View v, MotionEvent event) {
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() +
"/DCIM/app/sample_picture_" + currentDateandTime + ".jpg";
Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
Imgcodecs.imwrite(fileName,mRgba);
return false;
}
我是opencv的新手。谢谢你的帮助!
答案 0 :(得分:0)
最后我发现了问题! mRgba未在onCameraViewStarted()中初始化。
public boolean onTouch(View v, MotionEvent event) {
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() +
"/DCIM/app/sample_picture_" + currentDateandTime + ".jpg";
Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
Imgcodecs.imwrite(fileName, mIntermediateMat);
return false;
}