基于Hi3559A ARM64位嵌入式平台的OpenCV2.4.9+ffmpeg2.0.7移植及应用
2017-09-07 14:32
801 查看
前言:
按照上一篇文章的方式移植后发现可以正常操作图片文件,不能正常获取视频文件,后来发现是因为OpenCV中的视频API接口依赖于FFmpeg的支持,因此必须得移植合适版本的FFmpeg库,最新的不一定好,能用即可!
在嵌入式设备上做视频图像处理还是需要依赖强大的工具才行,虽然移植的过程比较痛苦,但是成功,后面的开发任务就轻松很多,事半功倍,可以将宝贵的时间放在更High-Level的应用上。不定期更新具体操作图片,若有疑问,请留言交流!
1、准备文件
ffmpeg-2.0.7.tar.bz2
opencv-2.4.9.zip
2、FFmpeg移植
1、解压
2、编译配置
./configure --prefix=/home/bug1989/opencv/ffmpeg_install --cross-prefix= aarch64-hisiv610-linux- --enable-cross-compile --arch=arm64 --target-os=linux --cc= aarch64-hisiv610-linux- gcc
此处会有一个警告,说xxx-pkg-xxx找不到,无视即可,不要被下着了,是warning不是error!
3、make
4、make install
5、在prefix中寻找你想要的
3、OpenCV移植
1、解压
2、添加之前移植安装完成的FFmpeg库的pkgconfig信息
export PKG_CONFIG_LIBDIR=/home/bug1989/opencv/ffmpeg_install/lib/
export PKG_CONFIG_PATH=/home/bug1989/opencv/ffmpeg_install/lib/pkgconfig/
3、解压后的根路径下运行cmake-gui,配置信息如下,注意“Linux”大写,“Target include”选择only,配置opencv源码路径,配置build路径,
点击configuration由于不支持CUDA配置报错,手动删除CUDA选项,删除OpenCL相关,删除V4L2相关,禁用动态库,禁用测试用例,设置make install的
安装路径,根据实际需求微调各种选项^_^!,确保ffmpeg的配置选项开启后点击generation,
4、进入build文件夹
make
make install
5、在prefix中寻找你想要的
4、测试用例
VideoSample.cpp
5、有时间再补充细节吧,主要是写给自己看的
按照上一篇文章的方式移植后发现可以正常操作图片文件,不能正常获取视频文件,后来发现是因为OpenCV中的视频API接口依赖于FFmpeg的支持,因此必须得移植合适版本的FFmpeg库,最新的不一定好,能用即可!
在嵌入式设备上做视频图像处理还是需要依赖强大的工具才行,虽然移植的过程比较痛苦,但是成功,后面的开发任务就轻松很多,事半功倍,可以将宝贵的时间放在更High-Level的应用上。不定期更新具体操作图片,若有疑问,请留言交流!
1、准备文件
ffmpeg-2.0.7.tar.bz2
opencv-2.4.9.zip
2、FFmpeg移植
1、解压
2、编译配置
./configure --prefix=/home/bug1989/opencv/ffmpeg_install --cross-prefix= aarch64-hisiv610-linux- --enable-cross-compile --arch=arm64 --target-os=linux --cc= aarch64-hisiv610-linux- gcc
此处会有一个警告,说xxx-pkg-xxx找不到,无视即可,不要被下着了,是warning不是error!
3、make
4、make install
5、在prefix中寻找你想要的
3、OpenCV移植
1、解压
2、添加之前移植安装完成的FFmpeg库的pkgconfig信息
export PKG_CONFIG_LIBDIR=/home/bug1989/opencv/ffmpeg_install/lib/
export PKG_CONFIG_PATH=/home/bug1989/opencv/ffmpeg_install/lib/pkgconfig/
3、解压后的根路径下运行cmake-gui,配置信息如下,注意“Linux”大写,“Target include”选择only,配置opencv源码路径,配置build路径,
点击configuration由于不支持CUDA配置报错,手动删除CUDA选项,删除OpenCL相关,删除V4L2相关,禁用动态库,禁用测试用例,设置make install的
安装路径,根据实际需求微调各种选项^_^!,确保ffmpeg的配置选项开启后点击generation,
4、进入build文件夹
make
make install
5、在prefix中寻找你想要的
4、测试用例
VideoSample.cpp
#include <opencv2/opencv.hpp> #include <iostream> #include <stdio.h> #include <sys/time.h> #include <ctype.h> #define _MAX_FNAME 128 using namespace cv; using namespace std; static unsigned long get_current_time(void) { struct timeval tv; gettimeofday(&tv, NULL); return (tv.tv_sec*1000000 + tv.tv_usec); } int main() { int frmCnt = 0; int time_0,time_1; int width, height; double dt; VideoCapture capture("a.mkv"); width = (int)capture.get(CV_CAP_PROP_FRAME_WIDTH); height = (int)capture.get(CV_CAP_PROP_FRAME_HEIGHT); printf("Video size:%d %d\n", width, height); cv::VideoWriter record; record.open("record.avi", CV_FOURCC('X','V','I','D'), capture.get(CV_CAP_PROP_FPS), Size(534, 300)); time_0 = get_current_time(); while(1) { Mat frame, dispImg; capture >> frame; if(frame.empty()) { break; } /* Resize */ cv::resize(frame, dispImg, cv::Size(534,300)); /* Save with picture */ imwrite("resize.jpg", dispImg); /* Save with video */ char text[_MAX_FNAME] = {'\0'}; sprintf(text, "FrmCnt: %d", frmCnt); cv::putText(dispImg, string(text), Point(5,15), FONT_HERSHEY_COMPLEX_SMALL, 1, CV_RGB(255,0,0)); cv::rectangle(dispImg, cvPoint(100, 100), cvPoint(150, 150), cvScalar(0, 255, 255), 1, 4, 0 ); frmCnt++; //save frame and encode record.write(dispImg); if(frmCnt == 50) { break; } } time_1 = get_current_time(); dt = (time_1 - time_0)/1000000.0; printf("video end, frmCnt = %d, Consuming time %.3f s, %.1f FPS\n", \ frmCnt, dt, frmCnt/dt); return 0; }Makefile
#This makefile is used to opencv 2.4 CC = aarch64-hisiv610-linux-g++ DIR = /home/ubuntu/share/tangqi_code/opencv/opencv_3559_2.4.9 TARGETS := VideoSample_3559 LIBS = -lopencv_highgui \ -lopencv_imgproc \ -lopencv_core \ -lopencv_video \ -ldl \ -lIlmImf \ -llibjasper \ -llibjpeg \ -llibpng \ -llibtiff \ -lzlib \ -lavformat \ -lavcodec \ -lavdevice \ -lavfilter \ -lavutil \ -lswscale \ -lpthread \ INCLUDE = -I$(DIR)/include/ LIB_TARGET_DIR = -L$(DIR)/lib \ -L/$(DIR)/share/OpenCV/3rdparty/lib CPPFLAGS = --static all:$(TARGETS) $(TARGETS):VideoSample.cpp $(CC) $(CPPFLAGS) $(INCLUDE) $^ $(LIB_TARGET_DIR) $(LIBS) -o $@ clean: rm -f *.o $(TARGETS)其中Makefile中的DIR路径是第3步中编译好的OpenCV的安装路径
5、有时间再补充细节吧,主要是写给自己看的
相关文章推荐
- 基于Hi3559A ARM64位嵌入式平台的OpenCV 2.4/3.1 移植
- Hi3559A ARM64位 嵌入式平台的OpenCV2.4移植
- 基于qt的嵌入式平台输入法:SYSZUXpinyin移植到arm后,UDP接收端中文乱码 本地中文乱码 解决
- ARM硬件平台上基于UCOS移植Lwip网络协议栈 分类: 嵌入式开发学习 2015-06-14 10:33 55人阅读 评论(1) 收藏
- 基于ARM的嵌入式Linux移植真实体验(5)――应用实例
- 基于ARM的嵌入式Linux移植真实体验(5)――应用实例
- 基于qt的嵌入式平台输入法:SYSZUXpinyin移植到arm后,UDP接收端中文乱码 本地中文乱码 解决
- OpenCV移植到ARM平台---Opencv with ffmpeg to ARM移植总结
- 基于ARM的嵌入式Linux开发平台
- 十年经验教你如何学习嵌入式系统(基于ARM平台)
- 基于ARM的嵌入式Linux开发平台
- 移植MySQL到嵌入式ARM平台
- 如何学习嵌入式系统(基于ARM平台)
- 【转载】基于Android平台的x264的移植与应用(一):移植篇
- 基于qt的嵌入式平台输入法:SYSZUXpinyin移植到arm后,UDP接收端中文乱码 本地中文乱码 解决
- 基于Android平台的x264的移植与应用(一):移植篇
- 移植MySQL到嵌入式ARM平台
- OpenCV 2.4.9在Ubuntu 12.04下的安装 && 移植到ARM上
- 将交叉编译好的OpenCV移植到ARM平台
- Android平台下OpenCV移植与使用---基于C/C++