OpenCV2.1 的 ffmpeg 似乎编译有问题,不能正常进行视频读写方面的操作,因此尝试调用 Matlab 来完成,不过也还没成功,详细记录如下:
1、在 Matlab 中通过 mex –setup 和 mbuild –setup 指定 VS2008 SP1 作为 C 编译器。
2、编写保存视频的 fun_saveVideo.m 文件如下:
<!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com -->
3、使用如下指令将 fun_saveVideo.m 编译为 动态链接库 供 VC 调用:
4、将生成的 libSaveVideo.h, libSaveVideo.lib, libSaveVideo.dll 三个文件复制到项目文件夹下,其中 lib 和 dll 文件复制到 debug 和 release 子文件夹内。
5、在 VS 界面 " \Tools \ Options \ Projects and Solutions \ VC++ Directories" 中,在 " Include files " 和 " Library files " 中分别添加下列目录(默认安装位置):
6、在项目属性" \Project \ Properties \ Configuration Properties \ Linker \ Input " 中添加 mclmcrrt.lib, libmx.lib, libmat.lib, mclmcr.lib 。
7、在项目的 Solution Explorer 的 Header Files 中添加 libSaveVideo.h ,在该文件的最下面可以看到函数的声明:
<!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com -->
8、在 ******(项目名称).h 中加入如下代码(如果不加 ‘#pragma comment(lib,’”libSaveVideo”)’,则编译链接时会出现错误“error LNK2019: unresolved external symbol”):
<!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com -->
9、函数调用的具体代码:
10、编译链接都通过,但实际运行时出错,可能是 m 文件编写不合理 或其它原因,有待进一步分析。
发表评论
评论