/*********************************************************** * File generated by the HALCON-Compiler hcomp version 20.11 * Usage: Interface to C++ * * Software by: MVTec Software GmbH, www.mvtec.com ***********************************************************/ #ifndef HCPP_HCLASSSVM #define HCPP_HCLASSSVM namespace HalconCpp { // Represents an instance of a support vector machine. class LIntExport HClassSvm : public HHandle { public: // Create an uninitialized instance HClassSvm():HHandle() {} // Copy constructor HClassSvm(const HClassSvm& source) : HHandle(source) {} // Copy constructor HClassSvm(const HHandle& handle); // Create HClassSvm from handle, taking ownership explicit HClassSvm(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_svm')! virtual void AssertType(Hphandle handle) const; public: // Deep copy of all data represented by this object instance HClassSvm Clone() const; /***************************************************************************** * Operator-based class constructors *****************************************************************************/ // read_class_svm: Read a support vector machine from a file. explicit HClassSvm(const HString& FileName); // read_class_svm: Read a support vector machine from a file. explicit HClassSvm(const char* FileName); #ifdef _WIN32 // read_class_svm: Read a support vector machine from a file. explicit HClassSvm(const wchar_t* FileName); #endif // create_class_svm: Create a support vector machine for pattern classification. explicit HClassSvm(Hlong NumFeatures, const HString& KernelType, double KernelParam, double Nu, Hlong NumClasses, const HString& Mode, const HString& Preprocessing, Hlong NumComponents); // create_class_svm: Create a support vector machine for pattern classification. explicit HClassSvm(Hlong NumFeatures, const char* KernelType, double KernelParam, double Nu, Hlong NumClasses, const char* Mode, const char* Preprocessing, Hlong NumComponents); #ifdef _WIN32 // create_class_svm: Create a support vector machine for pattern classification. explicit HClassSvm(Hlong NumFeatures, const wchar_t* KernelType, double KernelParam, double Nu, Hlong NumClasses, const wchar_t* Mode, const wchar_t* Preprocessing, Hlong NumComponents); #endif /*************************************************************************** * Operators * ***************************************************************************/ // Classify an image with a support vector machine. HRegion ClassifyImageClassSvm(const HImage& Image) const; // Add training samples from an image to the training data of a support vector machine. void AddSamplesImageClassSvm(const HImage& Image, const HRegion& ClassRegions) const; // Get the training data of a support vector machine (SVM). HClassTrainData GetClassTrainDataSvm() const; // Add training data to a support vector machine (SVM). void AddClassTrainDataSvm(const HClassTrainData& ClassTrainDataHandle) const; // Selects an optimal combination of features to classify the provided data. HTuple SelectFeatureSetSvm(const HClassTrainData& ClassTrainDataHandle, const HString& SelectionMethod, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score); // Selects an optimal combination of features to classify the provided data. HTuple SelectFeatureSetSvm(const HClassTrainData& ClassTrainDataHandle, const HString& SelectionMethod, const HString& GenParamName, double GenParamValue, HTuple* Score); // Selects an optimal combination of features to classify the provided data. HTuple SelectFeatureSetSvm(const HClassTrainData& ClassTrainDataHandle, const char* SelectionMethod, const char* GenParamName, double GenParamValue, HTuple* Score); #ifdef _WIN32 // Selects an optimal combination of features to classify the provided data. HTuple SelectFeatureSetSvm(const HClassTrainData& ClassTrainDataHandle, const wchar_t* SelectionMethod, const wchar_t* GenParamName, double GenParamValue, HTuple* Score); #endif // Create a look-up table using a Support-Vector-Machine to classify byte images. HClassLUT CreateClassLutSvm(const HTuple& GenParamName, const HTuple& GenParamValue) const; // Clear a support vector machine. static void ClearClassSvm(const HClassSvmArray& SVMHandle); // Clear a support vector machine. void ClearClassSvm() const; // Clear the training data of a support vector machine. static void ClearSamplesClassSvm(const HClassSvmArray& SVMHandle); // Clear the training data of a support vector machine. void ClearSamplesClassSvm() const; // Deserialize a serialized support vector machine (SVM). void DeserializeClassSvm(const HSerializedItem& SerializedItemHandle); // Serialize a support vector machine (SVM). HSerializedItem SerializeClassSvm() const; // Read a support vector machine from a file. void ReadClassSvm(const HString& FileName); // Read a support vector machine from a file. void ReadClassSvm(const char* FileName); #ifdef _WIN32 // Read a support vector machine from a file. void ReadClassSvm(const wchar_t* FileName); #endif // Write a support vector machine to a file. void WriteClassSvm(const HString& FileName) const; // Write a support vector machine to a file. void WriteClassSvm(const char* FileName) const; #ifdef _WIN32 // Write a support vector machine to a file. void WriteClassSvm(const wchar_t* FileName) const; #endif // Read the training data of a support vector machine from a file. void ReadSamplesClassSvm(const HString& FileName) const; // Read the training data of a support vector machine from a file. void ReadSamplesClassSvm(const char* FileName) const; #ifdef _WIN32 // Read the training data of a support vector machine from a file. void ReadSamplesClassSvm(const wchar_t* FileName) const; #endif // Write the training data of a support vector machine to a file. void WriteSamplesClassSvm(const HString& FileName) const; // Write the training data of a support vector machine to a file. void WriteSamplesClassSvm(const char* FileName) const; #ifdef _WIN32 // Write the training data of a support vector machine to a file. void WriteSamplesClassSvm(const wchar_t* FileName) const; #endif // Evaluate a feature vector by a support vector machine. HTuple EvaluateClassSvm(const HTuple& Features) const; // Classify a feature vector by a support vector machine. HTuple ClassifyClassSvm(const HTuple& Features, const HTuple& Num) const; // Approximate a trained support vector machine by a reduced support vector machine for faster classification. HClassSvm ReduceClassSvm(const HString& Method, Hlong MinRemainingSV, double MaxError) const; // Approximate a trained support vector machine by a reduced support vector machine for faster classification. HClassSvm ReduceClassSvm(const char* Method, Hlong MinRemainingSV, double MaxError) const; #ifdef _WIN32 // Approximate a trained support vector machine by a reduced support vector machine for faster classification. HClassSvm ReduceClassSvm(const wchar_t* Method, Hlong MinRemainingSV, double MaxError) const; #endif // Train a support vector machine. void TrainClassSvm(double Epsilon, const HTuple& TrainMode) const; // Train a support vector machine. void TrainClassSvm(double Epsilon, const HString& TrainMode) const; // Train a support vector machine. void TrainClassSvm(double Epsilon, const char* TrainMode) const; #ifdef _WIN32 // Train a support vector machine. void TrainClassSvm(double Epsilon, const wchar_t* TrainMode) const; #endif // Compute the information content of the preprocessed feature vectors of a support vector machine HTuple GetPrepInfoClassSvm(const HString& Preprocessing, HTuple* CumInformationCont) const; // Compute the information content of the preprocessed feature vectors of a support vector machine HTuple GetPrepInfoClassSvm(const char* Preprocessing, HTuple* CumInformationCont) const; #ifdef _WIN32 // Compute the information content of the preprocessed feature vectors of a support vector machine HTuple GetPrepInfoClassSvm(const wchar_t* Preprocessing, HTuple* CumInformationCont) const; #endif // Return the number of support vectors of a support vector machine. Hlong GetSupportVectorNumClassSvm(HTuple* NumSVPerSVM) const; // Return the index of a support vector from a trained support vector machine. double GetSupportVectorClassSvm(Hlong IndexSupportVector) const; // Return the number of training samples stored in the training data of a support vector machine. Hlong GetSampleNumClassSvm() const; // Return a training sample from the training data of a support vector machine. HTuple GetSampleClassSvm(Hlong IndexSample, Hlong* Target) const; // Add a training sample to the training data of a support vector machine. void AddSampleClassSvm(const HTuple& Features, const HTuple& Class) const; // Add a training sample to the training data of a support vector machine. void AddSampleClassSvm(const HTuple& Features, Hlong Class) const; // Return the parameters of a support vector machine. Hlong GetParamsClassSvm(HString* KernelType, double* KernelParam, double* Nu, Hlong* NumClasses, HString* Mode, HString* Preprocessing, Hlong* NumComponents) const; // Create a support vector machine for pattern classification. void CreateClassSvm(Hlong NumFeatures, const HString& KernelType, double KernelParam, double Nu, Hlong NumClasses, const HString& Mode, const HString& Preprocessing, Hlong NumComponents); // Create a support vector machine for pattern classification. void CreateClassSvm(Hlong NumFeatures, const char* KernelType, double KernelParam, double Nu, Hlong NumClasses, const char* Mode, const char* Preprocessing, Hlong NumComponents); #ifdef _WIN32 // Create a support vector machine for pattern classification. void CreateClassSvm(Hlong NumFeatures, const wchar_t* KernelType, double KernelParam, double Nu, Hlong NumClasses, const wchar_t* Mode, const wchar_t* Preprocessing, Hlong NumComponents); #endif }; // forward declarations and types for internal array implementation template class HSmartPtr; template class HHandleBaseArrayRef; typedef HHandleBaseArrayRef HClassSvmArrayRef; typedef HSmartPtr< HClassSvmArrayRef > HClassSvmArrayPtr; // Represents multiple tool instances class LIntExport HClassSvmArray : public HHandleBaseArray { public: // Create empty array HClassSvmArray(); // Create array from native array of tool instances HClassSvmArray(HClassSvm* classes, Hlong length); // Copy constructor HClassSvmArray(const HClassSvmArray &tool_array); // Destructor virtual ~HClassSvmArray(); // Assignment operator HClassSvmArray &operator=(const HClassSvmArray &tool_array); // Clears array and all tool instances virtual void Clear(); // Get array of native tool instances const HClassSvm* 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 HClassSvmArrayPtr *mArrayPtr; }; } #endif