Namespace cv and Function NamingΒΆ

All the newly introduced classes and functions are placed into cv namespace. Therefore, to access this functionality from your code, use cv:: specifier or "using namespace cv;" directive:

#include "cv.h"

...
cv::Mat H = cv::findHomography(points1, points2, cv::RANSAC, 5);
...

or

#include "cv.h"

using namespace cv;

...
Mat H = findHomography(points1, points2, RANSAC, 5 );
...

It is probable that some of the current or future OpenCV external names conflict with STL or other libraries, in this case use explicit namespace specifiers to resolve the name conflicts:

Mat a(100, 100, CV_32F);
randu(a, Scalar::all(1), Scalar::all(std::rand()
cv::log(a, a);
a /= std::log(2.);

For the most of the C functions and structures from OpenCV 1.x you may find the direct counterparts in the new C++ interface. The name is usually formed by omitting cv or Cv prefix and turning the first letter to the low case (unless it’s a own name, like Canny, Sobel etc). In case when there is no the new-style counterpart, it’s possible to use the old functions with the new structures, as shown the first sample in the chapter.

Previous topic

C++ Cheatsheet

Next topic

Memory Management

This Page