mattmiller
Posts: 2096
Joined: Thu Feb 05, 2015 11:25 pm

Re: Stretch OpenCV 3.3.0....

Sat Aug 19, 2017 3:21 pm

What stopped at 82%?
The download or the compilation?
I've found that I needed a lot of free space to compile it in the past

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7124
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Stretch OpenCV 3.3.0....

Sat Aug 19, 2017 7:10 pm

Drop the number of jobs. Linking takes lots of memory, so you're likely to start swapping and performance will drop through the floor.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

pageauc
Posts: 224
Joined: Fri Jan 04, 2013 10:52 pm

Re: Stretch OpenCV 3.3.0....

Sat Aug 19, 2017 7:33 pm

I have a whiptail menu driven bash script that does rpi-update, upgrade, installs dependencies, downloads and unzips source, does a cmake, compile, and make install of opencv 3.x. Did not have much luck with a j4 compile due to memory, so this script uses j2 on a quad core, otherwise single core compile. You are prompted if RPI is quad core since I have not automated detection yet. script allows review at critical steps and redoing if required. Eg cmake errors.

You may want to give it a try. Make sure you have lots of free disk space due to the size of the zip, unzip and working space. Once done space can be recovered by deleting zip and working folder.

https://github.com/pageauc/opencv3-setup

Let me know if this helps
Claude ...
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp

MarkDH102
Posts: 339
Joined: Fri Feb 13, 2015 3:18 pm

Re: Stretch OpenCV 3.3.0....

Mon Aug 21, 2017 8:31 am

I'm trying to compile 3.0.0 on a 2B and use -j3.
I've got an error with a #include_next <math.h> in cmath at around 23%. I've bodge-fixed it for now and hold my breath...
Nope... now it's cstdlib same error. Another bodge fix.

I might go back to Jessie. I hate faffing like this...

Yep, I'm going back to Jessie. Just got a load more compilation errors about 41% through. Seems to be incompatibilities with ffmpeg. Shame.

User avatar
bonzadog
Posts: 236
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Stretch OpenCV 3.3.0....

Tue Aug 22, 2017 2:34 pm

supra wrote:
Sat Aug 19, 2017 4:47 pm
mattmiller wrote:
Sat Aug 19, 2017 3:21 pm
What stopped at 82%?
The download or the compilation?
I've found that I needed a lot of free space to compile it in the past
It is not download. After build ...sudo make -j4...then after build, building, etc..then stop @ 82%.
I have 32gb sdhc card.
I'm still at 41% right now.
I let u know by today.
Hi,
Raspberry Pi 3
!6GB SD
Debian Stretch

I have exactly the same problem trying to install Opencv 3.3.0 with Stretch.
I had previously removed scratch, scratch2 and Wolfram-engine to ensure SD space.

I tried 3.2.0 but that stopped and left the Red and Yellow lights on which look suspiciously like a SD Space problem.

Any help most welcome!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7124
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Stretch OpenCV 3.3.0....

Tue Aug 22, 2017 5:04 pm

Raspbian Stretch (probably Lite) install on a Pi2, 16GB card.
Following the basic build instructions from http://docs.opencv.org/2.4/doc/tutorial ... stall.html

Code: Select all

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
git clone https://github.com/opencv/opencv.git
cd opencv
mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..
make -j2
sudo make install
The make line takes a fair while, but completes fine (a moderate number of warnings go past).

What steps are you doing to build OpenCV?
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
bonzadog
Posts: 236
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Stretch OpenCV 3.3.0....

Tue Aug 22, 2017 6:17 pm

6by9 wrote:
Tue Aug 22, 2017 5:04 pm
Raspbian Stretch (probably Lite) install on a Pi2, 16GB card.
Following the basic build instructions from http://docs.opencv.org/2.4/doc/tutorial ... stall.html

Code: Select all

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
git clone https://github.com/opencv/opencv.git
cd opencv
mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..
make -j2
sudo make install
The make line takes a fair while, but completes fine (a moderate number of warnings go past).

What steps are you doing to build OpenCV?
Hi;

All the steps here :
http://www.pyimagesearch.com/2015/10/26 ... an-jessie/

MarkDH102
Posts: 339
Joined: Fri Feb 13, 2015 3:18 pm

Re: Stretch OpenCV 3.3.0....

Wed Aug 23, 2017 6:14 am

Hi;

All the steps here :
http://www.pyimagesearch.com/2015/10/26 ... an-jessie/
These steps (which worked for me under Jessie) are not working under stretch (a fresh installation).
I tried building 3.0.0 and got ffmpeg library errors. Which I don't think is the fault of Stretch.
I have since tried building 3.3.0 but can't even get past the initial checks that "make" does. I'm seeing some really weird errors.
I have now reverted to my Jessie backup which is working fine for my needs.

User avatar
bonzadog
Posts: 236
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Stretch OpenCV 3.3.0....

Wed Aug 23, 2017 2:43 pm

6by9 wrote:
Tue Aug 22, 2017 5:04 pm
Raspbian Stretch (probably Lite) install on a Pi2, 16GB card.
Following the basic build instructions from http://docs.opencv.org/2.4/doc/tutorial ... stall.html

Code: Select all

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
git clone https://github.com/opencv/opencv.git
cd opencv
mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..
make -j2
sudo make install
The make line takes a fair while, but completes fine (a moderate number of warnings go past).

What steps are you doing to build OpenCV?
22.8.2017
Hello,
I followed those instructions - adding a couple more install - and got this:

- Installing: /usr/local/bin/opencv_traincascade
-- Set runtime path of "/usr/local/bin/opencv_traincascade" to "/usr/local/lib"
-- Installing: /usr/local/bin/opencv_createsamples
-- Set runtime path of "/usr/local/bin/opencv_createsamples" to "/usr/local/lib"
-- Installing: /usr/local/bin/opencv_annotation
-- Set runtime path of "/usr/local/bin/opencv_annotation" to "/usr/local/lib"
-- Installing: /usr/local/bin/opencv_visualisation
-- Set runtime path of "/usr/local/bin/opencv_visualisation" to "/usr/local/lib"
-- Installing: /usr/local/bin/opencv_interactive-calibration
-- Set runtime path of "/usr/local/bin/opencv_interactive-calibration" to "/usr/local/lib"
-- Installing: /usr/local/bin/opencv_version
-- Set runtime path of "/usr/local/bin/opencv_version" to "/usr/local/lib"
rpi-install-OPENCV3-new.sh: line 76: unexpected EOF while looking for matching `"'
rpi-install-OPENCV3-new.sh: line 78: syntax error: unexpected end of file

This look like a source error.

DB

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7124
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Stretch OpenCV 3.3.0....

Wed Aug 23, 2017 3:07 pm

bonzadog wrote:
Wed Aug 23, 2017 2:43 pm
6by9 wrote:
Tue Aug 22, 2017 5:04 pm
What steps are you doing to build OpenCV?
22.8.2017
Hello,
I followed those instructions - adding a couple more install - and got this:

- Installing: /usr/local/bin/opencv_traincascade
-- Set runtime path of "/usr/local/bin/opencv_traincascade" to "/usr/local/lib"
-- Installing: /usr/local/bin/opencv_createsamples
-- Set runtime path of "/usr/local/bin/opencv_createsamples" to "/usr/local/lib"
-- Installing: /usr/local/bin/opencv_annotation
-- Set runtime path of "/usr/local/bin/opencv_annotation" to "/usr/local/lib"
-- Installing: /usr/local/bin/opencv_visualisation
-- Set runtime path of "/usr/local/bin/opencv_visualisation" to "/usr/local/lib"
-- Installing: /usr/local/bin/opencv_interactive-calibration
-- Set runtime path of "/usr/local/bin/opencv_interactive-calibration" to "/usr/local/lib"
-- Installing: /usr/local/bin/opencv_version
-- Set runtime path of "/usr/local/bin/opencv_version" to "/usr/local/lib"
rpi-install-OPENCV3-new.sh: line 76: unexpected EOF while looking for matching `"'
rpi-install-OPENCV3-new.sh: line 78: syntax error: unexpected end of file

This look like a source error.
For reference, that is obviously cloning top-of-tree opencv rather than the 3.3.0 release. I was on commit

Code: Select all

commit cc5b99c2367db977518957942368ec554be7c964
Merge: af09cb2 58dc58a
Author: Alexander Alekhin <[email protected]>
Date:   Tue Aug 22 14:10:18 2017 +0000

    Merge pull request #9436 from alalek:cmake_drop_install_name_dir
Looking right now, there are 10 new commits after that.
"git checkout cc5b99c" will get you to the same commit I was on.

Strangely I don't have a file rpi-install-OPENCV3-new.sh in my OpenCV build. Could you do a find to locate it in your filesystem please?

I made a 3.3.0 build this morning on the same system I had made the Github ToT build on yesterday but with the few extra packages listed in your tutorial, and that was fine. I'm now doing it with a new Raspbian Stretch image - 53% so far.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7124
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Stretch OpenCV 3.3.0....

Wed Aug 23, 2017 4:13 pm

6by9 wrote:
Wed Aug 23, 2017 3:07 pm
I made a 3.3.0 build this morning on the same system I had made the Github ToT build on yesterday but with the few extra packages listed in your tutorial, and that was fine. I'm now doing it with a new Raspbian Stretch image - 53% so far.
Now up to 90% with make -j2. Yes it appears stalled at

Code: Select all

[ 90%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o
however top shows that kswapd0 is heavily active.
...
and then it does freeze.

One thing from my earlier build- I hadn't started X, just booted to the command line. I was also building over SSH, although that shouldn't make any real difference.
It looks like the Python bindings are HUGE files, and compiling them needs every ounce of system going. (cc1plus has been going solidly for over 6 minutes on opencv_python3.dir/__/src2/cv2.ccp.o, and is on over 512MB of memory)
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7124
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Stretch OpenCV 3.3.0....

Thu Aug 24, 2017 1:10 pm

supra wrote:
Wed Aug 23, 2017 6:03 pm
Yes. Now U understand. :D :D :D
A bit too much https://www.youtube.com/watch?v=qMa0CxgCqiM there.
I understand I get annoyed at piecemeal bug reports which omit major (or indeed in this case almost all) details. :evil: :evil: :evil:
supra wrote:
Wed Aug 23, 2017 6:03 pm
I almost got 100%. It will stop at Houghlinescircle_demo. After that, it will never go further beyond 100%. It is stil stop at Houghlinescircle_demo all times.
When it freezing, look at digital clock on right taskbar, it will stop. Look at cpu ...100%.
Nope, built fine to 100% on make (-j1)
top is a far more useful tool than looking at the clock.
supra wrote:
Wed Aug 23, 2017 6:03 pm
Go to preference...add/remove software...select opencv.....U will see that python comes with OpenCV 2.4.9 instead of OpenCV 3.

There is new library...python3-opencv.
There's a new library where? The Debian stable repos? If not then that comment is totally irrelevant.
I see that the experimental repos have 3.2.0
According to Github, 3.3.0 was released on 4th August 2017, so 20 days ago. Expect to wait a fair while for that to make it into Debian.
Debian ALWAYS goes for stablility rather than cutting edge.
supra wrote:
Wed Aug 23, 2017 6:03 pm
@6by9, reboot it every time u getting freezing until it reached @100% then stop @ houghlinecircle_demo.
Try -j2 or j3 to get 100%. And see what happen.
That all.
Completed fine on make (-j1).

As I had already stated, and is stated in your tutorial, when in doubt you should drop the number of jobs.
You have 1GB of RAM (assuming a Pi2 or Pi3), and a default of 100MB of swap. Exceed that and bad things will happen.
Feel free to configure a bigger swap drive which may help out, but it'll be dog slow on an SD card. Also set gpu_mem lower if you want to free up every last byte of RAM (I'm running on 96M).

At 90% when compiling modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o and modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o, each of the two cc1plus processes are using 518MB of RAM and are stalling due to swapping out. 27MB of RAM left, and swapping furiously. Neither is likely to complete without the other getting killed due to OOM.
Stopping and running with 1 job shows that it peaks at around 530MB of RAM whilst building opencv_python2.dir/__/src2/cv2.cpp.o, and about the same for the python3 library. Once the two python libraries are built, everything else will build on -j2.

TL;DR. I'm not investigating any more. There's no build issue here other than trying to fit a quart into a pint pot. Numerous libraries have been updated in Stretch and their requirements have increased. The tutorial being followed isn't one provided by RPF/RPT, so not much that can be done to get it amended.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
bonzadog
Posts: 236
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: [SOLVED]Re: Stretch OpenCV 3.3.0....

Fri Aug 25, 2017 1:06 pm

supra wrote:
Thu Aug 24, 2017 7:29 pm
@6by9(MOderator)
The problem has been solved by using

Code: Select all

 sudo make  -j1
. Because cpu is dropping @ 25%.
Never used between -j2 to -j4. That will caused freezing.
Thank you, Moderator(6by9) :) :) :) :)
I am very happy :D :D :D :D :D :D
Hi,

That -j1 worked for me j2 caused problems.

Bonzadog

predator7
Posts: 1
Joined: Wed Aug 30, 2017 1:04 pm

Re: [SOLVED]Stretch OpenCV 3.3.0....

Wed Aug 30, 2017 1:45 pm

Hi, is it also possible to build a .deb package of opencv 3.3.0 for raspbian stretch on raspberry pi 3 with python 3.5?

santiago g
Posts: 1
Joined: Tue Oct 31, 2017 12:51 am

Re: [SOLVED]Stretch OpenCV 3.3.0....

Tue Oct 31, 2017 1:03 am

Please someone help me. When I execute the MAKE command. An error appears.

  / usr / include / c ++ / 6 / cstdlib: 75: 25: fatal error: stdlib.h: The file or directory does not exist
  #include_next <stdlib.h>

the file does not exist, try with -j1 -j2 -j3 -j4 the more advanced is the -j4 up to 23 percent help me please urgently

alnaseh
Posts: 60
Joined: Thu Jun 23, 2016 5:12 am

Re: [SOLVED]Stretch OpenCV 3.3.0....

Sun Nov 12, 2017 3:28 am

increasing the swap from 100MB to 1024MB solved this issue. you can still compile it with -j4

you need to decrease the swap again once it is done

Code: Select all

$ sudo vi /etc/dphys-swapfile
change CONF_SWAPSIZE to 1024

$ sudo /etc/init.d/dphys-swapfile stop
$ sudo /etc/init.d/dphys-swapfile start


Tia
Posts: 18
Joined: Thu Nov 09, 2017 4:11 am

Re: [SOLVED]Stretch OpenCV 3.3.0....

Sat Mar 24, 2018 8:43 pm

Thank you everyone for the replies here which helped me solve this issue I had using OpenCV on Stretch too.

Code: Select all

make -j1
helped me too :)

Return to “General discussion”