Transplantation of opencv on arm and x86

Source: Internet
Author: User
Tags gtk

I. Development Environment

Operating System: fedora14

Opencv version: 2.0

Qt version: 4.7

Arm: mini6410

Cross-compilation tool: arm-linux-gcc-4.5.1

 

Ii. installation and configuration

The installation of the Linux system, the installation of cross QT-creator, and the installation of cross-compilation tools are basically no problem on the Internet, and can be used after testing. Here QT-creator installation encountered a small problem, according to the online and mini6410 development manual installation method is too complicated, with QtSdk-offline-linux-x86-v1.2.1.run installation is convenient and accurate.

This article focuses on how to install opencv in Linux, configure opencv to QT, and implement smooth running of QT + opencv GUI programs on x86 and arm platforms. Build a fast and convenient platform for future embedded pattern recognition.

 

I hope someone who solves this problem can contact me and start to install opencv2.4.2. After the installation is complete, write a simple opencv program for cross-compilation, but always compilation fails (here the Installation Reference Library: http://wenku.baidu.com/link? Url = response)

Port opencv2.4.2 to compile the arm Program

Arm-Linux-G ++-O opencv_test opencv_test.cpp-I/usr/local/ARM/opencv/include/opencv-L/usr/local/ARM/opencv/lib-lopencv_core- lopencv_highgui

The following error occurs:

/Usr/local/ARM/4.3.2/bin /.. /lib/GCC/ARM-None-Linux-gnueabi/4.3.2 /.. /.. /.. /.. /ARM-None-Linux-gnueabi/bin/ld: Warning :.. /.. /lib/libcxcore. so, needed by/usr/local/ARM/opencv-2.1/lib/libcv. so, not found (try using-rpath or-rpath-link)
/Usr/local/ARM/4.3.2/bin /.. /lib/GCC/ARM-None-Linux-gnueabi/4.3.2 /.. /.. /.. /.. /ARM-None-Linux-gnueabi/bin/ld: Warning :.. /.. /lib/libcv. so, needed by/usr/local/ARM/opencv-2.1/lib/libcvaux. so, not found (try using-rpath or-rpath-link)
/Usr/local/ARM/4.3.2/bin /.. /lib/GCC/ARM-None-Linux-gnueabi/4.3.2 /.. /.. /.. /.. /ARM-None-Linux-gnueabi/bin/ld: Warning :.. /.. /lib/libhighgui. so, needed by/usr/local/ARM/opencv-2.1/lib/libcvaux. so, not found (try using-rpath or-rpath-link)
/Usr/local/ARM/4.3.2/bin /.. /lib/GCC/ARM-None-Linux-gnueabi/4.3.2 /.. /.. /.. /.. /ARM-None-Linux-gnueabi/bin/ld: Warning :.. /.. /lib/libml. so, needed by/usr/local/ARM/opencv-2.1/lib/libcvaux. so, not found (try using-rpath or-rpath-link)

I read the author's blog: Workshop. He also tried his solution and referred to blog: http://blog.sina.com.cn/s/blog_602f87700100nyda.html.

In the cross-compilation process, lflags replace-L with-WL and-rpath-link-WL. The problem is lost, but it is impossible to find it. so library file, I am speechless, this problem has been solved before back, copy the library and set the path, the old problem again, it was painful to be beaten back ten years ago. Arm-None-Linux-gnueabi lacks such a library. You can copy the library and find it is useless. This library Nima is a copy of the previous articles of several bloggers, I don't know if I have tried it. You can't just give up opencv2.4.2.

 

The following describes how to install opencv2.0 and some problems encountered.

Here, I am referring to the opencv Chinese website (this website is very reliable)

Http://wiki.opencv.org.cn/index.php/%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91

Opencv2.0:

1. decompress the file:

# Tar zxvf opencv-2.0.0.tar.gz

# Cd opencv-2.0.0

 

2. Check Software Configuration

#. /Configure -- Host = arm-Linux -- without-GTK -- without-carbon -- without-QuickTime -- without-1394libs -- without-FFMPEG -- without-Python -- without-swig -- enable-static -- enable -Shared -- disable-apps cxx = arm-Linux-G ++ cppflags =-I/opt/friendlyarm/toolschain/4.5.1/ARM-None-Linux-gnueabi/include ldflags =- l/opt/friendlyarm/toolschain/4.5.1/ARM-None-Linux-gnueabi/lib -- with-v4l2 -- prefix =/opt/x86/opencv -- libdir =/opt/x86/opencv/ lib-export dedir =/opt/x86/opencv/include

If you are prompted that the required software is not installed, install it and run the./configure command until the prompt "now run make..." is displayed.

Note: opencv2.2 has saved the configure file, can be installed through cmake, refer to the http://www.samontab.com/web/2010/04/installing-opencv-2-1-in-ubuntu/

 

3. Compile opencv

# Make

 

4. Install opencv

# Make install

 

5. Update the dynamic link library

Use the root user to perform the following operations

Add the path/usr/local/lib to the file/etc/lD. So. conf and run the command

# Ldconfig

 

6. Test the installation package (under sample/C)

G ++ 'pkg-config opencv -- Libs -- cflags opencv 'Drawing. C-o drawing

The path cannot be found. The specific error is as follows:

Package opencv was not found in the PKG-config search path.

Perhaps you shoshould Add the directory ining 'opencv. pc'

To the pkg_config_path environment variable

No package 'opencv 'Found

Package opencv was not found in the PKG-config search path.

Perhaps you shoshould Add the directory ining 'opencv. pc'

To the pkg_config_path environment variable

No package 'opencv 'Found

There are many solutions on the Internet, which come to the end as the path setting problem.

Here, I add the following path to the/root/. bashrc file to compile it.

Export pkg_config_path =/opt/x86/opencv/lib/pkgconfig: $ pkg_config_path

Compile the test case here and then run the following command:

#./Drawing

You can also test other functions such:

CD samples/C
Chmod + x build_all.sh
./Build_all.sh
./Facedetect -- cascade = "/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" -- scale = 1.5 lena.jpg

 

The above is the configuration and installation of X86 opencv

The following describes how to configure and install arm opencv.

Export pkg_config_path =/opt/ARM/opencv/lib/pkgconfig: $ pkg_config_path

Step 1: Configure configure

. /Configure -- Host = arm-Linux -- without-GTK -- without-carbon -- without-QuickTime -- without-1394libs -- without-FFMPEG -- without-Python -- without-swig -- enable-static -- enable -Shared -- disable-apps cxx = arm-Linux-G ++ cppflags =-I/opt/friendlyarm/toolschain/4.5.1/ARM-None-Linux-gnueabi/include ldflags =- l/opt/friendlyarm/toolschain/4.5.1/ARM-None-Linux-gnueabi/lib -- with-v4l2 -- prefix =/opt/ARM/opencv -- libdir =/opt/ARM/opencv/ lib-includedir =/opt/ARM/opencv/include

Step 2: Compile

Make

The following error occurs:

../3 rdparty/. libs/lib_clapack.a (dlasyf. O): cocould not read symbols: file in wrong format

Solution: Delete the 3 rdparty/. libs/lib_clapack.a file, make clean, and restart make compilation.

Step 3: Install

Make install

After the installation is successful, many files are generated in the/opt/ARM/opencv/lib and/opt/ARM/opencv/include directories.

Step 4: Test

Arm-Linux-GCC test. c-o Test-arm-I/opt/ARM/opencv/include/opencv-L/opt/ARM/opencv/lib-lml-lcvaux-lhighgui-LCV-lcxcore-lpthread -LRT

An error occurred while porting opencv2.0 to arm to run./show-arm lena.jpg:

Opencv error: unspecified error (the function is not implemented. Rebuild the library with windows, GTK + 2.x or carbon support. If you are on Ubuntu or Debian,

Install libgtk2.0-Dev and PKG-config, then re-run cmake or configure script) in

Cvnamedwindow, file highgui/window. cpp, line 100

Here, we can call the opencv library to perform algorithm operations, but there is no GUI platform for use. Next I will try to use Qt as the platform to obtain the video.

The author of this article: http://blog.csdn.net/noodies/article/details/5798434

When I answered questions for a netizen, I used v412 for video capturing, then used opencv for image processing, and finally operated framebuffer to display the processing result (I have not tried it here, I think QT should be more convenient)

This article says that GTK should be installed before opencv: http://lovelittlebean.blog.163.com/blog/static/11658218620125911268437/

I used fedora14, but I have not installed GTK, but run

# PKG-config-modversion GTK +-2.0

You can find my GTK version.

# PKG-config -- cflags -- libs GTK ++-2.0

You can view GTK compilation and link information.

Here refer to the "Source code install GTK" blog: http:// OS .it168.com/a2008/0828/984/000000984646.shtml

I haven't figured out what GTK is for after so many times. I have mentioned it in the following blog.

Http://blog.csdn.net/yanzi1225627/article/details/7524698

The right words appear, such as GTK, but I still don't know what it means. Then I wrote the configuration of QT. So I will configure QT first. Here, the QT configuration I refer to is:

Http://blog.chinaunix.net/uid-24641004-id-3459705.html

Later, I learned that GTK is actually a GUI.

Run opencv to open the camera. I don't know whether the Q-debug version of this blogger is different or missing. When running, I am prompted that the qdebug application is incorrect. Locate code F1 and go to the function documentation, the header file include <qtdebug> is missing, and the header file is OK.

Also prompt. pro cannot find lib **. so library, go in and check and find that there is a blank line When configuring, that is, the Lib library of libs + = must add "\" to add multiple lines, I have a blank line.

"Error!" appears during running !"

In the code, this is the error message of qdebug. I directly changed it to "error: can not open Camero !". This makes it easy to understand.

The solution is to insert the camera.

During compilation and running, the Avatar appears


Next we will see how to port it to arm.

Modify. pro to the header file and library file of the arm version and compile your own small program. This was compiled and generated by the previous compilation, which I separated by x86 and arm.

Recompile and copy it to the Development Board for running.

A headache occurs, and a segmentation fault segment error occurs. Troubleshooting blog

Http://www.cnblogs.com/s_agapo/archive/2011/11/24/2262346.html

I have mentioned one point, but it is not suitable for my program. He just replaces the load function of QT with The LoadImage of opencv first.

Finally, in the blog:

Http://blog.csdn.net/yanzi1225627/article/details/8215695

In the comments mentioned, a nvwa told him to set-1 in capture = cvcreatecameracapture (-1) to 202. After trying it, she succeeded, so far, I still don't know what 202 means.

The running result is as follows:

 

So far, it has been found that the entire platform environment has been fully activated.

Next I tried to use his algorithm to perform face detection.

Some problems have also been encountered, such:

Compile the QT program of the x86 version and run it normally. However, when compiling the QT program of the arm version, the following error occurs: Main. O: relocations in generic elf (EM: 3)

Solution: Go to the project directory and execute make clean. After cleaning, it will be OK after compilation.

The cvwaitkey (0) error also occurs. I guess this function is indeed a problem on the ARM platform. I will comment it out, because it is just a waiting function and finally runs successfully, however, the video becomes a bit card, not as smooth as running in x86. Is it because I commented out the cvwaitkey and want to continue optimization.

Paste the result image:

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.