A new version of OpenCV has been released so… Time to update!
(This is an updated version of the article I wrote months ago: Installing and using OpenCV 3.2 with Eclipse and MinGW on Windows 10. )
Getting started
– You will need:
- OpenCV source code: version 3.4 or 3.3 (Link to Github repository (Latest release: 3.4.3));
- (Optional) If you want the extra modules, you will need opencv_contrib (Version 3.4.3 can be found here)
- Download MinGW-w64 and extract;
- Download and install CMake.
Configuring OpenCV
- Add MinGW to System Path
– Edit your System Environment variables (you can search for Environment in Windows’ Start Menu) ;
– Click on Path, and Edit;
– Then, hit New, and add the address of your MinGW bin folder.
- Extract OpenCV to a folder, rename it opencv_src- Inside it, create a folder named Mingw_build
Now, let’s compile OpenCV
- Open CMake-gui;
- Set “Where is the source code:” to opencv_srcand “Where to build the binaries” to opencv_src/Mingw_build/
- Click on Configure, choosing Eclipse CDT4 – MinGW MakeFilein the next window, then next;
Optional Step: OpenCV_Contrib Extra modules
- If you want a simple and flawlessly working installation, just skip this step and go to the next, it’s not obligatory for you to have opencv_contrib.
- For additional info, access its Modules Github Page.
- After the “Configure” is finished, Set OPENCV_EXTRA_MODULES_PATH to opencv_contrib/modules folder
Building and Installing
- After the “Configure”, on my PC I had to deselect the options ENABLE_PRECOMPILED_HEADERS and BUILD_opencv_python3 to correctly compile.
- Hit “Generate”;
- Now, open the CMD/PowerShell, and navigate to opencv_src/Mingw_build/
- Inside opencv_src/Mingw_build type mingw32-make and hit enter;- This step probably will take a while, wait until it’s finished.
- Install using mingw32-make install
- Finally, add C:\opencv_src\Mingw_build\install\x64\mingw\binto your system path.
- I have seen errors related also to the following parameters: WITH_PTHREADS_PF , WITH_OPENCL and ENABLE_CXX11 options. Try unchecking then if something occurs.
Configuring Eclipse
- Open it and create a C++ program using the following OpenCV example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #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: thisprogramname.exe 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; } |
- Go to
Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes
and add the source OpenCV folderC:\opencv_src\Mingw_build\install\include
- Go to
Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries
, and add this to the Libraries (-l), separately as shown in the image - For OpenCV 3.4:
1 | opencv_calib3d340 opencv_core340 opencv_features2d340 opencv_flann340 opencv_highgui340 opencv_imgcodecs340 opencv_imgproc340 opencv_ml340 opencv_objdetect340 opencv_photo340 opencv_shape340 |
- For OpenCV 3.3:
1 | opencv_calib3d330 opencv_core330 opencv_features2d330 opencv_flann330 opencv_highgui330 opencv_imgcodecs330 opencv_imgproc330 opencv_ml330 opencv_objdetect330 opencv_photo330 opencv_shape330 |
- If you are using a different OpenCV version, change the number at end of each lib to match your version
- You can add additional libraries from lib folder if you need, just follow the presented format;
- Add
C:\opencv_src\Mingw_build\install\x64\mingw\lib
to Library search path (-L); - Build the project. There are a lot of o ways of running it, e.g.:
- Open the Powershell or CMD, go to the executable folder and type:
yourprogramname.exe image.jpg - Or put the path of the image you want to show in the code, changing the following line:
- image = imread(argv[1], CV_LOAD_IMAGE_COLOR);
to - image = imread("C://YOURIMAGEPATH.jpg", CV_LOAD_IMAGE_COLOR);
- image = imread(argv[1], CV_LOAD_IMAGE_COLOR);
- Open the Powershell or CMD, go to the executable folder and type:
- Updates
04/11/17 – Changed the order of some steps;
22/11/17 – Added MinGW-w64 instead of the conventional MinGW;
11/01/18 – Added support to OpenCV 3.4
12/04/18 – Added a better explanation for running the test code
12/09/18 – Added version 3.4.3 links and error correction sentences
Have fun with your projects!
If this post helped you, please consider buying me a coffee 🙂
It doesn’t work for me.
First it complains because of SSE related stuff. So I set CPU_BASELINE from SSE2 to none (empty).
Then it says “No rule to make taget lib/libopencv_core330.dll.a’. How can that be?
I use the latest mingw and cmake. Any ideas or can I get precompiled binarys anywhere?
Hi.
Are you compiling with contrib modules? Don’t use them, unless you need.
If you’d like there’s an “official” vc14 compiled version at OpenCV’s website. I never tried it, actually.
What exactly is the SSE related stuff? Could you show the error?
it doesnt work.
Building CXX object modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj
This error occurs
Hi.
Try changing the ENABLE_CXX11 option on cmake.
It throw me this message of error
Makefile:161: recipe for target ‘all’ failed
mingw32-make: *** [all] Error 2
Do you know what is happen ???
Hi.
Could you provide more details with a screenshot or the last 20 lines of the error?
I am getting the same error. The snippet of the screen is in the link below:
https://drive.google.com/file/d/0B3cvBRnPDv1Kd0g3YXhMVUNuN1U/view?usp=sharing
I’m not sure if this will work, but you could try to download the unmodified 3.3 version and retry the process with it.
https://github.com/opencv/opencv/archive/3.3.0.zip
I used the one you mentioned but it doesn’t seem to work.
Shows an error “Error in configuration process. Project files may be invalid.” after I use Cmake_gui. Cant move forward.
Hello, I just tried this process and I get stuck after launching mingw32-make from the terminal. I get into some errors of this kind:
C:\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:176:14: error: ‘mutex’ in namespace ‘s
td’ does not name a type
std::mutex mtx;
and many others like this. I have activated the option ENABLE_CXX11…but I don’t think this is the problem. ANy ideas?
Hi.
Disable ENABLE_CXX11 and ENABLE_PRECOMPILED_HEADERS then click on Generate again.
I’ve done everything up to mingw32-make and then there’s this error.
https://drive.google.com/file/d/0B60WcsSD4fzuUGo3TzBtRElrYmM/view?usp=sharing
Hi.
Try disabling ENABLE_CXX11 and ENABLE_PRECOMPILED_HEADERS on CMake, then hit Generate again.
I tried disabling both but it seems that I’m still receiving the same error. I forgot to mention this but I also used contrib modules.
Did you try to compile without contrib?
Just now I tried to compile without contrib and the same error is appearing. The error always occurs at the line:
Building CXX object modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj
Hi, sorry for the delay. I tried to reproduce your error on my PC, unfortunately without success.
I Downloaded both 3.3.1 and 3.3.0 and it worked as expected.
Have you tried another version, like 3.2 or even 3.0?
Maybe it depends on the mingw-version? Which one do you use Jean?
My
g++ --version
gives:gcc (MinGW.org GCC-6.3.0-1) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
How to include also opencv_extra?
Hi.
It’s explained on the post.
How can I include Python as well?
If you wanna install it, I suggest you using pip (
pip install opencv
).mingw32-make[2]: *** [modules\videoio\CMakeFiles\opencv_videoio.dir\build.make:188: modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dshow.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:2979: modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2
How can I fix that errors?
Hi.
Open the file
\opencv\sources\cmakeOpenCVCompilerOptions.cmake
Comment the line:
add_extra_compiler_option(-Werror=non-virtual-dtor)
with an#
Now it should be
#add_extra_compiler_option(-Werror=non-virtual-dtor)
You are ready to Configure and Generate.
Hi
How can compile 3.4 along with contrib module with java wrapper..thanks
Hi.
Please take a look at this question on OpenCV website, I think it could help you.
Im trying to build using mingw64 and i reach 99% of the building process then an error occurs saying
“No rule to make bin/opencv-340.jar needed…”
This wrapper is something that I’m not too familiar with.
Seems to be something with Ant or your JNI. Try updating or even reinstalling them.
Hi Jean,
No matter what I do the project says it can’t find the library or include files. I built the binaries myself with CMake into a nifty installation, but for some reason it isn’t working.
Hi.
It doesn’t work during the OpenCV installation itself or when you’re trying to code something in Eclipse?
OpenCV installation is like a charm. Its when I try to run a program in Eclipse that it can’t find include/library files. I’ve even hard-coded some includes and it doesn’t find them.
The best thing I can suggest for you is to start the Eclipse config again or try to fix your Project going to
Project > C/C++ Index > Rebuild and Re-Resolve Unresolved Includes, and then left click on your Project folder and select Clean.
I don’t know what happened but I rebuilt the library, making sure Eclipse was pointing to all of the correct libs/bins, made sure all header files were included. Maybe the most important was making sure I had a path in the main system the pointed to both the bin & lib folders. Cleaned out a few paths that weren’t used anymore. And boom, we have launch (except I don’t know where the image/image file is) for demo.
The conversion to 64 bit went well so far. Eclipse Oxygen, OpenCV-3.4.0 and mingw-64 working together.
Spoke too soon. Well, everything is linking fine it seems, not I get a runtime error, crash, for some reason.
Am I supposed to put a .DLL in the executable folder?
Hi,
Usually, if you have linked everything correctly inside Eclipse it should run regardless of having a .dll inside the folder.
Could you show the error?
g++ “-IC:\\opencv_src\\Mingw_build\\install\\include” -O0 -g3 -Wall -c -fmessage-length=0 -o “src\\main.o” “..\\src\\main.cpp”
g++ “-LC:\\opencv_src\\Mingw_build\\install\\x64\\mingw\\lib” -o x64_super_vision_cam_v1.exe “src\\main.o”
src\main.o: In function
main':
cv::imread(cv::String const&, int)’C:\Users\Technologist\Marble\64bit\64bit_HID_camdev\x64_super_vision_cam_v1\Debug/../src/main.cpp:21: undefined reference to
C:\Users\Technologist\Marble\64bit\64bit_HID_camdev\x64_super_vision_cam_v1\Debug/../src/main.cpp:28: undefined reference to
cv::imshow(cv::String const&, cv::_InputArray const&)'
cv::waitKey(int)’ src\main.o: In functionC:\Users\Technologist\Marble\64bit\64bit_HID_camdev\x64_super_vision_cam_v1\Debug/../src/main.cpp:29: undefined reference to
cv::String::String(char const*)':
cv::String::allocate(unsigned long long)’C:/opencv_src/Mingw_build/install/include/opencv2/core/cvstd.hpp:602: undefined reference to
src\main.o: In function
cv::String::~String()':
cv::String::deallocate()’C:/opencv_src/Mingw_build/install/include/opencv2/core/cvstd.hpp:648: undefined reference to
src\main.o: In function
cv::Mat::~Mat()':
cv::fastFree(void*)’C:/opencv_src/Mingw_build/install/include/opencv2/core/mat.inl.hpp:692: undefined reference to
src\main.o: In function
cv::Mat::release()':
cv::Mat::deallocate()’C:/opencv_src/Mingw_build/install/include/opencv2/core/mat.inl.hpp:804: undefined reference to
collect2.exe: error: ld returned 1 exit status
This my output now:
g++ “-IC:\\opencv_src\\Mingw_build\\install\\include” -O0 -g3 -Wall -c -fmessage-length=0 -o “src\\main.o” “..\\src\\main.cpp”
g++ “-LC:\\opencv_src\\Mingw_build\\install\\x64\\mingw\\lib” -o x64_Marble_cam_v1.exe “src\\main.o” -lopencv_core340 -lopencv_shape340 -lopencv_photo340 -lopencv_objdetect340 -lopencv_ml340 -lopencv_imgcodecs340 -lopencv_highgui340 -lopencv_imgproc340 -lopencv_flann340 -lopencv_features2d340 -lopencv_calib3d340
src\main.o: In function
main':
cv::VideoCapture::VideoCapture(int)’C:\Users\Technologist\Marble\64bit\64bit_HID_camdev\x64_Marble_cam_v1\Debug/../src/main.cpp:22: undefined reference to
C:\Users\Technologist\Marble\64bit\64bit_HID_camdev\x64_Marble_cam_v1\Debug/../src/main.cpp:22: undefined reference to `cv::VideoCapture::~VideoCapture()’
Try adding opencv_videoio340 to your MinGW C++ Linker (Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries)
Hi Jean,
I’m having the error in the link while running mingw32-make.
https://drive.google.com/open?id=18bbfkcprkAKpgOUIU8Au1fDL3jSHf-v9
I’m using mingw, eclipse luna and windows 10.
Thanks,
Hi.
Are you using MinGW-w64?
Sorry I haven’t noticed your message before and my problem is not solved yet :/
Yes I installed this version of mingw
https://sourceforge.net/projects/mingw-w64/files/latest/download
I even deleted everything and started from zero with all the versions and the steps that you proposed, I had the same error.
Does your
g++ -v
show 7.1.0 or 7.2.0? I suggest using 7.2.0Yes it shows me 7.1.0, I’ll try 7.2.0 and get back to you, thanks a lot
I upgraded the version of g++, still have the same problem.. I updated the error photo in the link..
https://drive.google.com/open?id=13kbx6k8sDAzhEnIrc1tjz6oCzvCyJ8ml
Thank you..
To solve that error, you need to disable
ENABLE_PRECOMPILED_HEADERS
in CMake and then click Generate.That’s worked Finally! you saved my master degree, thank you 🙂
My program is executing but I still have warning messages, like this one..
#include
#include
Unresolved inclusion:
Unresolved inclusion:
Mat image = Mat::zeros(300,300,CV_8U);
Multiple markers at this line
– Symbol ‘CV_8U’ could not be resolved
– Invalid arguments ‘ Candidates are: cv::MatExpr zeros(cv::Size_, int) cv::MatExpr zeros(int, int, int) cv::MatExpr
zeros(int, const int *, int) ‘
That’s amazing! I’m really happy to know I contributed someway.
Now it’s all about learning how OpenCV works.
In the newer versions, like 3.4, you should use
Mat::zeros(Size size, int type)
Ok, I’ll search the documentation for this, what about “Unresolved inclusion” error, is the inclusions are different also?
#include
#include
This is what I’m putting..
Could you post a screenshot or repost the comment removing its angle brackets (or quotes)? The comment section seems to consider the code between angle brackets and quotes as some HTML tag.
Hi Sir again, I want to build opencv 3.4 with the extra module for java application and i follow your blog and thank you, i wanna ask if what do i need to change in my configurations because this following error occurs everytime:
in cmake this is the red lines:
CMake Warning at C:/opencv3.4/opencv3.4-master/sources/opencv-master/cmake/OpenCVDownload.cmake:190 (message):
data: Download failed: 6;”Couldn’t resolve host name”
CMake Warning at C:/opencv3.4/opencv3.4-master/sources/opencv_contrib-master/modules/face/CMakeLists.txt:26 (message):
Face: Can’t get model file for face alignment
////////////////////////////
in mingw32 this are the errors:
1st error:
mingw32-make[2]:*** No rule to make target ‘bin/opencv-340.jar’, needed by java_test/bin/opencv-340.jar. Stop.
mingw32-make[1] *** [CMakeFiles\Makefile2:14109: modules/java/test/pure_test?CMakeFiles/opencv_test_java.dir/all]Error 2
mingw32-make : *** [Makefile : 162 all] Error 2
2nd error:
mingw32-make[2]: *** [modules\xfeatures2d\CMakeFiles\opencv_xfeatures2d.dir\build.make:93:modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/bosstdesc.cpp.obj]Error1
mingw32-make[1] *** [CMakeFiles\Makefile2:7308:modules/xfeatures2d/CmakeFiles/mingw32-mak: ***[Makefile:16:all] Error 2
3rd Error:
Error occured during initialization of VM
Too small initial heap
mingw32-make[2]: *** [modules\java\jar\CMakeFiles\opencv_java_jar.dir\build.make:61 CmakeFiles/dephelper/opencv_java_jar] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:8181: modules/java/jar/CmakeFiles/opencv_java_jar.dir/all] Error 2
mingw32-make: *** [MakeFile: 162: all] Error 2
THANK YOU IN ADVANCE
Hi Jean,
I followed the steps you have mentioned. Build is done successfully 🙂 Thanks for your detailed steps!!!
When i run the code, i am unable to view the Image.
The code is running inside this if loop, I can see on the output window the cout message.
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
The image is copied inside the project, Is this should be placed anywhere?
I found out, there should be an argument provided in Profile configuration. Working perfectly now 🙂
mingw32-make[2]: *** [modules\coreI\CMakeFiles\opencv_core.dir\build.make:1844: bin/libopencv_core340.dll] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1655: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2
I’m getting this error when linking cxx shared library. I’m using windows 10, any idea on how to fix this?
Could you show the error with a screenshot/message of the last 10 lines or so of your mingw32-make command?
Hi Jean,
I am trying to play an video from the file, below is the code snippet
#include
#include
#include
#include
#include
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
//open the video file for reading
VideoCapture cap(“D:\Personal\workspace\OCV\solidYellowLeft.mp4”);
// if not success, exit program
if (cap.isOpened() == false)
{
cout << "Cannot open the video file" << endl;
cin.get(); //wait for any key press
return -1;
}
//get the frames rate of the video
double fps = cap.get(CAP_PROP_FPS);
cout << "Frames per seconds : " << fps << endl;
String window_name = "solidYellowLeft";
namedWindow(window_name, WINDOW_NORMAL); //create a window
while (true)
{
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video
if (bSuccess == false)
{
cout << "Found the end of the video" << endl;
break;
}
imshow(window_name, frame);
if (waitKey(10) == 27)
{
cout << "Esc key is pressed by user. Stoppig the video" << endl;
break;
}
}
return 0;
}
Facing undefined reference linking error:
D:\Personal\workspace\OCV\Debug/../display.cpp:86: undefined reference to
cv::VideoCapture::VideoCapture(cv::String const&)'
cv::VideoCapture::isOpened() const'D:\Personal\workspace\OCV\Debug/../display.cpp:89: undefined reference to
D:\Personal\workspace\OCV\Debug/../display.cpp:100: undefined reference to
cv::VideoCapture::get(int) const'
cv::VideoCapture::read(cv::_OutputArray const&)'D:\Personal\workspace\OCV\Debug/../display.cpp:110: undefined reference to
D:\Personal\workspace\OCV\Debug/../display.cpp:86: undefined reference to
cv::VideoCapture::~VideoCapture()'
cv::VideoCapture::~VideoCapture()'D:\Personal\workspace\OCV\Debug/../display.cpp:86: undefined reference to
D:\Personal\workspace\OCV\Debug/../display.cpp:86: undefined reference to `cv::VideoCapture::~VideoCapture()'
Can you help me to resolve this error?
Try adding opencv_videoio340 to your MinGW C++ Linker (Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries)
linking error is resolved now.
But there is new error, cannot open output file OCV.exe -> permission denied
20:58:59 **** Rebuild of configuration Debug for project OCV ****
Info: Internal Builder is used for build
g++ “-ID:\\Personal\\opencv_3.4\\opencv\\mingw_build_3.4\\install\\include” -O0 -g3 -Wall -c -fmessage-length=0 -o display.o “..\\display.cpp”
..\display.cpp: In function ‘int main(int, char**)’:
..\display.cpp:87:19: warning: unknown escape sequence: ‘\P’
VideoCapture cap(“D:\Personal\workspace\OCV\solidYellowLeft.mp4”);
^
..\display.cpp:87:19: warning: unknown escape sequence: ‘\w’
..\display.cpp:87:19: warning: unknown escape sequence: ‘\O’
..\display.cpp:87:19: warning: unknown escape sequence: ‘\s’
g++ “-LD:\\Personal\\opencv_3.4\\opencv\\mingw_build_3.4\\install\\x64\\mingw\\lib” -o OCV.exe display.o -llibopencv_calib3d340 -llibopencv_videoio340 -llibopencv_video340 -llibopencv_core340 -llibopencv_features2d340 -llibopencv_flann340 -llibopencv_highgui340 -llibopencv_imgcodecs340 -llibopencv_imgproc340 -llibopencv_ml340 -llibopencv_objdetect340 -llibopencv_photo340 -llibopencv_shape340
C:/Tools/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file OCV.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
20:59:01 Build Finished (took 1s.740ms)
I understand that if an .exe file is running it will not allow to rebuild it.
After killing it, it has resolved and compilation is through.
I am unable to play the video, it is failing to read the video and executing the below code
// if not success, exit program
if (cap.isOpened() == false)
{
cout << "Cannot open the video file" << endl;
cin.get(); //wait for any key press
return -1;
}
any idea?it would be really great if you can provide me the solution for this.
Hi.
I’m glad to know you’re making progress! Have you tried changing the file path
"D:\Personal\workspace\OCV\solidYellowLeft.mp4"
toD:\\Personal\\workspace\\OCV\\solidYellowLeft.mp4
?I tried with changing the path, doesn’t help still with same progress 🙁
Hi Jean,
I tried lots of options, I added ffmpeg_64.dll into my c++ settings. Still my videocapture is not working with opencv 3.4.0.
Is any configuration am i missing with still…?
I tried this code here on my pc and worked just fine:
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
//open the video file for reading
VideoCapture cap("E:\\Downloads\\FMAB_Ridler182_GOM_01.mkv");
// if not success, exit program
if (cap.isOpened() == false)
{
cout <<"Cannot open the video file"; cin.get(); //wait for any key press return -1; } else { cout << "Success"; } }
Try the following steps: (you might have already tried them, but I suggest you following it again with attention)
1 - Check if your
C:\opencv\install\x64\mingw\bin
folder has a file namedopencv_ffmpeg340_64.dll
. If not, try recompiling your OpenCV with the option WITH_FFMPEG checked in CMake;2 - Confirm if your
C:\opencv\install\x64\mingw\bin
is added to your system PATH (The SYSTEM path not only for the USER);3 - Check if
C:\opencv\install\x64\mingw\bin
is added on your Project's Library Search Path (Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries).Hi Jean,
I found that there is no opencv_ffmpeg340_64.dll is not there in the D:\Personal\opencv_3.4\opencv\mingw_build_3.4\install\x64\mingw\bin folder.
I reconfigured the cmake, but its till not generating into that folder.
Did you see any OpenCV compiling/configuring/installing errors or warnings related to opencv_ffmpeg ? If yes, could please post them?
Line 396: FFMPEG: Download: opencv_ffmpeg_64.dll
Line 396: FFMPEG: Download: opencv_ffmpeg_64.dll
Line 404: FFMPEG: Download failed: 6;”Couldn’t resolve host name”
Line 411: 3rdparty/ffmpeg/ffmpeg.cmake:20 (ocv_download)
Line 411: 3rdparty/ffmpeg/ffmpeg.cmake:20 (ocv_download)
Line 412: cmake/OpenCVFindLibsVideo.cmake:218 (download_win_ffmpeg)
Well, let’s try something manual then.
1 – Download opencv_ffmpeg_64.dll, opencv_ffmpeg.dll , and ffmpeg_version.cmake from https://github.com/opencv/opencv_3rdparty/tree/ffmpeg/master_20170418/ffmpeg
2 – Delete your older OpenCV source folder and re-extract the files
3 – Now, you will manually create the folders C:\opencv-3.4.0\.cache\ffmpeg
5 – Paste opencv_ffmpeg_64.dll, opencv_ffmpeg.dll , and ffmpeg_version.cmake inside the folder you just created ( C:\opencv-3.4.0\.cache\ffmpeg)
6 – Go to C:\opencv-3.4.0\3rdparty\ffmpeg\ffmpeg.cmake and open it. You will see something like this in the first lines:
# Binary branch name: ffmpeg/master_20171009
# Binaries were created for OpenCV: 8ac2c5d620b467d3f22802e96c88ddde6da707af
set(FFMPEG_BINARIES_COMMIT "66b1fed06cf3510235f367f96aa26da5cb234a15")
set(FFMPEG_FILE_HASH_BIN32 "3ae76b105113d944984b2351c61e21c6")
set(FFMPEG_FILE_HASH_BIN64 "cf3bb5bc9d393b022ea7a42eb63e794d")
set(FFMPEG_FILE_HASH_CMAKE "ec59008da403fb18ab3c1ed66aed583b")
[...]
Copy the hash numbers (that might be different) in front of the of FFMPEG_FILE flags and rename your files inside C:\opencv-3.4.0\.cache\ffmpeg to match the following format:
NUMBERS-fileName.dll
the opencv_ffmpeg.dll must use the FFMPEG_FILE_HASH_BIN32 hash, making its new name:
3ae76b105113d944984b2351c61e21c6-opencv_ffmpeg.dll
for opencv_ffmpeg_64 copy the value of FFMPEG_FILE_HASH_BIN64
cf3bb5bc9d393b022ea7a42eb63e794d-opencv_ffmpeg_64.dll
and finally FFMPEG_FILE_HASH_CMAKE for your your ffmpeg_version.cmake
ec59008da403fb18ab3c1ed66aed583b-ffmpeg_version.cmake
Now you are good to follow the installation tutorial. I Hope it works, Good Luck!
I tried it … now it is coming as terminated OCV.exe. Video is still unable to play.
Should i add the opencv_ffmpeg340_64.dll into project->properties->MINGW C++ Linker-> Library?
You could try, but I don’t think it will make any difference.
The problem you have been describing usually happens because of ffmpeg, and since you said that your folder doesn’t have it, that may be something related to your CMake/Network.
What about trying OpenCV 3.3/3.2/3.0 or even another CMake version? (Here I have been using 3.9.1)
Hello again Sir..im able to build opencv3.4 with contrib module but when im trying to add it to my Netbeans project im getting this error:
Excep
tion in thread “main” java.lang.UnsatisfiedLinkError: no opencv_340 in java library path
I tried to add the path of the generated libopencv_340.dll in the vm options of my project and im still getting this error..i already follow the solutions provided in the blog of Mr.Zamrath Nizam..what should i do..Thank you
Have you tried this one https://www.codeproject.com/Tips/717283/How-to-use-OpenCV-with-Java-under-NetBeans-IDE ?
Yes Sir i have already tried it, still it doesn’t resolve the error, and im just confused why im my build directory there are two libopencv_340.dll first is in the bin folder and the other one is in the install folder in java subdirectory..Which file shoud i use.Thank you again.
All the files needed for installation are copied from your source folder to your installation folder. So, they are the same, however, you must use the one inside the Install folder.
Sir it still occurs..can you provide me a zip file of opencv with extra modules that works perfectly..i really need it..Thanks just send it to my email at tvmagallano@gmail.com..thank you
while building the files, dnn module showed an error relating to temp in my system. Then in Cmake, i deselected the build_opencv_dnn, it worked even with opencv_contrib.
Hi,
Glad it worked for you! Thank you for the additional info.
The only problem is… Well, you won’t be capable of using dnn if you need it.
Hi,
I got an error after running mingw32-make. The error photo is in the link
https://drive.google.com/open?id=1zOWbPAGXS9mNBO2RjAQHh0HU25fXDnlu
Thank You,
Hi
1 – Go to OpenCV source folder
2 – Go to Cmake Folder
3 – Locate the file named “OpenCVCompilerOptions.cmake”
4 – Comment the line
add_extra_compiler_option(-Werror=non-virtual-dtor)
So it should become
#add_extra_compiler_option(-Werror=non-virtual-dtor)
5 – Configure and generate again
Hi Jean,
Build and compile appear ok. Need a test image, how do I?
Usage: display_image ImageToLoadAndDisplay
Hi,
Is everything working properly now?
Yes —
To make it work, I had to add the pointer to file_path and the include that in the location of argv:
char* file_path = “C://marble_win_development//x64_opencv_test//src//Lenna.jpg”;
Mat image;
image = imread(file_path, CV_LOAD_IMAGE_COLOR);
Did I miss the point here? I’m mainly a int main(){} guy, so the int main( int argc, char** argv ) drives me batty : )
Did I make unnecessary adjustments? I tried as is with Jenna.jpg in the source file folder with main.cpp, but wouldn’t show.
Well, let’s say you did, but I think that’s my fault.
I have read the tutorial again and it’s not completely clear about what you need to do to run the code properly.
Anyway, I’ll fix it, because you need to call the .exe file with the name of the image, e. g:
yourprogram.exe lenna.jpg
Thank you for making me notice this 🙂
All the best.
BTW, great tutorial.
closing remarks: Debug>x64_opencv_test2.exe Lenna.jpg works perfectly with yourprogram.exe lenna.jpg.
I can only get it to work with the shell by navigating to the directory. My IDE (Eclipse) has yourprogram.exe side by side in the same directory with lenna.jpg, but doesn’t work; can’t find it. That’s more my issue than yours. Later.
Hi Jean, have to reinstall, not related to your instructional. Which BIN is it?
C:\ MingW64\BIN\ or C:\MinGW64\x86_64-w64-mingw32\BIN ?? can’t recall
I mean the PATH that you said we need to add once MinGW installed.
Hi again! Hope you are doing fine.
Here I have been using: C:\mingw64\bin
Instead of calling “mingw32-make” you should add “-j” as an argument, so it will use all the available cores on your system and significantly increase the build process. You can also define the number of cores used: “mingw32-make -j4”
Hi Jean,
I have followed your instruction above, but I got the error as shown in the link below:
https://www.dropbox.com/s/nmh3itf9d7tdeqr/Error%20Message.png?dl=0
Can you please look at it and let me know how can I fix this error?
Thanks.
Hi,
Please try to compile again after unchecking all BUILD_TESTS options on the CMAKE Gui.
Hi Jean,
After disable BUILD_TEST option, I got the new error:
https://www.dropbox.com/s/b5z1zlvw0tyr2tl/Error%20Message%201.png?dl=0
Can you please to solve this issue?
Thanks.
Hi,
Now also uncheck BUILD_PERF_TESTS
Hi Jean,
It leads to another error message:
https://www.dropbox.com/s/g0b3squnl5bn69t/Error%20Message%202.png?dl=0
Please help again. Thanks.
Hi again Ganuco,
Glad you’re making progress.
I wont be home for the next few days or so, it will be somewhat difficult to search for solutions. Either way, let’s try to fix that.
By now, I suggest you to restart the entire process all over again, leaving all the EXAMPLES and TESTS directives on CMAKE unchecked.
Good luck!
I have tried to restart the entire process, but it still fail. Please let me know the new solution when you come back. Thanks.
The last line that appears before the error still related to opencv_stitching? If yes… well… try to uncheck BUILD_opencv_stitching.
A
Hi Jean,
I am still get the error:
https://www.dropbox.com/s/w0p2yvgoectym31/Error%20Message%203.png?dl=0
Please help. Thanks.
Hi Ganuco,
Try adding DCPU_DISPATCH= option to cmake. This is a known error for some CPU’s.
I do think that has been fixed on the latest versions (3.4.3, there’s a download link in the article).
So even if the cmake option does not work, switching to 3.4.3 would probably fix that.
bem completo, vou testar.
Voce sabe se é possivel usar a biblioteca sem usar o lib ou as dll? Quero portar o código para um microcontrolador ARM. Obrigado!
E aí! Sempre bom ver brasileiros por aqui!
Cara, a única experiência que eu tenho com ARM e OpenCV é para o Raspberry Pi. Para um microncontrolador seria novidade para mim, acredito eu que tenha soluções mais adequadas do que o OpenCV. ( se descobrir, me conte 🙂 )
As libs e dlls são componentes gerados por conta da compilação para Windows e de fato são essenciais para funcionar, ao menos no Windows.
é uma fase do meu projeto final, eu estou tentando rodar no pc seguindo seu tutorial, já que ja fizemos a camerar rodar como webcam(integrada com microcontrolador) numa primeira fase e meu parceiro esta tentando fazer rodar no pc mas somente incluindo os arquivos fonte da biblioteca sem compilar com o cmake, sem usar as bibliotecas estaticas ou dinamicas, isso não é possivel mesmo?
Outra coisa, eu compilei com o cmake mas nao apareceu a pasta install mas apareceu C:\opencv_src\Mingw_build\bin e C:\opencv_src\Mingw_build\win-install(que não possui a pasta bin) e dai eu travei na parte de incluir a pasta C:\opencv_src\Mingw_build\install, devo recompilar ou adiciono uma dessas pastas?
A pasta install nao foi criada por aqui, somenta win-install mas aparentemente sem nada dentro, somente uns arquivos do cmake, eu perdi algum passo?
Sim, ficou algum passou faltando aí, sugiro dar um double-check em tudo.
Hi, the build process without the contrib moduls worked fine, but I definitely need these extra packages.
I use mingw-w64 version 8.1.0, CMake 3.12.2, opencv 3.2 and opencv 3.4.1.
I did the installation with both opencv versions, but always got errors.
The warning in CMake is
“CMake Warning in CMakeLists.txt:
The build directory is a subdirectory of the source directory.
This is not supported well by Eclipse. It is strongly recommended to use a
build directory which is a sibling of the source directory.”
The error when I build it with mingw32-make is:
“C:\opencv_src\modules\videoio\src\cap_msmf.cpp: In instantiation of ‘void {anonymous}::ComPtr::Release() [with T = IMF2DBuffer]’:
C:\opencv_src\modules\videoio\src\cap_msmf.cpp:170:9: required from ‘HRESULT {anonymous}::ComPtr::As({anonymous}::ComPtr&) const [with U = IMF2DBuffer; T = IMFMediaBuffer; HRESULT = long int]’
C:\opencv_src\modules\videoio\src\cap_msmf.cpp:1271:17: required from here
C:\opencv_src\modules\videoio\src\cap_msmf.cpp:162:13: error: using invalid field ‘{anonymous}::ComPtr::p’
if (p)
^
C:\opencv_src\modules\videoio\src\cap_msmf.cpp:163:13: error: using invalid field ‘{anonymous}::ComPtr::p’
p.Release();
^
cc1plus.exe: some warnings being treated as errors
mingw32-make[2]: *** [modules\videoio\CMakeFiles\opencv_videoio.dir\build.make:189: modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_msmf.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:4420: modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2”
And can you tell me the steps for the contrib modules in detail, do I have to configure opencv first without extra packages, then add the extra modules path and configure again or just hit the generate button then?
Thank you!
Hi Mario!
This CMake warning happens because of how the folders are organized. Don’t worry about it (if you wanna change the build directory to outside the OpenCV source folder, that warning will disappear)
About the Opencv_contrib, please make sure to download the right version (the one that matches OpenCV’s). To install it, as mentioned in the tutorial, After the “Configure” is finished, Set OPENCV_EXTRA_MODULES_PATH to opencv_contrib/modules folder.
Hi Jean,
Thank you for the answer! I did it again with opencv 3.4.1 and opencv contrib 3.4.1 and followed the tutotrial steps with including the extra modules path, but again got the error at 62% of the build process.
Do you have any other tips for me? Do I have to uncheck more options in CMake or how du I have to configure the mingw installation for example?
Hi Jean,
I tried it again with opencv 3.4.3 and opencv contrib 3.4.3 and just got errors with the videoio module.
After unchecking it the build process ended with 100% success, the problem is I need the videoio module.
Do you have tips for these videoio module errors?
Hi, sorry for the delay.
Could you please show a screenshot of the error?
(I suggest you to try checking if the extra modules path is set to /opencv_contrib/modules
Also, you can try to enable/disable ENABLE_CXX11 and/or INSTALL_C_EXAMPLES)
Hi jean,
I’m having the error in the link while running mingw32-make
http://i66.tinypic.com/201gk5.png
please give me fast reply.
Thanks..!!
Hi Jean,
I am trying to use OPENCV 4.0 in eclipse,
I made configure and generate in CMake.
When i use the commmand mingw32-make with the directory path, i am facing the errors.
I have deselected the Prebuild actions and Build Python
Can you kindly help me out, Thanks in advance!
Hi Naveem,
I have not tried OpenCV 4 yet.
I will explain how to install and use it in a post very soon.
Best,
Jean.
Hi Jean,
Thanks a lot for your reply.
Waiting for your post very soon. Since i am not able to proceed further.
BR,
Naveen.
i found that when videoio module is trying to build, the build is failing.
Is it something i should download additionally or shall i exclude this module from the build.
I am posting the error from the module videoio
E:\opencv_ext_4.0\opencv\sources\modules\videoio\src\cap_msmf.cpp: In instantiation of ‘void {anonymous}::ComPtr::Release() [with T = IMF2DBuffer]’:
E:\opencv_ext_4.0\opencv\sources\modules\videoio\src\cap_msmf.cpp:175:9: required from ‘HRESULT {anonymous}::ComPtr::As({anonymous}::ComPtr&) const [with U = IMF2DBuffer; T = IMFMediaBuffer; HRESULT = long int]’
E:\opencv_ext_4.0\opencv\sources\modules\videoio\src\cap_msmf.cpp:1276:17: required from here
E:\opencv_ext_4.0\opencv\sources\modules\videoio\src\cap_msmf.cpp:167:13: error: using invalid field ‘{anonymous}::ComPtr::p’
if (p)
^
E:\opencv_ext_4.0\opencv\sources\modules\videoio\src\cap_msmf.cpp:168:13: error: using invalid field ‘{anonymous}::ComPtr::p’
p.Release();
^
mingw32-make[2]: *** [modules\videoio\CMakeFiles\opencv_videoio.dir\build.make:263: modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_msmf.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:2506: modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2
Hello Jean,
i am using OPENCV 4 which is latest using ECLIPSE.
i am done with the configure and generate using CMAKE.
But getting error when i run mingw32-make command.
I get mingw32-make *** all error 2 too. when mingw32-make is up to 65% and buinding detection_based_tracker. My mingw32 version is same as Jean’s, I unchecked Enable_Precompiles_header and CXX thing. My system is windows 7 64bit, and tried both 3.4.0, 3.3.0 … any suggestions? :<..
I know this article is over a year old now, but just in case anyone else has this issue, I figured I would post:
After downloading OpenCV 3.4 (note that 4.x versions tried did NOT work), I was able to get it to work with MinGW-w64 8.1.0 [g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0].
However, I found the Eclipse setup showed “Cross Compiler” instead of GCC Compiler, and when I tried to build the project in Eclipse I got an error “Program ‘make’ not found in PATH” and the build fails.
In order to correct this, I had to go to Preferences >> C\C++ Build >> Tool Chain Editor >> Change Current toolchain to MinGW GCC.
See corresponding steps in this Stackoverflow for screenshots:
https://stackoverflow.com/questions/11579135/program-make-not-found-in-path/40727977
Hi Jean
I am at this step: “Inside opencv_src/Mingw_build type mingw32-make and hit enter”; I get the following error:
C:\mingw64\bin\windres.exe: unknown option — W
Usage: C:\mingw64\bin\windres.exe [option(s)] [input-file] [output-file]
The options are:
-i –input= Name input file
-o –output= Name output file
-J –input-format= Specify input format
-O –output-format= Specify output format
-F –target= Specify COFF target
–preprocessor= Program to use to preprocess rc file
–preprocessor-arg= Additional preprocessor argument
-I –include-dir= Include directory when preprocessing rc file
-D –define [=] Define SYM when preprocessing rc file
-U –undefine Undefine SYM when preprocessing rc file
-v –verbose Verbose – tells you what it’s doing
-c –codepage= Specify default codepage
-l –language= Set language when reading rc file
–use-temp-file Use a temporary file instead of popen to read
the preprocessor output
–no-use-temp-file Use popen (default)
-r Ignored for compatibility with rc
@ Read options from
-h –help Print this help message
-V –version Print version information
FORMAT is one of rc, res, or coff, and is deduced from the file name
extension if not specified. A single file name is an input file.
No input-file is stdin, default rc. No output-file is stdout, default rc.
C:\mingw64\bin\windres.exe: supported targets: pe-x86-64 pei-x86-64 pe-bigobj-x86-64 elf64-x86-64 elf64-l1om elf64-k1om pe-i386 pei-i386 elf32-i386 elf32-iamcu elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
mingw32-make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:1004: modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:2304: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Your help would be appreciated.
Joe