123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- /***********************************************************
- * File generated by the HALCON-Compiler hcomp version 20.11
- * 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);
- #ifdef _WIN32
- // read_class_knn: Read the k-NN classifier from a file.
- explicit HClassKnn(const wchar_t* FileName);
- #endif
- // 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);
- #ifdef _WIN32
- // Selects an optimal subset from a set of features to solve a certain classification problem.
- HTuple SelectFeatureSetKnn(const HClassTrainData& ClassTrainDataHandle, const wchar_t* SelectionMethod, const wchar_t* GenParamName, double GenParamValue, HTuple* Score);
- #endif
- // 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);
- #ifdef _WIN32
- // Read the k-NN classifier from a file.
- void ReadClassKnn(const wchar_t* FileName);
- #endif
- // 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;
- #ifdef _WIN32
- // Save the k-NN classifier in a file.
- void WriteClassKnn(const wchar_t* FileName) const;
- #endif
- // 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
|