- 收藏
- 点赞
- 分享
- 举报
移植opencv3.20到3519步骤
[i=s] 本帖最后由 liusir 于 2017-2-22 14:31 编辑 [/i]
[backcolor=LightBlue][p=30, 2, left][b][size=5]1.移植环境:[/size][/b]
[p=30, 2, left]Ubuntu15.10 + arm-hisiv500-linux-
[p=30, 2, left]opencv3.20 下载地址
[p=30, 2, left][b][size=5]2.移植步骤:[/size][/b]
[p=30, 2, left][b]1)安装cmake-gui[/b]
[p=30, 2, left] shunzhi@ubuntu:~/hisi$ sudo apt-get install cmake-gui
[p=30, 2, left][b]2)新建一个opencv目录存放opencv-3.2.0.zip,并解压[/b]
shunzhi@ubuntu:~/hisi$ mkdir opencv
shunzhi@ubuntu:~/hisi$ ls
opencv opencv-3.2.0.zip
shunzhi@ubuntu:~/hisi$ unzip opencv-3.2.0.zip -d opencv
shunzhi@ubuntu:~/hisi$ cd opencv
shunzhi@ubuntu:~/hisi/opencv$ mkidr build _install
shunzhi@ubuntu:~/hisi/opencv$ ls
build opencv-3.2.0 _install [/p]
[p=30, 2, left][b]3)配置opencv编译环境[/b]
shunzhi@ubuntu:~/hisi/opencv/opencv-3.2.0$ ls
3rdparty cmake CONTRIBUTING.md doc LICENSE platforms samples
apps CMakeLists.txt data include modules README.md
shunzhi@ubuntu:~/hisi/opencv/opencv-3.2.0$cmake-gui [/p]
[p=30, 2, left]点击Browse Source选择~/hisi/opencv/opencv-3.2.0
[p=30, 2, left]点击Browse Build选择~/hisi/opencv/build
[p=30, 2, left]点击Configure [/p]
[p=30, 2, left]此时出现的对话框选择最后一项:Specify options for cross-compiling
[p=30, 2, left]点击NEXT
[p=30, 2, left]Operating System填写 arm-hisiv500-linux
[p=30, 2, left]C填写arm-hisiv500-linux-gcc
[p=30, 2, left]C++填写arm-hisiv500-linux-g++ [/p]
[p=30, 2, left]点击finish,然后等待Configuration done
[p=30, 2, left]然后在出现的列表中修改CMAKE_INSTALL_PREFIX为~/hisi/opencv/_install
[p=30, 2, left]点击Generate
[p=30, 2, left]等待Generation done
[p=30, 2, left]之后关闭cmake软件。 [/p]
[p=30, 2, left][b]4)编译opencv[/b]
shunzhi@ubuntu:~/hisi/opencv/build$make[/p]
[p=30, 2, left]编译中遇到的问题:
[color=DarkOrange] ../../lib/libopencv_core.so: undefined reference to pthread_mutex_trylock' ../../lib/libopencv_core.so: undefined reference to
pthread_mutexattr_settype'
../../lib/libopencv_core.so: undefined reference to dlsym' ../../lib/libopencv_core.so: undefined reference to
pthread_mutexattr_destroy'
../../lib/libopencv_imgcodecs.so: undefined reference to pthread_create' ../../lib/libopencv_core.so: undefined reference to
pthread_mutexattr_init'
../../lib/libopencv_core.so: undefined reference to dlopen' ../../lib/libopencv_imgcodecs.so: undefined reference to
pthread_join'
collect2: error: ld returned 1 exit status
modules/core/CMakeFiles/opencv_perf_core.dir/build.make:816: recipe for target 'bin/opencv_perf_core' failed
make[2]: [bin/opencv_perf_core] Error 1
CMakeFiles/Makefile2:1341: recipe for target 'modules/core/CMakeFiles/opencv_perf_core.dir/all' failed
make[1]: [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2[/p][/color]
[p=30, 2, left]问题原因:
cmake不认识我定义的arm-hisiv500-linux系统标记,没有加上库pthread和rt的链接选项[/p]
[p=30, 2, left]解决方案:修改CMakeCache.txt文件192行处
//Flags used by the linker.
CMAKE_EXE_LINKER_FLAGS:STRING= -lpthread -lrt[/p]
[p=30, 2, left][b]5)安装opencv[/b]
shunzhi@ubuntu:~/hisi/opencv/build$make install
shunzhi@ubuntu:~/hisi/opencv/_install$ ls
bin include lib LICENSE share [/p]
[p=30, 2, left][b][size=5]3.测试:[/size][/b]
[p=30, 2, left][b]1)编译测试程序[/b]
shunzhi@ubuntu:~/hisi/opencv$ pwd
/home/shunzhi/hisi/opencv
shunzhi@ubuntu:~/hisi/opencv$ ls
build _install opencv-3.2.0 test
shunzhi@ubuntu:~/hisi/opencv$ cd test/
shunzhi@ubuntu:~/hisi/opencv/test$ ls
Makefile opencv_hisi.c
shunzhi@ubuntu:~/hisi/opencv/test$ make
[Compiling] opencv_hisi.c ...
shunzhi@ubuntu:~/hisi/opencv/test$ ls
Makefile opencv_hisi opencv_hisi.c opencv_hisi.o
shunzhi@ubuntu:~/hisi/opencv/test$ [/p]
[p=30, 2, left][b]2)测试程序[/b]
[p=30, 2, left]opencv_hisi.c
[code]#include <opencv/cv.h>
include <opencv/highgui.h>
#include <stdio.h>[/p]
int main( int argc, char** argv )
{
IplImage* pImg; // 声明IplImage指针
// 载入图像,强制转化为Gray
if( argc == 3 && (pImg = cvLoadImage( argv[1], 0)) != 0 )
{
IplImage* pImg2 = cvCreateImage(cvGetSize(pImg), pImg->depth, pImg->nChannels);
cvCopy(pImg, pImg2, NULL);
cvSaveImage(argv[2], pImg2);// 把图像写入文件
cvReleaseImage( &pImg ); // 释放图像
cvReleaseImage( &pImg2 ); // 释放图像
printf("Success!\n");
return 0;
}
printf("Fail!\n");
return -1;
}[/code]
[p=30, 2, left]Makefile:
[code]CC = arm-hisiv500-linux-g++
DEMOTAR = opencv_hisi
DEMOOBJ = opencv_hisi.o
CFLAGS += -g -Wall -I$(shell pwd)/../_install/include
LDFLAGS += -L$(shell pwd)/../_install/lib -Wl,-Bdynamic -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lpthread -lrt
%.o: %.c
@echo "[Compiling] $< ..."
@$(CC) $(CFLAGS) -c $<
all: $(DEMOTAR)
$(DEMOTAR):$(DEMOOBJ)
@$(CC) -o $@ $^ $(LDFLAGS)
.PHONY : clean
clean:
rm -rf $(DEMOOBJ) $(DEMOTAR)[/code]
[p=30, 2, left][size=5][b]4.测试结果[/b][/size]
[p=30, 2, left][b]1)将opencv库拷贝到3519的开发板/usr/lib目录下。[/b]
/usr/lib # ls
libopencv_calib3d.so libopencv_imgproc.so libopencv_superres.so
libopencv_core.so libopencv_ml.so libopencv_video.so
libopencv_features2d.so libopencv_objdetect.so libopencv_videoio.so
libopencv_flann.so libopencv_photo.so libopencv_videostab.so
libopencv_highgui.so libopencv_shape.so
libopencv_imgcodecs.so libopencv_stitching.so[/p]
[p=30, 2, left][b]2)开发板执行测试程序[/b]
[p=30, 2, left] /mnt # ./opencv_hisi lena.jpg lena_test.jpg[/p]
[p=30, 2, left][b]注:[/b]
[p=30, 2, left]1)测试程序功能是将彩色图片转化为灰色图片(彩转灰)。
[p=30, 2, left]2)lean.jpg文件在 opencv/opencv-3.2.0/samples/data/lena.jpg
位置。[postbg]bg4.png[/postbg]
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
-
2015-01-20 22:07:13
-
2016-01-29 17:28:20
-
2019-01-17 09:51:14
-
2018-05-28 16:26:37
-
2016-03-25 18:04:45
-
2023-03-13 14:45:24
-
2015-06-09 11:11:23
-
2017-02-24 14:52:47
-
2015-06-06 22:07:14
-
2018-06-28 14:52:58
-
2018-12-06 08:59:33
-
2017-04-27 14:22:50
-
2019-03-30 13:17:16
-
2015-05-12 14:05:12
-
2019-01-28 09:30:29
-
2019-01-26 09:46:16
-
2018-12-03 15:49:53
-
2015-02-12 16:21:07
-
2021-01-23 16:48:48
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明