简体   繁体   English

OpenCV无法编译

[英]OpenCV can't compile

I'm a newbie OpenCV user. 我是新手OpenCV用户。 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). 不幸的是,我可以找到很多有关openCV的教程,但是它们对我不起作用(有时是因为它们使用的是旧版本)。

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. 我尝试编译(Visual Studio 2010),但出现类似150-250的错误。 I'm new to Visual Studio and I can't understand really well "him" and what he "doesn't like". 我是Visual Studio的新手,我不太了解“他”和他“不喜欢”什么。 I'm learning how to move inside the IDE but's its hard. 我正在学习如何在IDE中移动,但很难。

The errors refers to imgproc.hpp miniflann.hpp photo.hpp tracking.hpp and report a lot of undefined identifiers and syntax errors. 该错误涉及imgproc.hpp miniflann.hpp photo.hpp tracking.hpp,并报告许多未定义的标识符和语法错误。

I have some experience in programming (C with Arduino, Java, Assembly) but I found the openCV documentation very confusing and confused. 我有一些编程经验(使用Arduino,Java,Assembly进行编程),但是我发现openCV文档非常令人困惑和困惑。 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. 我是自学成才的,所以对入门的任何帮助将不胜感激,我的目标是在我的2WD机器人中实现Coputer视觉(如果可能,则为立体声)。

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) 我可以找到很多有关openCV的教程,但它们对我不起作用(有时是因为使用的是旧版本)

I'm new to Visual Studio and I can't understand really well "him" and what he "doesn't like". 我是Visual Studio的新手,我不太了解“他”和他“不喜欢”什么。 I'm learning how to move inside the IDE but's its hard. 我正在学习如何在IDE中移动,但很难。

I recommend you to have a look at these materials (created by prof. William Hoff , Computer Vision, Colorado School of Mines ): 我建议您看一下这些材料(由科罗拉多矿业大学计算机视觉的 William Hoff教授创建):
Creating Your First Program in Microsoft Visual C++ and 在Microsoft Visual C ++
Using OpenCV in Microsoft Visual C++ 在Microsoft Visual C ++中使用OpenCV

Also note that binary form of OpenCV is specific for a concrete version of Visual Studio. 另请注意,OpenCV的二进制形式特定于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 . 因此,例如,如果您有... \\ OpenCV \\ build \\ x86 \\ vc10 ,则意味着它应与Visual Studio 2010一起使用。 I was using OpenCV with Visual Studio 2012 recently and I had to compile it on my own. 我最近在Visual Studio 2012中使用了OpenCV,必须自己编译。

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!) 假设您已在PC上正确安装了OpenCV并按需设置了IDE,则需要在代码中包含更多库...尝试将其添加到代码的顶部(我有OpenCV 3.1版和此代码为我工作...我也是新手!)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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