I'm trying to compile a C++ program that uses OpenCV to score the similarity of two images:
Image Histogram Compare
When I g++ compile the file:
'opencv2/imgcodecs.hpp' file not found
#include "opencv2/imgcodecs.hpp"
I updated the opencv formula on Mac OS X. I re-ran brew install, but I still get this error.
mdfind imgcodecs.hpp -name
returns nothing - the file is nowhere on my system.
Does anyone know my imgcodecs is not included, and how to include it? I'm really novice at C and OpenCV, and enormously grateful for any help.
I notice that you are looking at tutorial code on the master branch (aka 3.0.0). It uses an imgcodecs module that is not present in earlier versions of OpenCV (e.g. 2.4.9).
Check which version of OpenCV you have (it seems not 3.0.0) and use a matching version of tutorial code (e.g. OpenCV 2.4.9 Histograms_Matching/EqualizeHist_Demo.cpp)
Related
Ok, just got my first Raspberry pi (3). Went on to install Opencv 3.1.0 using Adrian's guide:
How to Install Opencv 3 on Raspbian Jessie
Installed OpenCV WITH CONTRIB packages as I knew I would need them.
So OpenCV is working fine now. The issue is when I try to use SIFT:
"'module' object has no attribute 'xfeatures2d'"
I did and still do everything by the book, including working on 'cv' environment etc.
I tried checking the site-packages dir of both the python dir and the 'cv' env dir and couldn't find any mention of 'contrib' or 'xfeatures2d'.
Maybe that's the problem? How can I check that the contrib packages were actually compiled with OpenCV?
Thanks in advance.
Because u installed the latest version in OpenCV where they removed sift and surf, I am not sure how they substitute them, anyway u have to install older version of opencv 3.4.2.16 also make sure that opencv contrib of the same version is installed, thats the last working version working with sift/surf not sure if there are special versions for raspberry pi
I installed OpenCV 2.4.13 after installing the required dependencies and I'm running it with Qt Creator 5.7 for programming in C++. Following some tutorials I managed to load still images, process them and so on. But when I try to use the cv::VideoCapture, for example:
cv::VideoCapture cap;
cap.open("<File location/file name>");
or:
cv::VideoCapture("<File location/file name");
cap.isOpened() always return false. Even if I try to ignore this and go further with Mat, read, imshow and so on, the program crashes. I've already tried everything about loading the file: giving a std::string as argument, giving a *char, putting the video file on easier locations, in the project directory and nothing works. I tried with two different .mp4, with a .mov and with the cube4.avi file given in the "samples" folder (from openCV examples). All these files are perfectly played by my VLC. I've already tried in Qt with a QtWidgets project and with a plainCpp project. It never works. After searching about it, I've seen that this bug is very recurrent, but I've just found solutions for Windows, regarding on adding a .dll file to the project. But what should I do on Ubuntu, since Linux uses no dlls?
I figured out how to solve this and I'm here to share with everyone who encounter similar problems. First of all, my FFmpeg installation was for any unknown reason ignored on the OpenCV compilation. Since FFmpeg is needed to read and write videos, OpenCV wasn't able to do these jobs and displayed no error or warning messages about that. Anyway I decided to try everything again from the beginning. Keep in mind: if you just reinstall FFmpeg, it's not going to solve your problems; after that you have to do cmake, compile and install OpenCV again. I downloaded the most recent version of FFmpeg from the repository, compiled and installed it again. I tried to compile OpenCV again, but it was always stuck at about 15% when processing a FFmpeg (Libav) .h file with the message:
<file_name.h> can not be used when making a shared object; recompile with -fPIC
So I searched for it and with some effort I found out that it was necessary to compile the FFmpeg with the following configure line before doing the make:
.\configure --enable-pic --enable-shared
Some ffmpeg installation tutorials include even more commands after "configure". Then I compiled and reinstalled FFmpeg and compiled and reinstalled OpenCV. After that, I was able to load videos (the cap.isOpened() was no longer false), but nonetheless I was getting the following error for any video and they weren't being read:
Assertion desc failed at libswscale/swscale_internal.h:674
The way I found to solve this was downloading the newest stable FFmpeg version instead of the newest on, compiling it again, compiling OpenCV again and then it was successful! Now I can both load and write video files (I haven't tested it with multiple codecs yet). I wonder why they don't launch pre-compiled versions of OpenCV with everything so that we don't need to deal with all these stuffs...
Summarizing everything:
Download the last stable release of FFmpeg. If it doesn't work, try an older one. (I'm using the 2.8.6, the last stable right now).
Unpack it, open the terminal from the ffmpeg folder, compile and install it typing:
.\configure --enable-pic --enable-shared
make
sudo make install
Download OpenCV (if you haven't done it yet), unpack and install it following the official linux installation tutorial:
http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation
I solve the problem by install "opencv3.2.0-dev" instead "opencv3.2.0";
pip install opencv-python is not enough to install OPENCV.
I want to compile an OpenCV program where there is the header :
#include <mrpt/otherlibs/do_opencv_includes.h>
#if (MRPT_OPENCV_VERSION_NUM>=0x240) && MRPT_HAS_OPENCV_NONFREE
# include <opencv2/nonfree/features2d.hpp>
#endif
It require a version of OpenCV higher that 0x240.
I installed the OpenCV3 in my computer and now I have two versions of Open CV one lower that 0x240 and the other one is 3.0. When executing the program, it doesn't recognize the version 3.0.
What should I do ?
Thanks,
Younès
Building MRPT against OpenCV 3.0.0 has been very recently fixed in the master branch on GitHub, so if you get the code from there it should work now.
I am trying to build and use a piece of C++ code that uses OpenCV. I am working on Linux, working in Code::Blocks (and the code was originally also developed on a Linux platform using C::B).
I followed this to install OpenCV (Ubuntu 12.04 & OpenCV 2.4.3). The project compiles fine, but when I try to execute it, it crashes on launch, with the following message about how it can not find the library:
(file_address): error while loading shared libraries: libopencv_core.so.2.3:
cannot open shared object file: No such file or directory
Process returned 127 (0x7F) execution time : 0.017 s Press ENTER to continue.
I set all the parameters for the linker according to several Code::Blocks install tutorials.
I also checked in /usr/local/lib/ for my libraries (it is the folder I gave to Code::Blocks' compiler); and while I do have a libopencv_core.so, a libopencv_core.so.2.4 and a libopencv_core.2.4.3, I do not have a libopencv_core.so.2.3.
So I'm wondering what the issue is. Is it about backwards compatibility, i.e. do I have to install the exact same version of OpenCV used to develop the original code? (This would be a bit concerning, since I am trying to make a widely-usable library).
Could I force it to use libopencv_core.so.2.4 instead?
EDIT: I managed to make it work by removing everything and reinstalling with a simple apt-get. Sometimes it's the simplest method that works the best! From now on I'll try to apt-get before following installation tutorials. ;)
Have a nice day!
I am using OpenCV 2.4.6 on my Mac using XCode IDE. I am trying to create HDR images and I found this tutorial.
When I build it, it doesn't recognize, for example, CalibrateDebevec identifier. The problem is that in the header files of photo.hpp, it is not declared. In the tutorial is written that the base is OpenCV 3.0.0.
How can I make OpenCV 3.0.0 available?
I already tried to download these files from http://193.87.95.148/openwrt/mx23/trunk/dl/opencvtrunk-2.5.0/ and pasted the headers files into my include folder, but when I solve one problem, 10 more problems appear.
You can build OpenCV 3.0.0 from the current DevZone root master repository at http://code.opencv.org/projects/opencv/repository. Clone that repository and use cmake + options, make, and make install, just as you would when building any version of OpenCV. Good luck!