OpenCV C Language Interface and C + + interface Differences (introductory article)

Source: Internet
Author: User

OpenCV is an open source image processing library, the most classic 1.0 version number provides the interface is the C language interface.

Later the opencv2.x version number retains the C language interface, but it provides C + + interface, the C interface is only for backwards compatibility, and C + + interface is the trend.

So what's the difference between the two? Explain the differences in the configuration process today.


Take opencv2.3.0 and vs2008 as an example. When configured. You first configure the Include files and libraries file, and then add the DLL file to the system variable path. Additional dependent libraries are added to the final Item property. I usually do not use a lot of functions. These opencv_core230.lib are generally added. Opencv_highgui230.lib. Opencv_imgproc230.lib,opencv_video230.lib. What I need to explain is that I am using the C language interface. What is a C-language interface, for example. A small program that reads video files.

#include <opencv2/opencv.hpp> #include <iostream>using namespace Std;int main () {    cvcapture *pcapture= NULL;    Pcapture=cvcreatefilecapture ("50254000.avi");    Iplimage *pframe=null;    Cvnamedwindow ("Sor", 0);    while (pframe = Cvqueryframe (pcapture))    {        cvshowimage ("Sor", pframe); cvwaitkey;    }    return 0;}
Please forgive me for not releasing pcapture and displaying the form. Anyway, here's the OPENCV function. is the C language interface.

Today's whim, want to use the C + + interface to write a program, the result encountered a problem. I still configure it the way I used to.

The code is as follows:

#include <opencv2/opencv.hpp> #include <iostream>using namespace std;using namespace Cv;int main () { Videocapture Capture ("2014y12m17d08h21f58syi.avi"), if (!capture.isopened ()) {cout << "fail to open the Vedio" < < Endl;return 1;} Mat Frame;namedwindow ("test", 0);  while (Capture.read (frame)) {imshow ("test", frame), if (waitkey () = =) {return 0;}} return 0;}
The same is the reading of a video program, compile can pass, but the execution to the first sentence error. It was later found that the C language interface and the C + + interface used by the library file is not the same. So when it's configured. These items should be replaced in the additional dependencies of the project properties: Opencv_core230d.lib,opencv_highgui230d.lib. Opencv_imgproc230d.lib,opencv_video230d.lib, so later. Performed normally.


Of course, this is only a small difference in the configuration time, now OPENCV C + + interface provides many other more advanced algorithms, but also to the C language interface changes some bugs, so in the process of using OPENCV. The C + + interface should be used more.




OpenCV C Language Interface and C + + interface Differences (introductory article)

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.