This question already has answers here:
How to check for openCV on Ubuntu 9.10
(7 answers)
Closed 8 years ago.
I would like to find out what version of OpenCV is installed on my computer (i am running Ubuntu 10.04). Is there a simple way to check it if ? If not then can i find out the directories where files (samples, etc) are installed ?
I am trying to run some code that i have already tested on another computer with OpenCV 2.3 installed and i get many errors.
The other methods here didn't work for me, so here's what does work in Ubuntu 12.04 'precise'.
On Ubuntu and other Debian-derived platforms, dpkg is the typical way to get software package versions. For more recent versions than the one that #Tio refers to, use
dpkg -l | grep libopencv
If you have the development packages installed, like libopencv-core-dev, you'll probably have .pc files and can use pkg-config:
pkg-config --modversion opencv
You can look at the headers or libs installed. pkg-config can tell you where they are:
pkg-config --cflags opencv
pkg-config --libs opencv
Alternatively you can write a simple program and print the following defs:
CV_MAJOR_VERSION
CV_MINOR_VERSION
A similar question has been also asked here:
1) Direct Answer:
Try this:
sudo updatedb
locate OpenCVConfig.cmake
For me, I get:
/home/pkarasev3/source/opencv/build/OpenCVConfig.cmake
To see the version, you can try:
cat /home/pkarasev3/source/opencv/build/OpenCVConfig.cmake
giving
....
SET(OpenCV_VERSION 2.3.1)
....
2) Better Answer:
"sudo make install" is your enemy, don't do that when you need to compile/update the library often and possibly debug step through it's internal functions. Notice how my config file is in a local build directory, not in /usr/something. You will avoid this confusion in the future, and can maintain several different versions even (debug and release, for example).
Edit: the reason this questions seems to arise often for OpenCV as opposed to other libraries is that it changes rather dramatically and fast between versions, and many of the operations are not so well-defined / well-constrained so you can't just rely on it to be a black-box like you do for something like libpng or libjpeg. Thus, better to not install it at all really, but just compile and link to the build folder.
There is also a flag CV_VERSION which will print out the full version of opencv
To install this product you can see this tutorial: OpenCV on Ubuntu
There are listed the packages you need. So, with:
# dpkg -l | grep libcv2
# dpkg -l | grep libhighgui2
and more listed in the url you can find which packages are installed.
With
# dpkg -L libcv2
you can check where are installed
This operative is used for all debian packages.
Related
I am trying to get my head around some basic concepts, but I can't seem to figure them out.
I am really confused over what it means to install (I think they are called libraries) for C++. I am trying to install OpenCV, but I don't know what needs to happen for it to be installed, how to check, or what really OpenCV is (Is it a library, framework, something else?).
My understanding is that OpenCV (and other libraries/frameworks) is distributed as only the source code so that is is able to work cross-platform. Then, after you download it, you have to build it (I don't know what build means though), and then link your compiler against it so that it can access the files? I don't know how any of this would be done, or really what this means. I think a lot of this is done by CMake, but I don't know what CMake really does, how you would use it, or how you would then utilize the library/framework in your code. Also, where would the libraries like OpenCV be installed, how would clang (or any other compiler/linker) know where to find them, and what kind of files would they be (.a, .dylib, .cpp, .hpp, executables, or a collection of everything)? Is this structure specific to C++ and OS X or is it more widespread?
I am not looking for a tutorial on how to install OpenCV or other libraries, but I am instead trying to learn how that actually works so I won't need tutorials in the future.
Before you can do any C/C++ development work on a Mac, you need to go to the App Store and download Xcode for free - it is Apple's IDE - Integrated Development Environment. Without Xcode, you will have no compiler (i.e. clang or gcc or g++) and no build tools, (i.e. make).
Install Xcode
If you are totally new to Mac, App Store looks like this:
and Xcode looks like this:
Install Command Line Tools
Next you must install Xcode's command-line tools, so start a Terminal - by pressing ⌘+SPACE and starting to type Terminal and when it guesses correctly, just hit Enter/Return. Copy and paste the following into Terminal and hit Enter/Return.
xcode-select --install
The above is called a "Spotlight Search" and is the easiest way to find anything on a Mac.
Install homebrew
Then, if you want to install OpenCV on a Mac, install a package manager such as homebrew which is a matter of copying and pasting a single line from the homebrew website into your Terminal. I will not show the line here in case it ever changes and someone looks at this in a few years, but it is easy to see if you go to the link above.
Find Packages
Then you can find any packages you want with:
brew search opencv # Look for packages called "opencv"
or
brew search boost # Look for "boost" libraries
Install OpenCV
So, for a vanilla (no special options) installation and build of OpenCV do this:
brew install opencv
Remove Packages
You can later remove any packages you no longer want with:
brew rm opencv
Update Packages
You can also update all installed packages with:
brew update && brew upgrade && brew cleanup
Build a Project
Once you have got it installed, you can start compiling and building your own project. It helps if you use the pkg-config package to pick up all the necessary compiler/linker settings you need, so I would suggest:
brew install pkg-config
Now you can compile and link with a really simple command like:
g++ $(pkg-config --cflags --libs opencv) process.cpp -o process
Then you can go on to use Xcode IDE later if you want to once you get started.
Build with Xcode
Once you have got started with basic compilation, you may want to start using Xcode to edit your programs, to do that, you must tell Xcode where the header files are and also where the libraries are and which libraries to link. This will vary with your OpenCV version, but you will need to alter the places marked in the two diagrams below. You will find these easily if you click them in order - green area first, then the yellow, then the blue, then the red.
The actual information that will need to go in the Xcode settings areas I have marked above can be found by running the same pkg-config command I suggested in the previous section. So run:
pkg-config --cflags opencv
to get the location of the header (include) files, and then run
pkg-config --libs opencv
to get the information you need to fill in for the linker in Xcode.
I have just installed the newest OpenCV from source. After the installation I found that OpenCV was already installed on my computer. Now I have a /usr/include/opencv and a /usr/include/opencv2 existing together.
When I was trying to compile an example from the newest version, it automatically went to the directory opencv2 to find the header files. Obviously some examples in the new version require header files that only exist in opencv but not in opencv2.
I checked the version being used as follows.
$ pkg-config --modversion opencv
2.4.8
How can I clean the old version and set the environmental variables such that the newer version is used instead?
Thanks for pointing it out. I didn't realize that both /opencv and /opencv2 exist at the same time in normal installations. So these folders are irrelevant.
Here's what I did to install OpenCV. I followed this tutorial on my newly installed ubuntu 14.04:
http://www.bogotobogo.com/OpenCV/opencv_3_tutorial_ubuntu14_install_cmake.php
I git cloned and did a full make install. I thought the git source was of version 3.0.0, am I wrong on that?
(Sorry for the late edit and thanks so much for your help!!)
To reproduce your problem, I have just installed OpenCV from the Ubuntu package repository:
$ sudo aptitude install libopencv-dev
Which put include files to these places:
/usr/include/opencv
/usr/include/opencv2
I then downloaded and installed OpenCV from this place: http://opencv.org/
$ cd Downloads/opencv-3.0.0
$ mkdir build
$ cd build
$ cmake ..
[lots of configuration related output ...]
$ make -j7
[lots of build related output ...]
$ sudo make install
[lots of installation related output ...]
pkg-config now finds the newer version:
$ pkg-config --modversion opencv
3.0.0
And the includes are located here:
/usr/local/include/opencv
/usr/local/include/opencv2
You shouldn't have a problem, given you want to use the later installed version. (Are you sure you did properly install the custom build: sudo make install?)
You might want to remove the older version:
$ sudo aptitude remove libopencv-dev
However, you should make sure that you don't remove dependencies your custom build relies on (zlib, libjpeg, libtiff, pibpng, ...).
That being said, pkg-config gives you the details from the opencv.pc file it finds last.
These are the available files:
$ locate opencv.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/opencv.pc
/usr/local/lib/pkgconfig/opencv.pc
The latter belongs to the newer version (build from source), the first belongs to the older version (package install).
This is the search path:
$ pkg-config --variable pc_path pkg-config
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
Given this order of the entries in the search path, you get the newer version via pkg-config.
Currently I am writing a gtkmm3 GUI in netbeans and using a linux dev server to compile linux binaries as I go. As I really want my final program to be cross platform, I set up a dev server specifically for compiling windows apps in linux. I am using the custom repo listed here: http://sourceforge.net/projects/mingw-w64-archlinux but I am having trouble using pkg-config. I have tried all combinations I can think of (pkg-config mingw-w64-gtkmm3, pkg-config gtkmm-3.0, pkg-config mingw-w64-gtkmm-3.0, etc.) but all of them give me an error liks this:
Package mingw-w64-gtkmm3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `mingw-w64-gtkmm3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'mingw-w64-gtkmm3' found
I am new to doing cross-compiling, so help is appreciated.
I found the solution after poking around in the /usr directory for awhile. I advise anyone else struggling with this problem to do the same to familiarize themselves with mingw-w64.
the pkg-config command for mingw-w64 on arch is:
i686-w64-mingw32-pkg-config gtkmm-3.0 --cflags --libs
However, in order to use the above command, one first needs to install the following package on arch: mingw-w64-pkg-config (from the repo linked in the question)
I'm not extremely familiar with the linux filesystem, having moved from windows, but I do have a decent amount of experience with C++ and the Boost libraries in windows. Having switched Fedora 17, can anyone tell me if there is a certain directory where I should install Boost to get it working the gnu compiler?
Note: if it matters, I don't use an IDE I use vim for most of my programming.
There are a few ways of setting up the boost libraries on linux.
Save yourself some pain, use your package manager to install the Boost libs. You'll be grateful in the long run.
If you absolutely must do it yourself, simply put it anywhere so long as it's in the gcc include path. This is /usr/local/include/ or /usr/include/ for headers and /usr/local/lib/ or /usr/lib/ for libraries
Finally if for some reason that isn't possible, use the -I switch with g++ to specify the path to boost. (but this would only be necessary if 1 and 2 aren't possible)
Use your package manager to install boost libraries, for debian ubuntu it is like:
sudo aptitude install libboost-system1.49.0-dev
for centos6 it is
yum install boost-devel
I had issues installing boost using yum (recently installed Fedora 17)..
so I unzipped the boost tar ball to my /opt.
so g++ -I /opt/boost/boost_1_51_0 works like a charm.
From the introduction to boost:
http://www.boost.org/doc/libs/1_51_0/more/getting_started/unix-variants.html
you can put it anywhere you like. And then you compile with something like this
c++ -I path/to/boost_1_51_0 example.cpp -o example \
-L~/boost/stage/lib/ -lboost_regex-gcc34-mt-d-1_36
"c++" can be g++ or clang++ for example.
I've been googling and trying for days now, trying to figure out how to get 32-bit OpenCV working on OS X Lion, but can just find 64-bit version.
So i have the following questions:
OpenCV libraries come in 32-bit or 64-bit arch, is that correct?
How do I get 32-bit OpenCV working on Lion? I've trying the following ways:
- Install OpenCV via MacPorts: nope, MacPorts installs a 64-bit version.BI removed OpenCV and MacPorts.
Install OpenCV 2.4.1 via Homebrew, using the following command:
brew install opencv --build32
but looks like they are 64-bit too. Removed OpenCV and Homebrew.
Install OpenCV 2.4.1 by myself using standard unix makefiles. Nope, they still look like 64-bit.
I've written "they look like 64-bit" because i have to replace OpenC in a Xcode project made under OS X Snow Leopard, targeted for 32-bit Mac, and I always get tons of errors like:
ld: warning: ignoring file /usr/local/Cellar/opencv/2.4.1/lib/libopencv_calib3d.2.4.1.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
so i suppose that the OpenCV stuff is 64-bit. If i force the project to run in 64-bit, it rubs but doesn't work properly and gets stuck.
Is there a standard way to check if my OpenCV libraries are 64-bit or 32-bit?
Where can i get 32-bit OpenCV?
Solved the problem.
Recap: it is possible to have 32-bit OpenCV libraries on 64-bit Mac OSX Lion.
How?
Step 1: Download OpenCV 2.4.0
Step 2: Download and install CMake.
Step 3: Untar the OpenCV package.
Step 4: Make a separate directory inside the OpenCV package for building
mkdir build
cd build
cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 -D CMAKE_C_FLAGS=-m32 -D CMAKE_CXX_FLAGS=-m32 ..
(this will force the 32-bit compile)
make -j8
sudo make install
Step 5: Enjoy!
For forther reference please visit Mac OS X OpenCV Port Page
Thanks all for putting me on the right track:
#karlphilip: I tried to do as you suggested, but without the make options the compile phase fails, because the architectures are incoherent.
#hamstergene: MacPorts got stuck after the new installation, maybe I have some remains of the older install :( (strange, i followed the official instrusctions to remove it).
#Adrien: That's what I've done, but i had to merge 2 approaches :)
I ve had a hard time configuring OpenCv libraries on a number od different OSs. Turns out that the thing is auto-generating a sample project and then bulding business logic inside it.
See the installation instructions here
The web site of the OpenCV project has been significantly upgraded in the last year.
A new tutorial section is avaiable, i was able to install OpenCV on my 32-bit core Mac OS Lion.
A very cool tutorial is also available at Sadeep's Tech Blog, covering an interesting range of details.
Hope this helps!
Here's something you can try: download OpenCV 2.4 sources and edit the CMakeLists.txt in the root directory. Around line 242 you will see:
# ----------------------------------------------------------------------------
# Path for build/platform -specific headers
# ----------------------------------------------------------------------------
set(OPENCV_CONFIG_FILE_INCLUDE_DIR "${CMAKE_BINARY_DIR}/" CACHE PATH "Where to create the platform-dependant cvconfig.h")
add_definitions(-DHAVE_CVCONFIG_H)
ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR})
below the add_definitions() call, add this one:
add_definitions(-m32)