/*********************************************************** * File generated by the HALCON-Compiler hcomp version 20.11 * Usage: Interface to C++ * * Software by: MVTec Software GmbH, www.mvtec.com ***********************************************************/ #ifndef HCPP_HOCRBOX #define HCPP_HOCRBOX namespace HalconCpp { // Represents an instance of an OCR box classifier. class LIntExport HOCRBox : public HHandle { public: // Create an uninitialized instance HOCRBox():HHandle() {} // Copy constructor HOCRBox(const HOCRBox& source) : HHandle(source) {} // Copy constructor HOCRBox(const HHandle& handle); // Create HOCRBox from handle, taking ownership explicit HOCRBox(Hlong handle); bool operator==(const HHandle& obj) const { return HHandleBase::operator==(obj); } bool operator!=(const HHandle& obj) const { return HHandleBase::operator!=(obj); } protected: // Verify matching semantic type ('ocr_box')! virtual void AssertType(Hphandle handle) const; public: // Deep copy of all data represented by this object instance HOCRBox Clone() const; /***************************************************************************** * Operator-based class constructors *****************************************************************************/ // read_ocr: Read an OCR classifier from a file. explicit HOCRBox(const HString& FileName); // read_ocr: Read an OCR classifier from a file. explicit HOCRBox(const char* FileName); #ifdef _WIN32 // read_ocr: Read an OCR classifier from a file. explicit HOCRBox(const wchar_t* FileName); #endif // create_ocr_class_box: Create a new OCR-classifier. explicit HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HTuple& Features, const HTuple& Character); // create_ocr_class_box: Create a new OCR-classifier. explicit HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HString& Features, const HTuple& Character); // create_ocr_class_box: Create a new OCR-classifier. explicit HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const char* Features, const HTuple& Character); #ifdef _WIN32 // create_ocr_class_box: Create a new OCR-classifier. explicit HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const wchar_t* Features, const HTuple& Character); #endif /*************************************************************************** * Operators * ***************************************************************************/ // Serialize an OCR classifier. HSerializedItem SerializeOcr() const; // Deserialize a serialized OCR classifier. void DeserializeOcr(const HSerializedItem& SerializedItemHandle); // Writing an OCR classifier into a file. void WriteOcr(const HString& FileName) const; // Writing an OCR classifier into a file. void WriteOcr(const char* FileName) const; #ifdef _WIN32 // Writing an OCR classifier into a file. void WriteOcr(const wchar_t* FileName) const; #endif // Read an OCR classifier from a file. void ReadOcr(const HString& FileName); // Read an OCR classifier from a file. void ReadOcr(const char* FileName); #ifdef _WIN32 // Read an OCR classifier from a file. void ReadOcr(const wchar_t* FileName); #endif // Classify one character. HTuple DoOcrSingle(const HRegion& Character, const HImage& Image, HTuple* Confidences) const; // Classify characters. HTuple DoOcrMulti(const HRegion& Character, const HImage& Image, HTuple* Confidence) const; // Classify characters. HString DoOcrMulti(const HRegion& Character, const HImage& Image, double* Confidence) const; // Get information about an OCR classifier. void InfoOcrClassBox(Hlong* WidthPattern, Hlong* HeightPattern, Hlong* Interpolation, Hlong* WidthMaxChar, Hlong* HeightMaxChar, HTuple* Features, HTuple* Characters) const; // Create a new OCR-classifier. void CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HTuple& Features, const HTuple& Character); // Create a new OCR-classifier. void CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HString& Features, const HTuple& Character); // Create a new OCR-classifier. void CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const char* Features, const HTuple& Character); #ifdef _WIN32 // Create a new OCR-classifier. void CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const wchar_t* Features, const HTuple& Character); #endif // Train an OCR classifier by the input of regions. double TraindOcrClassBox(const HRegion& Character, const HImage& Image, const HTuple& Class) const; // Train an OCR classifier by the input of regions. double TraindOcrClassBox(const HRegion& Character, const HImage& Image, const HString& Class) const; // Train an OCR classifier by the input of regions. double TraindOcrClassBox(const HRegion& Character, const HImage& Image, const char* Class) const; #ifdef _WIN32 // Train an OCR classifier by the input of regions. double TraindOcrClassBox(const HRegion& Character, const HImage& Image, const wchar_t* Class) const; #endif // Train an OCR classifier with the help of a training file. double TrainfOcrClassBox(const HTuple& TrainingFile) const; // Train an OCR classifier with the help of a training file. double TrainfOcrClassBox(const HString& TrainingFile) const; // Train an OCR classifier with the help of a training file. double TrainfOcrClassBox(const char* TrainingFile) const; #ifdef _WIN32 // Train an OCR classifier with the help of a training file. double TrainfOcrClassBox(const wchar_t* TrainingFile) const; #endif // Define a new conversion table for the characters. void OcrChangeChar(const HTuple& Character) const; // Deallocation of the memory of an OCR classifier. void CloseOcr() const; // Test an OCR classifier. HTuple TestdOcrClassBox(const HRegion& Character, const HImage& Image, const HTuple& Class) const; // Test an OCR classifier. double TestdOcrClassBox(const HRegion& Character, const HImage& Image, const HString& Class) const; // Test an OCR classifier. double TestdOcrClassBox(const HRegion& Character, const HImage& Image, const char* Class) const; #ifdef _WIN32 // Test an OCR classifier. double TestdOcrClassBox(const HRegion& Character, const HImage& Image, const wchar_t* Class) const; #endif // Access the features which correspond to a character. HTuple OcrGetFeatures(const HImage& Character) const; }; // forward declarations and types for internal array implementation template class HSmartPtr; template class HHandleBaseArrayRef; typedef HHandleBaseArrayRef HOCRBoxArrayRef; typedef HSmartPtr< HOCRBoxArrayRef > HOCRBoxArrayPtr; // Represents multiple tool instances class LIntExport HOCRBoxArray : public HHandleBaseArray { public: // Create empty array HOCRBoxArray(); // Create array from native array of tool instances HOCRBoxArray(HOCRBox* classes, Hlong length); // Copy constructor HOCRBoxArray(const HOCRBoxArray &tool_array); // Destructor virtual ~HOCRBoxArray(); // Assignment operator HOCRBoxArray &operator=(const HOCRBoxArray &tool_array); // Clears array and all tool instances virtual void Clear(); // Get array of native tool instances const HOCRBox* Tools() const; // Get number of tools virtual Hlong Length() const; // Create tool array from tuple of handles virtual void SetFromTuple(const HTuple& handles); // Get tuple of handles for tool array virtual HTuple ConvertToTuple() const; protected: // Smart pointer to internal data container HOCRBoxArrayPtr *mArrayPtr; }; } #endif