Nolaan
Posts: 57
Joined: Thu Jul 10, 2014 6:35 pm
Contact: Website

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Tue Nov 18, 2014 9:02 am

arduinopi+ wrote:hi,
i unzipped and used dpkg on the deb file, but do u have any idea how i can include these files in my c program
thanks again
I guess you first have to write a program using OpenCV (maybe refer to tutorials). You may have to understand that librairies in a general sense are functions that helps to do a specific task while implementing an algorithm. Instead of you re-inventing the wheel, you just use the functions provided by this library by first including the correct header file ( eg, #include <opencv/highgui.h> ) and then provide the compiler the lib to link ie

Code: Select all

-lopencv_highgui
http://www.jetsonblog.com
twitter : @nolaan_boy

akshat_onix
Posts: 1
Joined: Sat Nov 22, 2014 8:13 am

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Sat Nov 22, 2014 8:20 am

Hey
I am unable to copy the extracted file libopencv_24-master to /usr/local/lib
I tried the command
sudo cp _P libopencv_24-master /usr/local/lib
but it says
effective uid is not 0, is sudo installed steuid root :evil:
Can you suggest what is calling the problem?
Thanks :D

ryuga9
Posts: 1
Joined: Sun Nov 23, 2014 12:06 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Sun Nov 23, 2014 12:10 pm

Hello, I am trying to compile this sample code from Opencv ducument:

Code: Select all

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
    if( argc != 2)
    {
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;
    }

    Mat image;
    image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

    if(! image.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Display window", image );                   // Show our image inside it.

    waitKey(0);                                          // Wait for a keystroke in the window
    return 0;
}
However, I cant compile it using g++

Code: Select all

 g++ -Wall -o test test.cpp -lopencv_core -lopencv_highgui
Error:

Code: Select all

fatal error: opencv2/core/core.hpp: No such file or directory
compilation terminated.
Am I missing some important steps?Thank you.

Nolaan
Posts: 57
Joined: Thu Jul 10, 2014 6:35 pm
Contact: Website

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Mon Nov 24, 2014 8:58 am

ryuga9 wrote:Hello, I am trying to compile this sample code from Opencv ducument:

Code: Select all

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
    if( argc != 2)
    {
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;
    }

    Mat image;
    image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

    if(! image.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Display window", image );                   // Show our image inside it.

    waitKey(0);                                          // Wait for a keystroke in the window
    return 0;
}
However, I cant compile it using g++

Code: Select all

 g++ -Wall -o test test.cpp -lopencv_core -lopencv_highgui
Error:

Code: Select all

fatal error: opencv2/core/core.hpp: No such file or directory
compilation terminated.
Am I missing some important steps?Thank you.
I would advise you just to read if you want to become a decent programmer. g++ says you =>

Code: Select all

fatal error: opencv2/core/core.hpp: No such file or directory
compilation terminated.
It means you have to install the -dev package containing the header files, such as core.hpp ...
http://www.jetsonblog.com
twitter : @nolaan_boy

AtoM-84
Posts: 1
Joined: Fri Nov 28, 2014 2:55 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Fri Nov 28, 2014 3:22 pm

Nolaan wrote:
DougieLawson wrote:Hi Nolaan,
Is it possible to get SURF added to your OpenCV2 stuff?
Hi DougieLawson,
I didn't check the compilation option (just built the default without CUDA), but I'm seeing a lot of *SURF* symbols in the libs via objdump. I'll try to recompile it soon.

Hi Nolaan,

Thank you for your help to install quickly and correctly OpenCV 2.4.10. Did you try to add SURF in the compilation option. I am trying to use the features2d library and several functions are not referenced. I would be very interested if you could produce a new deb package including SURF detection and other related functions.

Nota: For those in this post who have issues with header files (.hpp), I did all the same as explained by Nolaan in this post and in the readme file at the repository of the package. But with that you "only" have source files. You also need the header files which can be installed by doing the first step of the compilation as explained on OpenCV website. You stop after producing the build (do not start compiling!) and then you create a opencv2 folder that gather all the "include" folder of each module (one folder with the .hpp files in each, named with module name) and opencv.hpp and opencv_modules.hpp in the root (opencv2 folder). Then place it in the usr/include directory. This way your cpp compiler should not be lost facing the #include.

trundes
Posts: 17
Joined: Wed Nov 26, 2014 1:18 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Sun Nov 30, 2014 10:55 pm

I found this thread while looking for an easy way to get OpenCV up and running for use from python in raspbian. Nolaan earlier in this thread replied to a question regarding python
Nolaan wrote:
Div wrote:I've followed all the steps you posted here yet I don't seem able to make use of these libraries from python.
This is normal because python use a totally different library. They compile it themselves ie /usr/lib64/python2.7/site-packages/cv2.so
But I don't know what to make of the answer. Does it mean that there is no way to get these compiled libraries to work from python? Or will they work if some additional step is taken by the user?

trundes
Posts: 17
Joined: Wed Nov 26, 2014 1:18 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Mon Dec 01, 2014 2:37 pm

In answer to myself it turned out that all I had to do to install opencv that can be called from Python was to do

Code: Select all

sudo apt-get install libopencv-dev python-opencv
Very weird that a lot of google hits, even from this year, on opencv for raspbian give complicated compilation instructions and estimate the install time to 7 hours or more when there is this other method. Or maybe I'm missing some important difference between those two ways.

Nolaan
Posts: 57
Joined: Thu Jul 10, 2014 6:35 pm
Contact: Website

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Fri Dec 05, 2014 3:33 pm

@AtoM-84 : I didn't. I hope to release a new version by next week; including SURF features.
@trundes : Sorry, my answer was misleading. I thought since there's a python-opencv package, the "cv.so" file is distributed by the Python community. And you're actually right, it can be built from OpenCV sources. I'll try to include it in the next release.
http://www.jetsonblog.com
twitter : @nolaan_boy

trundes
Posts: 17
Joined: Wed Nov 26, 2014 1:18 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Sat Dec 06, 2014 3:45 pm

Nolaan wrote:@trundes : Sorry, my answer was misleading. I thought since there's a python-opencv package, the "cv.so" file is distributed by the Python community. And you're actually right, it can be built from OpenCV sources. I'll try to include it in the next release.
Now I'm really confused. I'm just an end user who wanted to do some OpenCV stuff in python. Doing

Code: Select all

sudo apt-get install libopencv-dev python-opencv
installed it and it appears to work. Is there any advantage for someone like me in using the downloads you offer? (There probably is some obvious difference, I'm new to raspi and kind of new to Linux.)

Nolaan
Posts: 57
Joined: Thu Jul 10, 2014 6:35 pm
Contact: Website

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Sat Dec 06, 2014 4:41 pm

trundes wrote:
Nolaan wrote:@trundes : Sorry, my answer was misleading. I thought since there's a python-opencv package, the "cv.so" file is distributed by the Python community. And you're actually right, it can be built from OpenCV sources. I'll try to include it in the next release.
Now I'm really confused. I'm just an end user who wanted to do some OpenCV stuff in python. Doing

Code: Select all

sudo apt-get install libopencv-dev python-opencv
installed it and it appears to work. Is there any advantage for someone like me in using the downloads you offer? (There probably is some obvious difference, I'm new to raspi and kind of new to Linux.)
It gives the latest version of the software, with all enhancements and features that comes with it. All the bugs corrections and goodies coming with a new software release.
http://www.jetsonblog.com
twitter : @nolaan_boy

freedream
Posts: 6
Joined: Tue Dec 11, 2012 3:47 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Wed Dec 10, 2014 3:35 pm

Thanks for your work, but how I can use it? How to add include files in the program and the compiling parameters(eg. g++ -L xx or -I xx)? If can provide a simple C example to explain it clearly? Many thanks!!

Nolaan
Posts: 57
Joined: Thu Jul 10, 2014 6:35 pm
Contact: Website

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Wed Dec 10, 2014 7:22 pm

See this thread : http://webcache.googleusercontent.com/s ... clnk&gl=cz
I used google cache because the site is apparently in maintenance.
http://www.jetsonblog.com
twitter : @nolaan_boy

paul_espinosa
Posts: 7
Joined: Thu Dec 11, 2014 8:18 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Thu Dec 11, 2014 9:14 pm

how i can include this file of mi aplication when i compilate with qmake ...i am a beginer on that
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>

kinectguy
Posts: 1
Joined: Sun Dec 14, 2014 12:19 am

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Sun Dec 14, 2014 12:24 am

First of all, thank you for your work and sharing it with all of us.

I installed the debian package, all the libraries are there and the configuration file looks good, but it seems there aren't any demos? Is there a way I can get the standard demos so I can see what this software has to offer?

bernhard85
Posts: 1
Joined: Sun Dec 14, 2014 11:33 am

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Sun Dec 14, 2014 11:38 am

Hi! Many thanks for your work. I have one question: Did you compile with openGL support?
For video processing I want to use openGL as the usual imShow is way too slow to show images.
However my program fails at namedWindow("screen", CV_WINDOW_OPENGL);

srayner
Posts: 10
Joined: Sun Mar 17, 2013 5:20 pm
Location: UK
Contact: Website

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Thu Dec 18, 2014 8:55 pm

Can you provide an example of how to use these libraries in a c++ program?

Your example apps seem to be compiled binaries. Do you have any example source code that uses these libraries that you can show us?

I'm just have this (from the OpenCV website);

Code: Select all

#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc, char** argv )
{
    if ( argc != 2 )
    {
        printf("usage: DisplayImage.out <Image_Path>\n");
        return -1;
    }

    Mat image;
    image = imread( argv[1], 1 );

    if ( !image.data )
    {
        printf("No image data \n");
        return -1;
    }
    namedWindow("Display Image", CV_WINDOW_AUTOSIZE );
    imshow("Display Image", image);

    waitKey(0);

    return 0;
}
but the compiler just thows an error because it can't find opencv.hpp

Steve

srayner
Posts: 10
Joined: Sun Mar 17, 2013 5:20 pm
Location: UK
Contact: Website

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Thu Dec 18, 2014 10:33 pm

Trying to get a bit further I did;

Code: Select all

sudo apt-get install libopencv-dev
Then I tried compiling with;

Code: Select all

g++ -std=c++0x DisplayImage.cpp -oDisplayImage 
This now seems to be able to resolve the location of the header files, but now I get this error;

Code: Select all

/tmp/ccw0VCEt.o: In function `main':
DisplayImage.cpp:(.text+0xd0): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
DisplayImage.cpp:(.text+0x158): undefined reference to `cv::namedWindow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
DisplayImage.cpp:(.text+0x1a8): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
DisplayImage.cpp:(.text+0x1bc): undefined reference to `cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
DisplayImage.cpp:(.text+0x1dc): undefined reference to `cv::waitKey(int)'
/tmp/ccw0VCEt.o: In function `cv::Mat::~Mat()':
DisplayImage.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x3c): undefined reference to `cv::fastFree(void*)'
/tmp/ccw0VCEt.o: In function `cv::Mat::operator=(cv::Mat const&)':
DisplayImage.cpp:(.text._ZN2cv3MataSERKS0_[cv::Mat::operator=(cv::Mat const&)]+0x12c): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
/tmp/ccw0VCEt.o: In function `cv::Mat::release()':
DisplayImage.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x58): undefined reference to `cv::Mat::deallocate()'
collect2: ld returned 1 exit status
Any help appreciated.

ScreenOfDeath
Posts: 25
Joined: Tue Dec 16, 2014 10:30 pm
Location: Germany

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Sat Dec 20, 2014 12:22 am

You have to link to the opencv libraries.

I´ve switched to openCV 3.0beta, so you have to modify my makefile.
(Some libs are maybe unknown like -opencv_superres just remove then
and you have to add -lopencv_core -lopencv_legacy at the end)

Here is my makefile:

Code: Select all

opencv_libs = -I/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_video -lopencv_videoio -lopencv_highgui -lopencv_photo -lopencv_flann -lopencv_superres -lopencv_imgcodecs -lopencv_stitching -lopencv_shape -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect

file = YOUR_FILENAME_HERE.cpp 

main: $(file)
	g++ $(file) -o main $(opencv_libs)  

clean:
	rm main
Have fun :D

paul_espinosa
Posts: 7
Joined: Thu Dec 11, 2014 8:18 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Wed Jan 07, 2015 7:53 am

hello i am trying to use opencv with qt
one month ago, i used opencv with qt
i did this on my rapberry:
wget https://github.com/Nolaan/libopencv_24/ ... 10.deb.zip
unzip libopencv_2.4.10.deb.zip
sudo dpkg -i libopencv_2.4.10.deb
and i added the file opencv and opencv2 in /usr/local/include (these files i got of my compile opencv on my laptop)


but now i do the same but i can not compile
this appears on the terminal

/usr/bin/g++ -c -pipe -marm -mfpu=vfp -mtune=arm1176jzf-s -march=armv6zk -mabi=aapcs-linux -mfloat-abi=hard -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_CORE_LIB -I/opt/qt5/mkspecs/devices/linux-rasp-pi-g++ -I. -I/usr/local/include/opencv -I/opt/qt5/include -I/opt/qt5/include/QtCore -I. -o main.o main.cpp
main.cpp:6:5: warning: unused parameter ‘argc’ [-Wunused-parameter]
main.cpp:6:5: warning: unused parameter ‘argv’ [-Wunused-parameter]

/usr/bin/g++ -Wl,-rpath-link,/opt/vc/lib -Wl,-rpath-link,/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/lib/arm-linux-gnueabihf -Wl,-O1 -Wl,-rpath,/usr/local/qt5/lib -o cam main.o -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann -lopencv_nonfree -L/usr/local/qt5/lib -lQt5Core -lpthread

/usr/bin/ld: warning: libavformat.so.53, needed by /usr/local/lib/libopencv_highgui.so, not found (try using -rpath or -rpath-link)
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
/usr/local/lib/libopencv_highgui.so: undefined reference to `[email protected]_53'
collect2: ld returned 1 exit status
Makefile:176: recipe for target 'cam' failed
make: *** [cam] Error 1


some body maybe has a solution ???

paul_espinosa
Posts: 7
Joined: Thu Dec 11, 2014 8:18 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Wed Jan 07, 2015 5:03 pm

problem solved
do
sudo apt-get install ffmpeg
sudo ldconfig
everything ok

pmap93
Posts: 19
Joined: Mon Sep 29, 2014 12:48 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Thu Jan 08, 2015 9:48 am

So this process of installing OpenCV doesn't work if going to be used for Python? If it is possible, how? :D

paul_espinosa
Posts: 7
Joined: Thu Dec 11, 2014 8:18 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Thu Jan 15, 2015 10:29 pm

i am testing on qt5.2
http://www.alvarolara.com/2014/08/22/co ... pberry-pi/

this lenguage is on c++

but install opencv on pyton is very easy
http://robologs.net/2014/04/25/instalar ... erry-pi-2/
these link only function with pyton 2

here there is like install pyton 2.7 an the driver for raspicam to use the pi camera with opencv
http://picamera.readthedocs.org/en/rele ... tall2.html

KRV_Perera
Posts: 1
Joined: Fri Jan 16, 2015 8:13 am

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Fri Jan 16, 2015 8:17 am

Would you post a sample code which uses compiled libraries in a working program
because demo app are seems not working when I tried this.
C or Python is preferred.. Thanks in advance

vnv
Posts: 14
Joined: Tue Jan 20, 2015 5:13 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Wed Feb 04, 2015 1:06 pm

Hi,

could you please upload whole installation directory, so it is possible to do make install.

vnv
Posts: 14
Joined: Tue Jan 20, 2015 5:13 pm

Re: OpenCV 2.4.9 compiled libraries for Raspberry Pi (RPi)

Wed Feb 04, 2015 2:32 pm

Also if it isn't burden for you, could you explain steps in building it (if you do cross compile).

Thanks.

Return to “C/C++”