[Mo] A rough explanation of errors caused by opencv header files

Source: Internet
Author: User

One of the many problems encountered by beginners of opencv is that errors often occur when the # include opencv header file. The program is easy to understand. Anyone who understands opencv knows that the program has no errors, but compilation is a lot of errors, that is, the header file cannot be found.

Fatal error c1083: Unable to open include file: "CV. h ": no such file or directoryfatal error c1083: Unable to open include file:" highgui. H ": no such file or directory ......

This is a common mistake. It is very likely that it is a file (the path of cv. h and highgui. H is incorrectly set ). Opencv Versions later than 2.2 <opencv root> include have two folders: opencv and opencv2. From the official point of view, it gradually prefers the method containing header files in opencv2.

Note: <opencv root> is the installation path of opencv2.2. Each person's path may be different !!


Interpretation of a: opencv (C: \ OpenCV-2.2.0 \ vs2008 \ include \ opencv) What is in this folder?


CV. h highgui. H is not familiar? If you want to use # include "CV. h ", make sure that the path when you configure the compiler to include files is: C: \ OpenCV-2.2.0 \ vs2008 \ include \ opencv. Because cv. H is in c: \ OpenCV-2.2.0 \ vs2008 \ include \ opencv. This is better than a blogger in China. You have to go to Africa and call my name to find me. It's strange to find me! (For compiler configuration, click here)

If you fill in c: \ OpenCV-2.2.0 \ vs2008 \ include \ In the compiler configuration, you must do this when calling cv. h:

#include “opencv/cv.h”

Interpretation 2: opencv2 (C: \ OpenCV-2.2.0 \ vs2008 \ include \ opencv2) What is in this folder?


Opencv. HPP is a header file that contains all the header files of opencv. There is a picture with the truth:

#ifndef __OPENCV_ALL_HPP__#define __OPENCV_ALL_HPP__ #include "opencv2/core/core_c.h"#include "opencv2/core/core.hpp"#include "opencv2/flann/flann.hpp"#include "opencv2/imgproc/imgproc_c.h"#include "opencv2/imgproc/imgproc.hpp"#include "opencv2/video/tracking.hpp"#include "opencv2/video/background_segm.hpp"#include "opencv2/features2d/features2d.hpp"#include "opencv2/objdetect/objdetect.hpp"#include "opencv2/calib3d/calib3d.hpp"#include "opencv2/ml/ml.hpp"#include "opencv2/highgui/highgui_c.h"#include "opencv2/highgui/highgui.hpp"#include "opencv2/contrib/contrib.hpp" #endif


In addition, folders are used. Each folder is a header file. So if you configure the compiler to include files in c: \ OpenCV-2.2.0 \ vs2008 \ include, then when you want to call the opencv function in this new way, the simplest and most reliable way is

#include “opencv2/opencv.hpp”

After that:

If you do not know whether it is using C: \ OpenCV-2.2.0 \ vs2008 \ include \ opencv or c: \ OpenCV-2.2.0 \ vs2008 \ include \ opencv2, then simply in the file that contains the inside, enter both of them !! The probability of such errors may be much less.


In fact, whether it is the old or new method, you only need to specify the folder in which the header file you want to include is located, the path is correct, and then configure the compiler. That's easy. For new users, there is a fear and worship mentality in many things. At the beginning, I wrote a header file for myself, and then the people included in the file were excited. After finding out what the header file is, we can pull the cold and pull the cold: how can we worship people so easily (* ^__ ^ *).

Write so many rights first!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.