Comments (13)
for python3
sudo apt-get install python3-opencv
for python2
sudo apt-get install python2-opencv
Easy install
http://jollejolles.com/easy-install-opencv-for-python-on-mac-ubuntu-and-raspberry-pi/
from opencv-3.2.0-compiling-on-raspberry-pi.
@DGaffney Try running sudo make
without specifying the number of cores. This should work, but be aware that it wil take longer time to complete the process. You can leave it over night, grab a cup of coffee, or watch one of your favorite movies :D
from opencv-3.2.0-compiling-on-raspberry-pi.
Alright - I'm trying to install ffmpeg directly one more time and then failing that, I'll not specify cores and go on vacation for a week and maybe it'll be compiled by then :) - if you're ok with it I'd love to keep this open until I confirm that fixes it?
from opencv-3.2.0-compiling-on-raspberry-pi.
@DGaffney Sure, and thanks a lot for you kind words :)
from opencv-3.2.0-compiling-on-raspberry-pi.
Thanks for this checklist!
from opencv-3.2.0-compiling-on-raspberry-pi.
@DGaffney You are more than welcome
from opencv-3.2.0-compiling-on-raspberry-pi.
@DGaffney I googled about your problem, and yes it "sometimes" causes issues for some people. So now I decided to update my checklist to OpenCV 3.2.0. The good part is, you can use OpenCV on your RPI without have to specify -D WITH_FFMPEG=ON
. The CMakeList.txt provided by OpenCV turns it on by default. therefore, you can manipulate avi videos on RPi. The following line is included in the CMakeList.txt:`
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )`
I tried it myself and it works fine for me right now.
I know this solution might be annoying for some people, but delete all opencv directories you already downloaded, and start from step 11. Also now you can freely use sudo make -j3
if you want.
from opencv-3.2.0-compiling-on-raspberry-pi.
@Tes3awy alright, this sounds good - I'll give it a try! For what it's worth, the make still failed with same situation:
[ 10%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_libv4l.cpp.o
[ 11%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o
In file included from /home/pi/opencv-3.1.0/modules/videoio/src/cap_ffmpeg.cpp:45:0:
/home/pi/opencv-3.1.0/modules/videoio/src/cap_ffmpeg_impl.hpp: In member function ‘bool OutputMediaStream_FFMPEG::open(const char*, int, int, double)’:
/home/pi/opencv-3.1.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2207:41: warning: ignoring return value of ‘int avformat_write_header(AVFormatContext*, AVDictionary**)’, declared with attribute warn_unused_result [-Wunused-result]
avformat_write_header(oc_, NULL);
^
[ 11%] Linking CXX shared library ../../lib/libopencv_videoio.so
/usr/bin/ld: /usr/local/lib/libx264.a(common.o): relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libx264.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:227: recipe for target 'lib/libopencv_videoio.so.3.1.0' failed
make[2]: *** [lib/libopencv_videoio.so.3.1.0] Error 1
CMakeFiles/Makefile2:5832: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
from opencv-3.2.0-compiling-on-raspberry-pi.
The error still happens, but it didn't crash this time? I'm still at 33% so I'll report in tomorrow once it's finished running, but here's that output just in case you wanted to see it:
[ 32%] Building CXX object modules/shape/CMakeFiles/opencv_shape.dir/src/tps_trans.cpp.o
[ 32%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o
[ 32%] Linking CXX shared library ../../lib/libopencv_shape.so
[ 32%] Linking CXX shared library ../../lib/libopencv_videoio.so
[ 32%] Built target opencv_shape
[ 32%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/blob.cpp.o
/usr/bin/ld: /usr/local/lib/libx264.a(common.o): relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libx264.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:228: recipe for target 'lib/libopencv_videoio.so.3.2.0' failed
make[2]: *** [lib/libopencv_videoio.so.3.2.0] Error 1
CMakeFiles/Makefile2:6433: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
from opencv-3.2.0-compiling-on-raspberry-pi.
Spoke too soon! It did fail shortly thereafter:
[ 34%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/torch/torch_importer.cpp.o
[ 34%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/opencl_kernels_dnn.cpp.o
[ 34%] Linking CXX shared library ../../lib/libopencv_dnn.so
[ 34%] Built target opencv_dnn
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
from opencv-3.2.0-compiling-on-raspberry-pi.
Latest update - I decided to reset the RPi to a clean install of the OS (Jessie with Pixel, 2017-03-02 release), and only do a few things after install before leading into your checklist (install tmux, allow ssh, and nothing else). Before running cmake in Step 11, I followed directions from https://www.jeffreythompson.org/blog/2014/11/13/installing-ffmpeg-for-raspberry-pi/ to install ffmpeg. Nearly all the way through, I hit an error while using sudo make -j3 in Step 12:
BUILD SUCCESSFUL
Total time: 1 minute 3 seconds
Scanning dependencies of target opencv_java
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/generator/src/cpp/Mat.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/generator/src/cpp/converters.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/generator/src/cpp/jni_part.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/generator/src/cpp/utils.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/__/core/misc/java/src/cpp/core_manual.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/__/features2d/misc/java/src/cpp/features2d_converters.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/core.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/imgproc.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/ml.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/photo.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/video.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/imgcodecs.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/videoio.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/objdetect.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/bioinspired.cpp.o
[ 82%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/features2d.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions.
modules/python2/CMakeFiles/opencv_python2.dir/build.make:320: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o' failed
make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 4
CMakeFiles/Makefile2:20806: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/all' failed
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 83%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/calib3d.cpp.o
[ 83%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/xfeatures2d.cpp.o
[ 83%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/aruco.cpp.o
[ 83%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/phase_unwrapping.cpp.o
[ 83%] Building CXX object modules/java/CMakeFiles/opencv_java.dir/gen/structured_light.cpp.o
[ 83%] Linking CXX shared library ../../lib/libopencv_java320.so
[ 83%] Built target opencv_java
[ 83%] Linking CXX shared module ../../lib/python3/cv2.cpython-34m.so
[ 83%] Built target opencv_python3
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
I'm running sudo make without multiple cores now to see if that can bypass the issue, the "Killed" printout makes me feel like the issue is due to resource constraints rather than anything to do with the current build. I'll reply after this finishes up either tonight if I'm feeling like waiting around (2:30am local here) or when I wake up (afternoon in your TZ if you're in Cairo).
from opencv-3.2.0-compiling-on-raspberry-pi.
Another update (because of course I stayed up to see if it would compile) - we are now compiled! The only note that I would add is that your checklist doesn't cover installs of ffmpeg. Before cmake in step 11, people need to install ffmpeg from source (or maybe from apt-get, though I didn't try that so I can't directly vouch for that approach). Either way, to make this checklist compliant with the latest RPi build, before cmake, you need to do the following:
cd /usr/src
git clone https://github.com/FFmpeg/FFmpeg.git
cd ffmpeg
sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
make
sudo make install
Again, that's sourced from https://www.jeffreythompson.org/blog/2014/11/13/installing-ffmpeg-for-raspberry-pi/
I'm now able to confirm that cv2 is reporting version 3.2.0 in python, so the issues I had are now dealt with, but I think that you should add in the checklist the step provided above, since you aren't explicitly stating that users should install ffmpeg, and as a result, this use case would still likely fail - up to you, however, so I'll leave it with this comment, up to you to close! Thanks for everything and all the feedback - greatly appreciated.
from opencv-3.2.0-compiling-on-raspberry-pi.
I started with raspberry pi 2 model B. it's worked, but when I install it for raspberry pi 3 model B, it shows the same error message and then I follow this site, it's worked for me
http://pklab.net/?id=392&lang=EN
from opencv-3.2.0-compiling-on-raspberry-pi.
Related Issues (8)
- Step 13 - compile HOT 3
- sudo apt-get install libgtk2.0-dev [SOLVED] HOT 2
- Created menu assisted bash script for opencv3 install HOT 3
- Installing OpenCV 3.3.0 with opencv-contrib on Raspberry Pi 3, but got error during make HOT 4
- Menu Driven opencv3 Install on Raspberry Pi HOT 1
- Illegal instruction HOT 1
- Add SWAP size on Raspberry Pi B+ HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencv-3.2.0-compiling-on-raspberry-pi.