Files
952-11/env/halcon/include/halconcpp/HOCRKnn.h
T
2024-02-26 16:19:48 +08:00

263 lines
11 KiB
C++

/***********************************************************
* File generated by the HALCON-Compiler hcomp version 20.11
* Usage: Interface to C++
*
* Software by: MVTec Software GmbH, www.mvtec.com
***********************************************************/
#ifndef HCPP_HOCRKNN
#define HCPP_HOCRKNN
namespace HalconCpp
{
// Represents an instance of a k-NearestNeighbor OCR classifier.
class LIntExport HOCRKnn : public HHandle
{
public:
// Create an uninitialized instance
HOCRKnn():HHandle() {}
// Copy constructor
HOCRKnn(const HOCRKnn& source) : HHandle(source) {}
// Copy constructor
HOCRKnn(const HHandle& handle);
// Create HOCRKnn from handle, taking ownership
explicit HOCRKnn(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_knn')!
virtual void AssertType(Hphandle handle) const;
public:
// Deep copy of all data represented by this object instance
HOCRKnn Clone() const;
/*****************************************************************************
* Operator-based class constructors
*****************************************************************************/
// read_ocr_class_knn: Read an OCR classifier from a file.
explicit HOCRKnn(const HString& FileName);
// read_ocr_class_knn: Read an OCR classifier from a file.
explicit HOCRKnn(const char* FileName);
#ifdef _WIN32
// read_ocr_class_knn: Read an OCR classifier from a file.
explicit HOCRKnn(const wchar_t* FileName);
#endif
// create_ocr_class_knn: Create an OCR classifier using a k-Nearest Neighbor (k-NN) classifier.
explicit HOCRKnn(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HTuple& Features, const HTuple& Characters, const HTuple& GenParamName, const HTuple& GenParamValue);
// create_ocr_class_knn: Create an OCR classifier using a k-Nearest Neighbor (k-NN) classifier.
explicit HOCRKnn(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HString& Features, const HTuple& Characters, const HTuple& GenParamName, const HTuple& GenParamValue);
// create_ocr_class_knn: Create an OCR classifier using a k-Nearest Neighbor (k-NN) classifier.
explicit HOCRKnn(Hlong WidthCharacter, Hlong HeightCharacter, const char* Interpolation, const char* Features, const HTuple& Characters, const HTuple& GenParamName, const HTuple& GenParamValue);
#ifdef _WIN32
// create_ocr_class_knn: Create an OCR classifier using a k-Nearest Neighbor (k-NN) classifier.
explicit HOCRKnn(Hlong WidthCharacter, Hlong HeightCharacter, const wchar_t* Interpolation, const wchar_t* Features, const HTuple& Characters, const HTuple& GenParamName, const HTuple& GenParamValue);
#endif
/***************************************************************************
* Operators *
***************************************************************************/
// Classify a related group of characters with an OCR classifier.
HTuple DoOcrWordKnn(const HRegion& Character, const HImage& Image, const HString& Expression, Hlong NumAlternatives, Hlong NumCorrections, HTuple* Confidence, HString* Word, double* Score) const;
// Classify a related group of characters with an OCR classifier.
HString DoOcrWordKnn(const HRegion& Character, const HImage& Image, const HString& Expression, Hlong NumAlternatives, Hlong NumCorrections, double* Confidence, HString* Word, double* Score) const;
// Classify a related group of characters with an OCR classifier.
HString DoOcrWordKnn(const HRegion& Character, const HImage& Image, const char* Expression, Hlong NumAlternatives, Hlong NumCorrections, double* Confidence, HString* Word, double* Score) const;
#ifdef _WIN32
// Classify a related group of characters with an OCR classifier.
HString DoOcrWordKnn(const HRegion& Character, const HImage& Image, const wchar_t* Expression, Hlong NumAlternatives, Hlong NumCorrections, double* Confidence, HString* Word, double* Score) const;
#endif
// Deserialize a serialized k-NN-based OCR classifier.
void DeserializeOcrClassKnn(const HSerializedItem& SerializedItemHandle);
// Serialize a k-NN-based OCR classifier.
HSerializedItem SerializeOcrClassKnn() const;
// Read an OCR classifier from a file.
void ReadOcrClassKnn(const HString& FileName);
// Read an OCR classifier from a file.
void ReadOcrClassKnn(const char* FileName);
#ifdef _WIN32
// Read an OCR classifier from a file.
void ReadOcrClassKnn(const wchar_t* FileName);
#endif
// Write a k-NN classifier for an OCR task to a file.
void WriteOcrClassKnn(const HString& FileName) const;
// Write a k-NN classifier for an OCR task to a file.
void WriteOcrClassKnn(const char* FileName) const;
#ifdef _WIN32
// Write a k-NN classifier for an OCR task to a file.
void WriteOcrClassKnn(const wchar_t* FileName) const;
#endif
// Clear an OCR classifier.
void ClearOcrClassKnn() const;
// Create an OCR classifier using a k-Nearest Neighbor (k-NN) classifier.
void CreateOcrClassKnn(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HTuple& Features, const HTuple& Characters, const HTuple& GenParamName, const HTuple& GenParamValue);
// Create an OCR classifier using a k-Nearest Neighbor (k-NN) classifier.
void CreateOcrClassKnn(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HString& Features, const HTuple& Characters, const HTuple& GenParamName, const HTuple& GenParamValue);
// Create an OCR classifier using a k-Nearest Neighbor (k-NN) classifier.
void CreateOcrClassKnn(Hlong WidthCharacter, Hlong HeightCharacter, const char* Interpolation, const char* Features, const HTuple& Characters, const HTuple& GenParamName, const HTuple& GenParamValue);
#ifdef _WIN32
// Create an OCR classifier using a k-Nearest Neighbor (k-NN) classifier.
void CreateOcrClassKnn(Hlong WidthCharacter, Hlong HeightCharacter, const wchar_t* Interpolation, const wchar_t* Features, const HTuple& Characters, const HTuple& GenParamName, const HTuple& GenParamValue);
#endif
// Trains an k-NN classifier for an OCR task.
void TrainfOcrClassKnn(const HTuple& TrainingFile, const HTuple& GenParamName, const HTuple& GenParamValue) const;
// Trains an k-NN classifier for an OCR task.
void TrainfOcrClassKnn(const HString& TrainingFile, const HTuple& GenParamName, const HTuple& GenParamValue) const;
// Trains an k-NN classifier for an OCR task.
void TrainfOcrClassKnn(const char* TrainingFile, const HTuple& GenParamName, const HTuple& GenParamValue) const;
#ifdef _WIN32
// Trains an k-NN classifier for an OCR task.
void TrainfOcrClassKnn(const wchar_t* TrainingFile, const HTuple& GenParamName, const HTuple& GenParamValue) const;
#endif
// Compute the features of a character.
HTuple GetFeaturesOcrClassKnn(const HImage& Character, const HString& Transform) const;
// Compute the features of a character.
HTuple GetFeaturesOcrClassKnn(const HImage& Character, const char* Transform) const;
#ifdef _WIN32
// Compute the features of a character.
HTuple GetFeaturesOcrClassKnn(const HImage& Character, const wchar_t* Transform) const;
#endif
// Return the parameters of an OCR classifier.
void GetParamsOcrClassKnn(Hlong* WidthCharacter, Hlong* HeightCharacter, HString* Interpolation, HTuple* Features, HTuple* Characters, HString* Preprocessing, Hlong* NumTrees) const;
// Return the parameters of an OCR classifier.
void GetParamsOcrClassKnn(Hlong* WidthCharacter, Hlong* HeightCharacter, HString* Interpolation, HString* Features, HTuple* Characters, HString* Preprocessing, Hlong* NumTrees) const;
// Classify multiple characters with an k-NN classifier.
HTuple DoOcrMultiClassKnn(const HRegion& Character, const HImage& Image, HTuple* Confidence) const;
// Classify multiple characters with an k-NN classifier.
HString DoOcrMultiClassKnn(const HRegion& Character, const HImage& Image, double* Confidence) const;
// Classify a single character with an OCR classifier.
HTuple DoOcrSingleClassKnn(const HRegion& Character, const HImage& Image, const HTuple& NumClasses, const HTuple& NumNeighbors, HTuple* Confidence) const;
// Classify a single character with an OCR classifier.
HString DoOcrSingleClassKnn(const HRegion& Character, const HImage& Image, const HTuple& NumClasses, const HTuple& NumNeighbors, double* Confidence) const;
// Select an optimal combination of features to classify OCR data.
HTuple SelectFeatureSetTrainfKnn(const HTuple& TrainingFile, const HTuple& FeatureList, const HString& SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
// Select an optimal combination of features to classify OCR data.
HTuple SelectFeatureSetTrainfKnn(const HString& TrainingFile, const HString& FeatureList, const HString& SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
// Select an optimal combination of features to classify OCR data.
HTuple SelectFeatureSetTrainfKnn(const char* TrainingFile, const char* FeatureList, const char* SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
#ifdef _WIN32
// Select an optimal combination of features to classify OCR data.
HTuple SelectFeatureSetTrainfKnn(const wchar_t* TrainingFile, const wchar_t* FeatureList, const wchar_t* SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
#endif
};
// forward declarations and types for internal array implementation
template<class T> class HSmartPtr;
template<class T> class HHandleBaseArrayRef;
typedef HHandleBaseArrayRef<HOCRKnn> HOCRKnnArrayRef;
typedef HSmartPtr< HOCRKnnArrayRef > HOCRKnnArrayPtr;
// Represents multiple tool instances
class LIntExport HOCRKnnArray : public HHandleBaseArray
{
public:
// Create empty array
HOCRKnnArray();
// Create array from native array of tool instances
HOCRKnnArray(HOCRKnn* classes, Hlong length);
// Copy constructor
HOCRKnnArray(const HOCRKnnArray &tool_array);
// Destructor
virtual ~HOCRKnnArray();
// Assignment operator
HOCRKnnArray &operator=(const HOCRKnnArray &tool_array);
// Clears array and all tool instances
virtual void Clear();
// Get array of native tool instances
const HOCRKnn* 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
HOCRKnnArrayPtr *mArrayPtr;
};
}
#endif