Files
2025-03-26 01:06:45 +08:00

203 lines
6.5 KiB
C++

/***********************************************************
* File generated by the HALCON-Compiler hcomp version 18.05
* Usage: Interface to C++
*
* Software by: MVTec Software GmbH, www.mvtec.com
***********************************************************/
#ifndef HCPP_HCLASSKNN
#define HCPP_HCLASSKNN
namespace HalconCpp
{
// Represents an instance of a k-NearestNeighbor classifier.
class LIntExport HClassKnn : public HHandle
{
public:
// Create an uninitialized instance
HClassKnn():HHandle() {}
// Copy constructor
HClassKnn(const HClassKnn& source) : HHandle(source) {}
// Copy constructor
HClassKnn(const HHandle& handle);
// Create HClassKnn from handle, taking ownership
explicit HClassKnn(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 ('class_knn')!
virtual void AssertType(Hphandle handle) const;
public:
// Deep copy of all data represented by this object instance
HClassKnn Clone() const;
/*****************************************************************************
* Operator-based class constructors
*****************************************************************************/
// read_class_knn: Read the k-NN classifier from a file.
explicit HClassKnn(const HString& FileName);
// read_class_knn: Read the k-NN classifier from a file.
explicit HClassKnn(const char* FileName);
// create_class_knn: Create a k-nearest neighbors (k-NN) classifier.
explicit HClassKnn(const HTuple& NumDim);
/***************************************************************************
* Operators *
***************************************************************************/
// Classify an image with a k-Nearest-Neighbor classifier.
HRegion ClassifyImageClassKnn(const HImage& Image, HImage* DistanceImage, double RejectionThreshold) const;
// Add training samples from an image to the training data of a k-Nearest-Neighbor classifier.
void AddSamplesImageClassKnn(const HImage& Image, const HRegion& ClassRegions) const;
// Get the training data of a k-nearest neighbors (k-NN) classifier.
HClassTrainData GetClassTrainDataKnn() const;
// Add training data to a k-nearest neighbors (k-NN) classifier.
void AddClassTrainDataKnn(const HClassTrainData& ClassTrainDataHandle) const;
// Selects an optimal subset from a set of features to solve a certain classification problem.
HTuple SelectFeatureSetKnn(const HClassTrainData& ClassTrainDataHandle, const HString& SelectionMethod, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
// Selects an optimal subset from a set of features to solve a certain classification problem.
HTuple SelectFeatureSetKnn(const HClassTrainData& ClassTrainDataHandle, const HString& SelectionMethod, const HString& GenParamName, double GenParamValue, HTuple* Score);
// Selects an optimal subset from a set of features to solve a certain classification problem.
HTuple SelectFeatureSetKnn(const HClassTrainData& ClassTrainDataHandle, const char* SelectionMethod, const char* GenParamName, double GenParamValue, HTuple* Score);
// Clear a k-NN classifier.
void ClearClassKnn() const;
// Return the number of training samples stored in the training data of a k-nearest neighbors (k-NN) classifier.
Hlong GetSampleNumClassKnn() const;
// Return a training sample from the training data of a k-nearest neighbors (k-NN) classifier.
HTuple GetSampleClassKnn(Hlong IndexSample, HTuple* ClassID) const;
// Deserialize a serialized k-NN classifier.
void DeserializeClassKnn(const HSerializedItem& SerializedItemHandle);
// Serialize a k-NN classifier.
HSerializedItem SerializeClassKnn() const;
// Read the k-NN classifier from a file.
void ReadClassKnn(const HString& FileName);
// Read the k-NN classifier from a file.
void ReadClassKnn(const char* FileName);
// Save the k-NN classifier in a file.
void WriteClassKnn(const HString& FileName) const;
// Save the k-NN classifier in a file.
void WriteClassKnn(const char* FileName) const;
// Get parameters of a k-NN classification.
HTuple GetParamsClassKnn(const HTuple& GenParamName) const;
// Set parameters for k-NN classification.
void SetParamsClassKnn(const HTuple& GenParamName, const HTuple& GenParamValue) const;
// Search for the next neighbors for a given feature vector.
HTuple ClassifyClassKnn(const HTuple& Features, HTuple* Rating) const;
// Creates the search trees for a k-NN classifier.
void TrainClassKnn(const HTuple& GenParamName, const HTuple& GenParamValue) const;
// Add a sample to a k-nearest neighbors (k-NN) classifier.
void AddSampleClassKnn(const HTuple& Features, const HTuple& ClassID) const;
// Add a sample to a k-nearest neighbors (k-NN) classifier.
void AddSampleClassKnn(double Features, Hlong ClassID) const;
// Create a k-nearest neighbors (k-NN) classifier.
void CreateClassKnn(const HTuple& NumDim);
// Create a look-up table using a k-nearest neighbors classifier (k-NN) to classify byte images.
HClassLUT CreateClassLutKnn(const HTuple& GenParamName, const HTuple& GenParamValue) const;
};
// forward declarations and types for internal array implementation
template<class T> class HSmartPtr;
template<class T> class HHandleBaseArrayRef;
typedef HHandleBaseArrayRef<HClassKnn> HClassKnnArrayRef;
typedef HSmartPtr< HClassKnnArrayRef > HClassKnnArrayPtr;
// Represents multiple tool instances
class LIntExport HClassKnnArray : public HHandleBaseArray
{
public:
// Create empty array
HClassKnnArray();
// Create array from native array of tool instances
HClassKnnArray(HClassKnn* classes, Hlong length);
// Copy constructor
HClassKnnArray(const HClassKnnArray &tool_array);
// Destructor
virtual ~HClassKnnArray();
// Assignment operator
HClassKnnArray &operator=(const HClassKnnArray &tool_array);
// Clears array and all tool instances
virtual void Clear();
// Get array of native tool instances
const HClassKnn* 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
HClassKnnArrayPtr *mArrayPtr;
};
}
#endif