简体   繁体   中英

OpenCV can't compile

I'm a newbie OpenCV user. I'm just trying to learn something about it but I don't know where to start.

Unfortunately I can find a lots of tutorials about openCV but they doesn't work for me (sometime because of the old version they used).

So before really starting I'd like to see if the environment is working fine to avoid wasting time in the future. Here is an example I found:

#include <opencv\cv.h>
#include <opencv\highgui.h>

using namespace cv;

int main()
{
    //create an image to store the video screen grab
    Mat image;

    //setup the video capture method using the default camera
    VideoCapture cap;
    cap.open(0);

    //create the window that will show the video feed
    namedWindow("VideoCaptureTutorial", 1);

    //create a loop to update the image with video camera image capture
    while(1)
    {
        //grad a frame from the video camers
        cap>>image;

        //show the image on the screen
        imshow("VideoCaptureTutorial", image);

        //create a 33ms delay
        waitKey(33);
    }

    return 0;
}

I try to compile (Visual studio 2010) But I get something like 150-250 errors. I'm new to Visual Studio and I can't understand really well "him" and what he "doesn't like". I'm learning how to move inside the IDE but's its hard.

The errors refers to imgproc.hpp miniflann.hpp photo.hpp tracking.hpp and report a lot of undefined identifiers and syntax errors.

I have some experience in programming (C with Arduino, Java, Assembly) but I found the openCV documentation very confusing and confused. I'm self taught so any help about how to start would be appreciated, my goal is to implement Coputer vision (stereo if possible) into my 2WD robot.

Thanks

It's impossible to tell you what to do to make your program work, since you haven't provided almost any information that would help to understand the cause of your problem. But after reading these lines:

I can find a lots of tutorials about openCV but they doesn't work for me (sometime because of the old version they used)

I'm new to Visual Studio and I can't understand really well "him" and what he "doesn't like". I'm learning how to move inside the IDE but's its hard.

I recommend you to have a look at these materials (created by prof. William Hoff , Computer Vision, Colorado School of Mines ):
Creating Your First Program in Microsoft Visual C++ and
Using OpenCV in Microsoft Visual C++

Also note that binary form of OpenCV is specific for a concrete version of Visual Studio. So for example if you have ...\\OpenCV\\build\\x86\\ vc10 that means that it is meant to be used with Visual Studio 2010 . I was using OpenCV with Visual Studio 2012 recently and I had to compile it on my own.

Assuming that you have installed OpenCV correctly on you PC and have set up the IDE as you should, you need to include more libraries in your code... Try adding this to the top of your code(I have OpenCV version 3.1 and this code works for me... And I'm a newbie too!)

#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM