Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在opencv相机中捕获帧并显示意图_Android_Opencv_Android Intent_Android Camera Intent_Opencv4android - Fatal编程技术网

Android 在opencv相机中捕获帧并显示意图

Android 在opencv相机中捕获帧并显示意图,android,opencv,android-intent,android-camera-intent,opencv4android,Android,Opencv,Android Intent,Android Camera Intent,Opencv4android,这是我目前为和opencv库相机提供的触摸屏捕获功能。它工作正常,可以将图像保存到SD卡。 不过,我也希望在拍摄完照片后能够参与到这次活动中来。最终的结果是,它无法捕获照片(我已检查了存储空间),但可以用于其他活动。 @SuppressLint("SimpleDateFormat") @Override public boolean onTouch(View v, MotionEvent event) { Log.i(TAG, "onTouch event"); Simp

这是我目前为和opencv库相机提供的触摸屏捕获功能。它工作正常,可以将图像保存到SD卡。 不过,我也希望在拍摄完照片后能够参与到这次活动中来。最终的结果是,它无法捕获照片(我已检查了存储空间),但可以用于其他活动。

@SuppressLint("SimpleDateFormat")
@Override    
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 saveDir = Environment.getExternalStorageDirectory().getPath() + "/DCIM/OCV/TouchSave";
    File dirCheck = new File(saveDir);
    if(!dirCheck.exists()) {
        dirCheck.mkdirs();
    }
    String fileName = saveDir + "/touch_picture_" + currentDateandTime + ".jpg";
    try {
        mOpenCvCameraView.takePicture(fileName);

        Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
    } catch(Exception ex) {
        ex.printStackTrace();
    }

    last_photo_name = fileName;

    return false;
}
这是我添加的代码行。 有谁能帮我添加这些代码行,但它也可以捕获照片?非常感谢。

@SuppressLint("SimpleDateFormat")
@Override    
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 saveDir = Environment.getExternalStorageDirectory().getPath() + "/DCIM/OCV/TouchSave";
    File dirCheck = new File(saveDir);
    if(!dirCheck.exists()) {
        dirCheck.mkdirs();
    }
    String fileName = saveDir + "/touch_picture_" + currentDateandTime + ".jpg";
    try {
        mOpenCvCameraView.takePicture(fileName);

        Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
    } catch(Exception ex) {
        ex.printStackTrace();
    }

    last_photo_name = fileName;

    return false;
}
还有,我还有一个问题我在opencv cameraview上添加了一个按钮,但无法在onClick函数上添加上述捕获函数。如何将它们添加到onClick函数中?非常感谢。

@SuppressLint("SimpleDateFormat")
@Override    
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 saveDir = Environment.getExternalStorageDirectory().getPath() + "/DCIM/OCV/TouchSave";
    File dirCheck = new File(saveDir);
    if(!dirCheck.exists()) {
        dirCheck.mkdirs();
    }
    String fileName = saveDir + "/touch_picture_" + currentDateandTime + ".jpg";
    try {
        mOpenCvCameraView.takePicture(fileName);

        Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
    } catch(Exception ex) {
        ex.printStackTrace();
    }

    last_photo_name = fileName;

    return false;
}