Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
09-19-2015, 04:23 PM
|
#1
|
Senior Member
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267
Rep:
|
How do I setup opencv2 on my ubuntu distribution
I have a project to do but I need opencv libraries in order to do it. I did the apt-get install commands and tried to compile the c++ file that was given to me but I got a bunch of errors. I think the libraraies are not there, or they are placed in a location that the compiler doesn't seem to be looking in. where is the compiler looking for these library files and how do I set to where the compiler will include these files when it compiles a program.
|
|
|
09-19-2015, 06:27 PM
|
#2
|
Member
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792
|
Quote:
Originally Posted by baronobeefdip
I did the apt-get install commands
|
Did you install the development package?
Code:
$ apt-get install opencv-dev
EDIT: As noted by baronofbeefdip below that should be libopencv-dev
Quote:
Originally Posted by baronobeefdip
. . . I got a bunch of errors.
|
Please list the errors.
Here's an example command line to compile a c++/opencv program on my system:
Code:
g++ -std=c++11 main.cpp -lstdc++ $(pkg-config --libs --cflags opencv)
Last edited by norobro; 09-19-2015 at 06:41 PM.
|
|
|
09-19-2015, 06:28 PM
|
#3
|
Senior Member
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267
Original Poster
Rep:
|
Quote:
Originally Posted by norobro
Did you install the development package?
Code:
$ apt-get install opencv-dev
Please list the errors.
Here's an example command line to compile a c++/opencv program on my system:
Code:
g++ -std=c++11 main.cpp -lstdc++ $(pkg-config --libs --cflags opencv)
|
The errors are pretty much saying that they can't find the header files.
Just tried your apt-get command and I got an error, is there a ppa or something that I can use to fix this one.
Code:
E: Unable to locate package opencv-dev
|
|
|
09-19-2015, 06:34 PM
|
#4
|
Senior Member
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267
Original Poster
Rep:
|
Quote:
Originally Posted by norobro
Did you install the development package?
Code:
$ apt-get install opencv-dev
Please list the errors.
Here's an example command line to compile a c++/opencv program on my system:
Code:
g++ -std=c++11 main.cpp -lstdc++ $(pkg-config --libs --cflags opencv)
|
I just ran this command and installed all of the development files, I'll post what happens when I try to compile the program
Code:
apt-get install libopencv-dev
|
|
|
09-19-2015, 06:36 PM
|
#5
|
Member
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792
|
EDIT: whoops, had this open in a tab and missed your post.
Are you still on Squeeze? What do you use as repositories?
Here is opencv-dev in Wheezy: link
Last edited by norobro; 09-19-2015 at 06:38 PM.
|
|
|
09-19-2015, 06:38 PM
|
#6
|
Senior Member
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267
Original Poster
Rep:
|
Quote:
Originally Posted by norobro
Are you still on Squeeze? What do you use as repositories?
Here is opencv-dev in Wheezy: link
|
I just tried to compile the program, here is what came back
Code:
/tmp/ccvvzxBm.o: In function `main':
lab1.cpp:(.text+0x5c): undefined reference to `cv::imread(std::string const&, int)'
lab1.cpp:(.text+0x1a9): undefined reference to `cv::namedWindow(std::string const&, int)'
lab1.cpp:(.text+0x1da): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
lab1.cpp:(.text+0x21a): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
lab1.cpp:(.text+0x242): undefined reference to `cv::waitKey(int)'
lab1.cpp:(.text+0x275): undefined reference to `cv::destroyWindow(std::string const&)'
/tmp/ccvvzxBm.o: In function `cv::Mat::~Mat()':
lab1.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/ccvvzxBm.o: In function `cv::Mat::operator=(cv::Mat const&)':
lab1.cpp:(.text._ZN2cv3MataSERKS0_[_ZN2cv3MataSERKS0_]+0x111): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
/tmp/ccvvzxBm.o: In function `cv::Mat::release()':
lab1.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x47): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
I am using Backbox Linux, the most recent reccomended version.
|
|
|
09-19-2015, 06:43 PM
|
#7
|
Member
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792
|
And how did you compile it? Are you using an IDE?
|
|
|
09-19-2015, 06:47 PM
|
#8
|
Senior Member
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267
Original Poster
Rep:
|
Quote:
Originally Posted by norobro
And how did you compile it? Are you using an IDE?
|
I used the g++ command, I figured because it was a C++ file.
|
|
|
09-19-2015, 06:57 PM
|
#9
|
Member
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792
|
What do you get with the following command?
Code:
pkg-config --libs opencv
|
|
|
09-19-2015, 07:01 PM
|
#10
|
Senior Member
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267
Original Poster
Rep:
|
Code:
/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so /usr/lib/x86_64-linux-gnu/libopencv_contrib.so /usr/lib/x86_64-linux-gnu/libopencv_core.so /usr/lib/x86_64-linux-gnu/libopencv_features2d.so /usr/lib/x86_64-linux-gnu/libopencv_flann.so /usr/lib/x86_64-linux-gnu/libopencv_gpu.so /usr/lib/x86_64-linux-gnu/libopencv_highgui.so /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so /usr/lib/x86_64-linux-gnu/libopencv_legacy.so /usr/lib/x86_64-linux-gnu/libopencv_ml.so /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so /usr/lib/x86_64-linux-gnu/libopencv_ocl.so /usr/lib/x86_64-linux-gnu/libopencv_photo.so /usr/lib/x86_64-linux-gnu/libopencv_stitching.so /usr/lib/x86_64-linux-gnu/libopencv_superres.so /usr/lib/x86_64-linux-gnu/libopencv_ts.so /usr/lib/x86_64-linux-gnu/libopencv_video.so /usr/lib/x86_64-linux-gnu/libopencv_videostab.so -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab
|
|
|
09-19-2015, 07:15 PM
|
#11
|
Member
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792
|
That's the same list my system has. Is your c++ file too large to post?
|
|
|
09-19-2015, 07:25 PM
|
#12
|
Senior Member
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267
Original Poster
Rep:
|
not at all
Code:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( )
{
Mat img;
img = imread("tamucc.jpg", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "tamucc.jpg" and store it in 'img'
if (img.empty()) //check whether the image is loaded or not
{
cout << "Error : Image cannot be loaded..!!" << endl;
return -1;
}
double rows = img.rows; // image size
double cols = img.cols;
cout<< "The image has "<<rows<<" rows and "<<cols << " columns"<<endl;
namedWindow("MyWindow",CV_WINDOW_NORMAL);
imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window
waitKey(0); //wait infinite time for a keypress
destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"
return 0;
}
|
|
|
09-19-2015, 07:47 PM
|
#13
|
Member
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792
|
Works on my box, of course with a different jpeg file:
Code:
$ gcc -std=c++11 main.cpp -lstdc++ $(pkg-config --libs --cflags opencv)
$ ./a.out
The image has 389 rows and 600 columns
So something is wrong with your install. Maybe try reinstalling opencv?
Is the tamucc what i think it is? I'm in central Tejas.
|
|
|
09-19-2015, 07:56 PM
|
#14
|
Senior Member
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267
Original Poster
Rep:
|
How do I reinstall it, because it's a fresh Linux distribution installation and a fresh install of opencv. I didn't do anything with anything on the system other than install the opencv development files.
|
|
|
09-19-2015, 08:11 PM
|
#15
|
Member
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792
|
The only way I know is to remove the package first and the install it again. Probably not necessary though.
What does the following output? As root:
Code:
ldconfig -p | grep opencv
|
|
|
All times are GMT -5. The time now is 06:38 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|