HClassBox.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /***********************************************************
  2. * File generated by the HALCON-Compiler hcomp version 20.11
  3. * Usage: Interface to C++
  4. *
  5. * Software by: MVTec Software GmbH, www.mvtec.com
  6. ***********************************************************/
  7. #ifndef HCPP_HCLASSBOX
  8. #define HCPP_HCLASSBOX
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a classifier.
  12. class LIntExport HClassBox : public HHandle
  13. {
  14. public:
  15. // Copy constructor
  16. HClassBox(const HClassBox& source) : HHandle(source) {}
  17. // Copy constructor
  18. HClassBox(const HHandle& handle);
  19. // Create HClassBox from handle, taking ownership
  20. explicit HClassBox(Hlong handle);
  21. bool operator==(const HHandle& obj) const
  22. {
  23. return HHandleBase::operator==(obj);
  24. }
  25. bool operator!=(const HHandle& obj) const
  26. {
  27. return HHandleBase::operator!=(obj);
  28. }
  29. protected:
  30. // Verify matching semantic type ('class_box')!
  31. virtual void AssertType(Hphandle handle) const;
  32. public:
  33. // Deep copy of all data represented by this object instance
  34. HClassBox Clone() const;
  35. /*****************************************************************************
  36. * Operator-based class constructors
  37. *****************************************************************************/
  38. // create_class_box: Create a new classifier.
  39. explicit HClassBox();
  40. /***************************************************************************
  41. * Operators *
  42. ***************************************************************************/
  43. // Train a classificator using a multi-channel image.
  44. void LearnNdimBox(const HRegion& Foreground, const HRegion& Background, const HImage& MultiChannelImage) const;
  45. // Classify pixels using hyper-cuboids.
  46. HRegion ClassNdimBox(const HImage& MultiChannelImage) const;
  47. // Deserialize a serialized classifier.
  48. void DeserializeClassBox(const HSerializedItem& SerializedItemHandle) const;
  49. // Serialize a classifier.
  50. HSerializedItem SerializeClassBox() const;
  51. // Save a classifier in a file.
  52. void WriteClassBox(const HString& FileName) const;
  53. // Save a classifier in a file.
  54. void WriteClassBox(const char* FileName) const;
  55. #ifdef _WIN32
  56. // Save a classifier in a file.
  57. void WriteClassBox(const wchar_t* FileName) const;
  58. #endif
  59. // Set system parameters for classification.
  60. void SetClassBoxParam(const HString& Flag, const HTuple& Value) const;
  61. // Set system parameters for classification.
  62. void SetClassBoxParam(const HString& Flag, double Value) const;
  63. // Set system parameters for classification.
  64. void SetClassBoxParam(const char* Flag, double Value) const;
  65. #ifdef _WIN32
  66. // Set system parameters for classification.
  67. void SetClassBoxParam(const wchar_t* Flag, double Value) const;
  68. #endif
  69. // Read a classifier from a file.
  70. void ReadClassBox(const HString& FileName) const;
  71. // Read a classifier from a file.
  72. void ReadClassBox(const char* FileName) const;
  73. #ifdef _WIN32
  74. // Read a classifier from a file.
  75. void ReadClassBox(const wchar_t* FileName) const;
  76. #endif
  77. // Train the classifier with one data set.
  78. void LearnSampsetBox(const HFeatureSet& SampKey, const HString& Outfile, Hlong NSamples, double StopError, Hlong ErrorN) const;
  79. // Train the classifier with one data set.
  80. void LearnSampsetBox(const HFeatureSet& SampKey, const char* Outfile, Hlong NSamples, double StopError, Hlong ErrorN) const;
  81. #ifdef _WIN32
  82. // Train the classifier with one data set.
  83. void LearnSampsetBox(const HFeatureSet& SampKey, const wchar_t* Outfile, Hlong NSamples, double StopError, Hlong ErrorN) const;
  84. #endif
  85. // Train the classifier.
  86. void LearnClassBox(const HTuple& Features, Hlong Class) const;
  87. // Get information about the current parameter.
  88. HTuple GetClassBoxParam(const HString& Flag) const;
  89. // Get information about the current parameter.
  90. HTuple GetClassBoxParam(const char* Flag) const;
  91. #ifdef _WIN32
  92. // Get information about the current parameter.
  93. HTuple GetClassBoxParam(const wchar_t* Flag) const;
  94. #endif
  95. // Destroy the classifier.
  96. void CloseClassBox() const;
  97. // Create a new classifier.
  98. void CreateClassBox();
  99. // Describe the classes of a box classifier.
  100. HTuple DescriptClassBox(Hlong Dimensions, HTuple* BoxIdx, HTuple* BoxLowerBound, HTuple* BoxHigherBound, HTuple* BoxNumSamplesTrain, HTuple* BoxNumSamplesWrong) const;
  101. // Describe the classes of a box classifier.
  102. Hlong DescriptClassBox(Hlong Dimensions, Hlong* BoxIdx, Hlong* BoxLowerBound, Hlong* BoxHigherBound, Hlong* BoxNumSamplesTrain, Hlong* BoxNumSamplesWrong) const;
  103. // Classify a set of arrays.
  104. double TestSampsetBox(const HFeatureSet& SampKey) const;
  105. // Classify a tuple of attributes with rejection class.
  106. Hlong EnquireRejectClassBox(const HTuple& FeatureList) const;
  107. // Classify a tuple of attributes.
  108. Hlong EnquireClassBox(const HTuple& FeatureList) const;
  109. };
  110. // forward declarations and types for internal array implementation
  111. template<class T> class HSmartPtr;
  112. template<class T> class HHandleBaseArrayRef;
  113. typedef HHandleBaseArrayRef<HClassBox> HClassBoxArrayRef;
  114. typedef HSmartPtr< HClassBoxArrayRef > HClassBoxArrayPtr;
  115. // Represents multiple tool instances
  116. class LIntExport HClassBoxArray : public HHandleBaseArray
  117. {
  118. public:
  119. // Create empty array
  120. HClassBoxArray();
  121. // Create array from native array of tool instances
  122. HClassBoxArray(HClassBox* classes, Hlong length);
  123. // Copy constructor
  124. HClassBoxArray(const HClassBoxArray &tool_array);
  125. // Destructor
  126. virtual ~HClassBoxArray();
  127. // Assignment operator
  128. HClassBoxArray &operator=(const HClassBoxArray &tool_array);
  129. // Clears array and all tool instances
  130. virtual void Clear();
  131. // Get array of native tool instances
  132. const HClassBox* Tools() const;
  133. // Get number of tools
  134. virtual Hlong Length() const;
  135. // Create tool array from tuple of handles
  136. virtual void SetFromTuple(const HTuple& handles);
  137. // Get tuple of handles for tool array
  138. virtual HTuple ConvertToTuple() const;
  139. protected:
  140. // Smart pointer to internal data container
  141. HClassBoxArrayPtr *mArrayPtr;
  142. };
  143. }
  144. #endif