opencv - 如何通过OpenCV用序列图像制作视频

标签 opencv image-processing video

我正在做一个提取视频帧并将其重新制作为视频的小项目。
如何使序列图像重新回到视频?

这是我提取视频帧代码的一部分。

if (n_frame % 3 == 0)
        {
            //Save an image
            sprintf(filename, "frame%.3d.jpg", n_save++);
            imwrite(filename, frame);
            cout << "save: " << filename << endl;

        }

我将图片命名为frame000,frame001,frame002 ....等等。

我正在使用opencv 2.4.11。

非常感谢!

最佳答案

您使用了FFmpegFrameRecorder
字符串路径= Environment.getExternalStorageDirectory()。getPath()+“/ Video_images”;

        File folder = new File(path);

        File[] listOfFiles = folder.listFiles();

        if (listOfFiles.length > 0) {

            iplimage = new opencv_core.IplImage[listOfFiles.length];

            for (int j = 0; j < listOfFiles.length; j++) {

                String files = "";

                if (listOfFiles[j].isFile()) {
                    files = listOfFiles[j].getName();
                    System.out.println(" j " + j + listOfFiles[j]);
                }

                String[] tokens = files.split("\\.(?=[^\\.]+$)");
                String name = tokens[0];

                iplimage[j] = cvLoadImage(Environment.getExternalStorageDirectory().getPath() + "/Video_images/" + name + ".jpg");

            }    

记录器=新的FFmpegFrameRecorder(Constn.SS,480,480);
        try {
            recorder.setVideoCodec(13);
            recorder.setFrameRate(0.4d);
            recorder.setPixelFormat(0);
            recorder.setVideoQuality(1.0d);
            recorder.setVideoBitrate(4000);
            startTime = System.currentTimeMillis();
            recorder.start();
            int time = Integer.parseInt(params[0]);
            resp = "Slept for " + time + " milliseconds";
            for (int i = 0; i < iplimage.length; i++) {
                long t = 1000 * (System.currentTimeMillis() - startTime);
                if (t < recorder.getTimestamp()) {
                    t = recorder.getTimestamp() + 1000;
                }
                recorder.setTimestamp(t);
                recorder.record(iplimage[i]);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

关于opencv - 如何通过OpenCV用序列图像制作视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42272266/

相关文章:

python - 我的 OpenCV remap()ing 有什么问题?

c++ - 对Color Distance结果进行积分成像(逻辑错误)

image-processing - openCV检测闪烁的灯

wordpress - Youtube到视频的链接不再起作用了吗?

HTML5 视频不循环

c++ - 如果同时运行 GPU 密集光流算法,为什么会得到损坏的结果?

php - 使用 PHP 从多个图像中创建附加的照片拼贴图像

android - 如何在Android中使用opencv自动裁剪从相机拍摄的名片图像

java - 在 Java 中获取 Mathematica 图像

ios - 如何使用从套接字连接加载的数据初始化视频对象-iOS