http://www.eefocus.com/sj229335457/blog/13-06/295352_ad954.html
【OpenHW12】rainysky陪你一起在zedboard上移植qt+opencv(六):在zedboard上运行Opencv
参考这里
想要在zed上用opencv要cmake
cmake时候会有很多可选的 选项 这个至关重要 影响以后在zed上对 各种图片格式 视频格式 什么什么 各种东西的支持
在这里和pc不太一样了,需要设置编译环境,在opencv-2.4.4下面新建一个文件,文件名为toolchain.cmake,里面的内容为:/opt/zedboard/opencv_zed/OpenCV-2.4.3 而我是在这里 建 立 toolchain.camke
不就是不能jpg\格式吗
不重要先做功能再 优化!!!
以后都用bmp就行啦
这样的话 我这个
【OpenHW12】rainysky陪你一起在zedboard上移植qt+opencv(六):在zedboard上运行Opencv
(六 ) 就算做完啦2015-------3-----21号
------------------------------------------------------------------------------------
2015--3--23还是得回来做这个镜像
为了确认他没问题啊
就严格按照他说的来
就当成没那个小写的opecv2.4.3文件夹
只用大写的 就好 cmake -D CMAKE_TOOLCHAIN_FILE=toolchain.cmake -D CMAKE_INSTALL_PREFIX=/opt/zedboard/opencv_zed/OpenCV-2.4.3/install/ ../
进行cmake
遇到问题是
CMake Warning (dev) at cmake/OpenCVModule.cmake:667 (get_target_property):
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "opencv_highgui" has an INTERFACE_LINK_LIBRARIES property which
differs from its LINK_INTERFACE_LIBRARIES properties.
INTERFACE_LINK_LIBRARIES:
opencv_core;opencv_imgproc;dl;m;pthread;rt
LINK_INTERFACE_LIBRARIES:
Call Stack (most recent call first):
modules/highgui/CMakeLists.txt:280 (ocv_add_accuracy_tests)
This warning is for project developers. Use -Wno-dev to suppress it.
解决问题:::
cmake -Wno-dev -D CMAKE_TOOLCHAIN_FILE=toolchain.cmake -D CMAKE_INSTALL_PREFIX=/opt/zedboard/opencv_zed/OpenCV-2.4.3_3/install_zed/ ../
这样就好了
还是有问题::
可能是因为我忽略了这个问题
导致了 我warpAffine函数在zed上有问题
处理后没有结果
所以试试消除这个问题
ccmake ./ 不是必须的
cmake时候已经自动检测能按什么不能按什么 然后他自动在文件里写好了
ccmake就是为了进一步修改的
过程记录
opencv2。4。10版本 或者是opencv2。4。9版本中
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
可以
再ccmake 。/
进行查看
这时候直接c.........(注意不能直接c 要手动加上with_qt 我电脑自动检测不到)
(来来来 我试一下 事实证明 没有选with_qt也是可以的)
不知道这个是不是必须要 勾选的 之前的错误是因为没有写名字空间 cv
可以
如果关掉一些with 再c
可以
在opencv2。4。3版本中
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
可以
这时候问题来了
再ccmake 。/
进入查看完成 什么都不改
再c
不行了
报错是
CUDA_TOOLKIT_ROOT_DIR not found or specified
CMake Warning (dev) at cmake/OpenCVModule.cmake:667 (get_target_property):
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "opencv_highgui" has an INTERFACE_LINK_LIBRARIES property which
differs from its LINK_INTERFACE_LIBRARIES properties.
INTERFACE_LINK_LIBRARIES:
opencv_core;opencv_imgproc;dl;m;pthread;rt;/usr/lib/i386-linux-gnu/libz.so;lib
jpeg;/usr/lib/i386-linux-gnu/libpng.so;/usr/lib/i386-linux-gnu/libz.so;libtiff
;libjasper;IlmImf;gtk-x11-2.0;gdk-x11-2.0;atk-1.0;gio-2.0;pangoft2-1.0;pangoca
iro-1.0;gdk_pixbuf-2.0;cairo;pango-1.0;fontconfig;gobject-2.0;glib-2.0;freetyp
e;gthread-2.0;glib-2.0;avcodec;avformat;avutil;swscale
所以赶紧换版本吧
我改用了2。4。10结果在make时候报错!!
/opt/zedboard/opencv_pc/opencv-2.4.10/modules/core/src/system.cpp: In function ‘(static initializers for /opt/zedboard/opencv_pc/opencv-2.4.10/modules/core/src/system.cpp)’:
/opt/zedboard/opencv_pc/opencv-2.4.10/modules/core/src/system.cpp:280:10: error: inconsistent operand constraints in an ‘asm’
);
^
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o] 错误 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] 错误 2
make: *** [all] 错误 2
https://github.com/Itseez/opencv/commit/ea50be0529c248961e1b66293f8a9e4b807294a6 这位大神解决了这个问题
做好了pc版本opencv2。4。10
再做zed版本的opencv2。4。10
同样还是先cmake
这里会自动检测能with什么东西
但是具体到zed上要修改
所以 ccmake 。/
时候要全off(libv4l也off 暂时这样 我不知道行不行)
除了v4l是on
然后制作镜像!!
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/opencv-2.4.10# ls
3rdparty build CMakeLists.txt doc index.rst LICENSE platforms samples toolchain.cmake~
apps cmake data include install modules README.md toolchain.cmake
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/<span style="color:#FF0000;">opencv-2.4.10# dd if=/dev/zero of=opencv_lib.img bs=1M count=80</span>
记录了80+0 的读入
记录了80+0 的写出
83886080字节(84 MB)已复制,1.23954 秒,67.7 MB/秒
root@dong-Lenovo-G480:/opt/zedboard/opencv_z<span style="color:#FF0000;">ed/opencv-2.4.10# mkfs.ext2 -F opencv_lib.img </span>
mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks: 完成
文件系统标签=
OS type: Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
20480 inodes, 81920 blocks
4096 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=67371008
10 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: 完成
正在写入inode表: 完成
Writing superblocks and filesystem accounting information: 完成
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/opencv-2.4.10#
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/opencv-2<span style="color:#FF0000;">.4.10# chmod go+w opencv_lib.img
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/opencv-2.4.10# mount opencv_lib.img -o loop /mnt/
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/opencv-2.4.10# cp -rf /opt/zedboard/opencv_zed/opencv-2.4.10/install/lib/* /mnt/
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/opencv-2.4.10# chmod go-w opencv_lib.img </span>
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/opencv-2.4.10# umount /m
media/ mnt/
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/opencv-2.4.1<span style="color:#FF0000;">0# umount /mnt/
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/opencv-2.4.10# ls</span>
3rdparty build CMakeLists.txt doc index.rst LICENSE opencv_lib.img README.md toolchain.cmake
apps cmake data include install modules platforms samples toolchain.cmake~
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/opencv-2.4.10#
这里镜像做好了!!
测试仿射变换!!
qt上仿射变换 失败
裸opencv'上测试 。。。
arm-xilinx-linux-gnueabi-g++ -I /opt/zedboard/opencv_zed/opencv-2.4.4/install/include -I/opt/zedboard/opencv_zed/opencv-2.4.4/install/include/opencv -L/opt/zedboard/opencv_zed/opencv-2.4.4/install/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann ./edge_detection.cpp -o ./edge_detection.o
这个编译的写法不对!!
正确的写法是::
arm-xilinx-linux-gnueabi-g++ -I /opt/zedboard/opencv_zed/opencv-2.4.10/install/include/ -I /opt/zedboard/opencv_zed/opencv-2.4.10/install/include/opencv2 -I /opt/zedboard/opencv_zed/opencv-2.4.10/install/include/opencv -L /opt/zedboard/opencv_zed/opencv-2.4.10/install/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann ./test_zed_opencv_gray.cpp -o ./temp.o
也不对
报错是
/root/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.6.1/../../../../arm-xilinx-linux-gnueabi/bin/ld: warning: libopencv_photo.so.2.4, needed by /opt/zedboard/opencv_zed/opencv-2.4.10/install/lib/libopencv_contrib.so, not found (try using -rpath or -rpath-link)
/root/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.6.1/../../../../arm-xilinx-linux-gnueabi/bin/ld: warning: libopencv_gpu.so.2.4, needed by /opt/zedboard/opencv_zed/opencv-2.4.10/install/lib/libopencv_contrib.so, not found (try using -rpath or -rpath-link)
/root/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.6.1/../../../../arm-xilinx-linux-gnueabi/bin/ld: warning: libopencv_nonfree.so.2.4, needed by /opt/zedboard/opencv_zed/opencv-2.4.10/install/lib/libopencv_contrib.so, not found (try using -rpath or -rpath-link)
最后这么写就行了
root@dong-Lenovo-G480:/opt/zedboard/opencv_zed/code# arm-xilinx-linux-gnueabi-g++ -I /opt/zedboard/opencv_zed/opencv-2.4.10/install/include/ -I /opt/zedboard/opencv_zed/opencv-2.4.10/install/include/opencv2 -I /opt/zedboard/opencv_zed/opencv-2.4.10/install/include/opencv -L /opt/zedboard/opencv_zed/opencv-2.4.10/install/lib -lopencv_core -lopencv_imgproc -lopencv_highgui ./test_zed_opencv_gray.cpp -o ./temp.o
而在pc上编译的命令是“::
g++ test_warp.cpp -o test_warp `pkg-config opencv --cflags --libs`
直接opencv编译到zed上 不用qt
仍然不能做仿射变换!!!!
最最后:
已知imshow不能再zed上直接用,cap.open()函数不能在zed上直接用
是因为opencv调用了系统更底层的东西 ,而我的zed上没有
所以warpaffine在zed上运算结果为零 也是因为这个原因
(我也觉得不太可能 因为这个函数仅仅是线性变换啊!!)