Download HALCON Programmer`s Guide

Transcript
34
Basics of the HALCON/C++ Interface
You can specify (“use”) the namespace in three ways:
• specifically, by prefixing each class name or operator call with the namespace
HalconCpp::HObject original_image, smoothed_image;
HalconCpp::ReadImage(&original_image, "monkey");
• locally, by placing the directive using namespace HalconCpp; at the beginning of a block, e.g.,
at the beginning of a function:
int main(int argc, char *argv[])
{
using namespace HalconCpp;
HObject original_image, smoothed_image;
ReadImage(&original_image, "monkey");
Then, you can use HALCON’s classes and functions without prefix inside this block.
• globally, by placing the directive using directly after including HalconCpp.h. Then, you do not
need the prefix in your whole application.
#include "HalconCpp.h"
using namespace HalconCpp;
Which method is the most suitable depends on your application, more exactly on what other libraries it
includes and if there are name collisions.
Please note that the namespace is not mentioned in the operator descriptions in the reference manual in
order to keep it readable. Similarly, in the following sections the namespace is left out.
5.2
Calling HALCON Operators
How a HALCON operator can be called via the HALCON/C++ interface is described in detail in the
HALCON operator reference manual. As an example, figure 5.1 shows parts of the entry for the operator
MeanImage.
Please note that the reference manual does not list all possible signatures of the operators. A complete
list can be found in the file include\cpp\HCPPGlobal.h.
Below, we
• take a closer look at the parameters of an operator call (section 5.2.1)
• describe how to call operators via classes (section 5.2.2 on page 37) or via special constructors
(section 5.2.3 on page 38) or destructors (section 5.2.4 on page 39)
• explain another special HALCON concept, the tuple mode (section 5.2.5 on page 39)