HALCON/C++ 的所有函数和类都使用 HalconCpp 命名空间,以防止与其他 C++ 库发生潜在的名称冲突。
您可以通过三种方式指定("使用")命名空间:
HalconCpp::HObject original_image, smoothed_image; HalconCpp::ReadImage(&original_image, "monkey");
int main(int argc, char* argv[]) { using namespace HalconCpp; HObject original_image, smoothed_image; ReadImage(&original_image, "monkey");
在这种情况下,您可以使用 HALCON 的类和函数,而无需在该代码块中添加前缀。
#include "HalconCpp.h" using namespace HalconCpp;
using HalconCpp::HObject; using HalconCpp::ReadImage; HObject original_image, smoothed_image; ReadImage(&original_image, "monkey");
哪种方法最合适取决于您的应用程序,更具体地说,取决于它包含哪些其他库,以及是否存在名称冲突。
请注意,为了保持可读性,参考手册中的算子描述没有提及命名空间。同样,在以下章节中也没有提及命名空间。