OpenCV,无法从位图或IP摄像机录制视频?

时间:2018-09-26 10:02:10

标签: android opencv ip-camera

**

我尝试将位图(ip-camera)转换为来自OpenCV的视频。

它执行了打开和释放操作,但是我的视频是0 B。

我应该尝试哪个方向? 还是我缺少哪一部分? **

private void videoW(Bitmap bitmap) {
    if (isRecord) {
        mat = new Mat(bitmap.getWidth(), bitmap.getHeight(), CvType.CV_8UC3);
        if (mVideoWriter == null) {
            try {
                FileWriter fileWriter = new FileWriter(Environment.getExternalStorageDirectory()+"/Test/video.avi");
            } catch (IOException e) {
                e.printStackTrace();
            }
            mVideoWriter = new VideoWriter(recordfilepath(), VideoWriter.fourcc('M', 'P', '4', '2'), 30.0D, mat.size());
            mVideoWriter.open(recordfilepath(), VideoWriter.fourcc('M', 'P', '4', '2'), 30.0D, mat.size());
        }
        if (!mVideoWriter.isOpened()) {
            mVideoWriter.open(recordfilepath(), VideoWriter.fourcc('M', 'P', '4', '2'), 30.0D, mat.size());
        }
        Utils.bitmapToMat(bitmap, mat);
        mVideoWriter.write(mat);
    } else {
        if (mVideoWriter != null) {
            mVideoWriter.release();
            mVideoWriter = null;
        }
    }
}

0 个答案:

没有答案