Hi,
I’ve searched for tutorials explaining how to install and configure OpenCV 2.4.9 with Cmake, using Visual Studio 2013, but I haven’t found any good ones. As a result, I’ve decided to create my own tutorial, where I explain how to build the OpenCV solution using Cmake and how to create applications in Visual Studio 2013 that use OpenCV. Note that my laptop is running Windwos 8.1.
Here is the tutorial:
The tutorial summarizes the following steps:
- Downloading and extracting OpenCV.
- Downloading and installing Cmake.
- Building OpenCV using Cmake.
- Creating applications in Visual Studio 2013 that use OpenCV.
As promised, I’ve uploaded the sample code that I used as an example application:
#include “stdafx.h”
#include “opencv2/highgui/highgui.hpp”
#include <iostream>using namespace cv;
using namespace std;int main(int argc, char* argv[])
{
VideoCapture cap(0); // open the video camera no. 0if (!cap.isOpened()) // if not success, exit program
{
cout << “Cannot open the video file” << endl;
return -1;
}double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the videocout << “Frame size : ” << dWidth << ” x ” << dHeight << endl;
namedWindow(“MyVideo”, CV_WINDOW_AUTOSIZE); //create a window called “MyVideo”
Mat frame;while (1)
{
bool bSuccess = cap.read(frame); // read a new frame from videoif (!bSuccess) //if not success, break loop
{
cout << “Cannot read a frame from video file” << endl;
break;
}imshow(“MyVideo”, frame); //show the frame in “MyVideo” window
if (waitKey(30) == 27) //wait for ‘esc’ key press for 30ms. If ‘esc’ key is pressed, break loop
{
cout << “esc key is pressed by user” << endl;
break;
}
}
return 0;
}
If you have any question, please comment on this post and I’ll be glad to help.
Gil.
Many thanks, man ) This video is very useful.
I still have problems 😦
error LNK1181: cannot open input file ‘opencv_highgui2410.lib’
Hi,
Please send me and email to gil.levi100@gmail.com with some more details and I’ll help you as best as I can.
Gil.
i have a windows 8 and the system properties said its a 64 bit but when i ran your program, visual studio is giving me this error:
Error 1 error LNK1112: module machine type ‘x64’ conflicts with target machine type ‘X86’
also, im using visual studio community 2013. thanks!
Hi Jen,
In VS there’s a toolbar with a button that says “Local Windows Debugger”. Next to it, there are two menus – in the first you select between release and debug and in the second you select between architectures (x64 and x86). Have you changed the architecture to x64?
If you problem persists, please send me a screenshot to gil.levi100@gmail.com and I’ll try to help.
Best,
Gil.
Hi,
I get the same error as Sounhi
LINK : fatal error LNK1181: cannot open input file ‘opencv_highgui2411.obj’
Could you please help me.
Thanks,
Hi,
Please send me and email to gil.levi100@gmail.com with some more details and I’ll help you as best as I can.
Gil.
Hi ,
Thank you so much for your tutorial and excellent explanations.
I’m doing a project of using markerless (Natural Image) for Augmented reality Coloring Book apps for mobiles.
My question is which features descriptors you suggest for me to use?
Thanks in advance.
Aziz
Hi,
Thank you for your interest in my blog.
It would be easier to answer if you could send me some example images to my mail and explain the application and running time/memory requirements.
You can mail me at gil.levi100@gmail.com.
Best,
Gil.
Hello how are you?
I’m having problems with the C code … when I copy and paste the visual studios it appears with several errors. The commands are underlined in red.
Could you pass me the code as a file or somehow that it is avoided?
thank you
Note: I am Brazilian and this tutorial is helping me a lot
Hi Luiz,
Thank you for your interest in my post.
Please mail me at gil.levi100@gmail.com with the error description and the code and I’ll do my best to help.
Best,
Gil
Hi i have a question, I do not have nearly the same amount of .dll and .lib files as shown on your video; particularly the OPENCV_HIGHGUI.
Also the portion of the video where you changed a directory and the errors on the code disappeared, that did not work for me.
Please help if you can.
My email is danlarsen@live.com
Hi Daniel,
Please mail me at gil.levi100@gmail.com with the code and I’ll try to help.
Best,
Gil.
Excellent video.. Thank you so much,,,
I am starting an image processing application and I can’t decide between using c++ or c#.. It’s basically image enhancements and classifications.. I have basic c++ knowledge.. Never dealt with pointers or memory management.. Any advice much much appreciated..
Hi,
Thank you for your interest in my blog.
What about Python? it’s super easy, development is much faster (you don’t have to worry about memory management), it’s cross platform and there are many available machine learning and deep learning packages available in Python.
Best,
Gil
Hi Gil! That’s a really great article! I’m not a fan of this kind of articles, but I actually enjoyed reading this one. My friend has written a similar article, check it out and let me know what do you think! http://blog.zaven.co/opencv-in-android-studio-project/
Thanks. Looks good!
Thanks for checking it! Hope that all the vocabulary is used properly, because I was translating it! 🙂
Hi Gill,
i have installed opencv 3.1.0 c++ using cmake.But after installation highgui module is missing. Can you please tell what could be the reason and how to get it correct.
After compiling a program in codeblocks it shows following error-
C:\Users\Lipi\Desktop\blur.cpp|7|fatal error: opencv2/highgui.hpp: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
thanx in advance.
Hi,
Can you please send me an email with the CodeBlock project files? My email is gil.levi100@gmail.com
Best,
Gil