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

Source: Internet
Author: User
Tags image processing library

OpenCV is an open source image processing library, and the most classic version of 1.0 provides interfaces that are C-language. Later, the opencv2.x version retains the C language interface, but provides a C + + interface, where the C interface is only for backwards compatibility, while the C + + interface is the trend. So what's the difference between the two? Explain the differences in the configuration process today.


In the case of opencv2.3.0 and vs2008, configure the Include file and library file, add the DLL file in the system variable path, and then add the additional dependent libraries in the project properties. I usually use the function is not much, generally add these several opencv_core230.lib,opencv_highgui230.lib,opencv_imgproc230.lib,opencv_video230.lib. It is necessary to note 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;}
Excuse me for not releasing pcapture and display windows, anyway, here's the OPENCV function, which 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 did before. 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 run to the first sentence error. It was later discovered that the C language interface and the C + + interface used a different library file. As a result of the configuration, 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 after that, it runs normally.


Of course, this is only a small difference in the configuration time, now OPENCV C + + interface provides more advanced algorithms, and to the C language interface modified some bugs, so in the process of using OPENCV, you should use more than C + + interface.


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

Related 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.