Cross-compiling OpenCV for Raspberry Pi with Python Support.

asked 2013-01-26 11:23:44 -0500

onedude gravatar image

updated 2013-01-29 15:57:30 -0500

Hi Guys,

I am kind of a noob that knows how to follow instructions and add my own, but I am a bit stuck. I dont know if this forum or the CMAKE forum would be the place to go but I guess I will start here.

I am trying to cross-compile OpenCV for a raspberry Pi with Python support. There are instructions on how to compile directly on the raspberry pi, but it takes 4+ hours to complete. (these instructions are here at (INSTRUCTION_SET_1) ) It seems to work for the version they call out for but I was trying to get the latest version of opencv and it failed and I got sick of waiting 4 hours every time I need to re-build the binaries. Hence I decided to look into cross compiling. I was successful at cross compiling a simple "Hello World" program using these other instructions (INSTRUCTION_SET_2). So I decided to jump in and try to compile OpenCV by following the first set of instruction but changing the CMAKE command to this:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON -D CMAKE_TOOLCHAIN_FILE=/home/shocker/workspace/rasp-pi/toolchain/bin/Toolchain-RaspberryPi.cmake ..

Before running this I installed the libraries and other required programs on the raspberry pi and tried to "rsync" it to my PC for the cross compiling. Now I hit a brick wall because I cant seem to figure out how to tell CMAKE to use those libraries (I am doing it by setting the CMAKE_FIND_ROOT_PATH variable in the toolchain point to the root of where the "rsync" was placed). If I am doing this correctly, it is still not working because when I run "make" it fails either when attempting to compile a dc1394 library or somewhere else. I figured I could turn off 1934 compiling since rasp-pi doesnt have one, but then something else failed. Exact failure was:

/workspace/rasp-pi/OpenCV-2.4.3/modules/highgui/src/cap_libv4l.cpp:250:21: fatal error: libv4l1.h: No such file or directory compilation terminated. make[2]: * [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_libv4l.cpp.o] Error 1 make[1]: [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2 make: ** [all] Error 2

As a summary of what I did:

  1. Follow INSTRUCTION_SET_1 on the raspberry pi to install any additional/required libraries on the pi. Don't compile OpenCV.
  2. Follow INSTRUCTION_SET_2 on PC to get cross compiler running.
  3. Follow rest of instructions on getting OpenCV on PC working but change CMAKE command to the one mentioned above.

If that would have worked. I would have copied the whole recently built folder to the pi and then execute "make install"

Sorry for the looooong explanation, but I figured if what I am doing is correct, then someone else can complete what I am missing or failing at.

Thank you in advance you great guru community.

edit retag flag offensive close merge delete


Anyone.... Anyone... Buuueller... I see traffic to this post but no takes on what to do?

onedude gravatar imageonedude ( 2013-02-06 16:19:18 -0500 )edit

are you able to compile OpenCV for the native architecture (assuming x86). What operating system are you using?

highway900 gravatar imagehighway900 ( 2013-05-12 21:59:02 -0500 )edit