272 lines
10 KiB
C++
272 lines
10 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_HCLASSMLP
|
||
|
|
#define HCPP_HCLASSMLP
|
||
|
|
|
||
|
|
namespace HalconCpp
|
||
|
|
{
|
||
|
|
|
||
|
|
// Represents an instance of a multilayer perceptron.
|
||
|
|
class LIntExport HClassMlp : public HHandle
|
||
|
|
{
|
||
|
|
|
||
|
|
public:
|
||
|
|
|
||
|
|
// Create an uninitialized instance
|
||
|
|
HClassMlp():HHandle() {}
|
||
|
|
|
||
|
|
// Copy constructor
|
||
|
|
HClassMlp(const HClassMlp& source) : HHandle(source) {}
|
||
|
|
|
||
|
|
// Copy constructor
|
||
|
|
HClassMlp(const HHandle& handle);
|
||
|
|
|
||
|
|
// Create HClassMlp from handle, taking ownership
|
||
|
|
explicit HClassMlp(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_mlp')!
|
||
|
|
virtual void AssertType(Hphandle handle) const;
|
||
|
|
|
||
|
|
public:
|
||
|
|
|
||
|
|
// Deep copy of all data represented by this object instance
|
||
|
|
HClassMlp Clone() const;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/*****************************************************************************
|
||
|
|
* Operator-based class constructors
|
||
|
|
*****************************************************************************/
|
||
|
|
|
||
|
|
// read_class_mlp: Read a multilayer perceptron from a file.
|
||
|
|
explicit HClassMlp(const HString& FileName);
|
||
|
|
|
||
|
|
// read_class_mlp: Read a multilayer perceptron from a file.
|
||
|
|
explicit HClassMlp(const char* FileName);
|
||
|
|
|
||
|
|
// create_class_mlp: Create a multilayer perceptron for classification or regression.
|
||
|
|
explicit HClassMlp(Hlong NumInput, Hlong NumHidden, Hlong NumOutput, const HString& OutputFunction, const HString& Preprocessing, Hlong NumComponents, Hlong RandSeed);
|
||
|
|
|
||
|
|
// create_class_mlp: Create a multilayer perceptron for classification or regression.
|
||
|
|
explicit HClassMlp(Hlong NumInput, Hlong NumHidden, Hlong NumOutput, const char* OutputFunction, const char* Preprocessing, Hlong NumComponents, Hlong RandSeed);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/***************************************************************************
|
||
|
|
* Operators *
|
||
|
|
***************************************************************************/
|
||
|
|
|
||
|
|
// Classify an image with a multilayer perceptron.
|
||
|
|
HRegion ClassifyImageClassMlp(const HImage& Image, double RejectionThreshold) const;
|
||
|
|
|
||
|
|
// Add training samples from an image to the training data of a multilayer perceptron.
|
||
|
|
void AddSamplesImageClassMlp(const HImage& Image, const HRegion& ClassRegions) const;
|
||
|
|
|
||
|
|
// Get the training data of a multilayer perceptron (MLP).
|
||
|
|
HClassTrainData GetClassTrainDataMlp() const;
|
||
|
|
|
||
|
|
// Add training data to a multilayer perceptron (MLP).
|
||
|
|
void AddClassTrainDataMlp(const HClassTrainData& ClassTrainDataHandle) const;
|
||
|
|
|
||
|
|
// Selects an optimal combination of features to classify the provided data.
|
||
|
|
HTuple SelectFeatureSetMlp(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 SelectFeatureSetMlp(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 SelectFeatureSetMlp(const HClassTrainData& ClassTrainDataHandle, const char* SelectionMethod, const char* GenParamName, double GenParamValue, HTuple* Score);
|
||
|
|
|
||
|
|
// Create a look-up table using a multi-layer perceptron to classify byte images.
|
||
|
|
HClassLUT CreateClassLutMlp(const HTuple& GenParamName, const HTuple& GenParamValue) const;
|
||
|
|
|
||
|
|
// Clear a multilayer perceptron.
|
||
|
|
static void ClearClassMlp(const HClassMlpArray& MLPHandle);
|
||
|
|
|
||
|
|
// Clear a multilayer perceptron.
|
||
|
|
void ClearClassMlp() const;
|
||
|
|
|
||
|
|
// Clear the training data of a multilayer perceptron.
|
||
|
|
static void ClearSamplesClassMlp(const HClassMlpArray& MLPHandle);
|
||
|
|
|
||
|
|
// Clear the training data of a multilayer perceptron.
|
||
|
|
void ClearSamplesClassMlp() const;
|
||
|
|
|
||
|
|
// Deserialize a serialized multilayer perceptron.
|
||
|
|
void DeserializeClassMlp(const HSerializedItem& SerializedItemHandle);
|
||
|
|
|
||
|
|
// Serialize a multilayer perceptron (MLP).
|
||
|
|
HSerializedItem SerializeClassMlp() const;
|
||
|
|
|
||
|
|
// Read a multilayer perceptron from a file.
|
||
|
|
void ReadClassMlp(const HString& FileName);
|
||
|
|
|
||
|
|
// Read a multilayer perceptron from a file.
|
||
|
|
void ReadClassMlp(const char* FileName);
|
||
|
|
|
||
|
|
// Write a multilayer perceptron to a file.
|
||
|
|
void WriteClassMlp(const HString& FileName) const;
|
||
|
|
|
||
|
|
// Write a multilayer perceptron to a file.
|
||
|
|
void WriteClassMlp(const char* FileName) const;
|
||
|
|
|
||
|
|
// Read the training data of a multilayer perceptron from a file.
|
||
|
|
void ReadSamplesClassMlp(const HString& FileName) const;
|
||
|
|
|
||
|
|
// Read the training data of a multilayer perceptron from a file.
|
||
|
|
void ReadSamplesClassMlp(const char* FileName) const;
|
||
|
|
|
||
|
|
// Write the training data of a multilayer perceptron to a file.
|
||
|
|
void WriteSamplesClassMlp(const HString& FileName) const;
|
||
|
|
|
||
|
|
// Write the training data of a multilayer perceptron to a file.
|
||
|
|
void WriteSamplesClassMlp(const char* FileName) const;
|
||
|
|
|
||
|
|
// Calculate the class of a feature vector by a multilayer perceptron.
|
||
|
|
HTuple ClassifyClassMlp(const HTuple& Features, const HTuple& Num, HTuple* Confidence) const;
|
||
|
|
|
||
|
|
// Calculate the class of a feature vector by a multilayer perceptron.
|
||
|
|
Hlong ClassifyClassMlp(const HTuple& Features, const HTuple& Num, double* Confidence) const;
|
||
|
|
|
||
|
|
// Calculate the evaluation of a feature vector by a multilayer perceptron.
|
||
|
|
HTuple EvaluateClassMlp(const HTuple& Features) const;
|
||
|
|
|
||
|
|
// Train a multilayer perceptron.
|
||
|
|
double TrainClassMlp(Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const;
|
||
|
|
|
||
|
|
// Compute the information content of the preprocessed feature vectors of a multilayer perceptron.
|
||
|
|
HTuple GetPrepInfoClassMlp(const HString& Preprocessing, HTuple* CumInformationCont) const;
|
||
|
|
|
||
|
|
// Compute the information content of the preprocessed feature vectors of a multilayer perceptron.
|
||
|
|
HTuple GetPrepInfoClassMlp(const char* Preprocessing, HTuple* CumInformationCont) const;
|
||
|
|
|
||
|
|
// Return the number of training samples stored in the training data of a multilayer perceptron.
|
||
|
|
Hlong GetSampleNumClassMlp() const;
|
||
|
|
|
||
|
|
// Return a training sample from the training data of a multilayer perceptron.
|
||
|
|
HTuple GetSampleClassMlp(Hlong IndexSample, HTuple* Target) const;
|
||
|
|
|
||
|
|
// Get the parameters of a rejection class.
|
||
|
|
HTuple GetRejectionParamsClassMlp(const HTuple& GenParamName) const;
|
||
|
|
|
||
|
|
// Get the parameters of a rejection class.
|
||
|
|
HTuple GetRejectionParamsClassMlp(const HString& GenParamName) const;
|
||
|
|
|
||
|
|
// Get the parameters of a rejection class.
|
||
|
|
HTuple GetRejectionParamsClassMlp(const char* GenParamName) const;
|
||
|
|
|
||
|
|
// Set the parameters of a rejection class.
|
||
|
|
void SetRejectionParamsClassMlp(const HTuple& GenParamName, const HTuple& GenParamValue) const;
|
||
|
|
|
||
|
|
// Set the parameters of a rejection class.
|
||
|
|
void SetRejectionParamsClassMlp(const HString& GenParamName, const HString& GenParamValue) const;
|
||
|
|
|
||
|
|
// Set the parameters of a rejection class.
|
||
|
|
void SetRejectionParamsClassMlp(const char* GenParamName, const char* GenParamValue) const;
|
||
|
|
|
||
|
|
// Add a training sample to the training data of a multilayer perceptron.
|
||
|
|
void AddSampleClassMlp(const HTuple& Features, const HTuple& Target) const;
|
||
|
|
|
||
|
|
// Add a training sample to the training data of a multilayer perceptron.
|
||
|
|
void AddSampleClassMlp(const HTuple& Features, Hlong Target) const;
|
||
|
|
|
||
|
|
// Return the regularization parameters of a multilayer perceptron.
|
||
|
|
HTuple GetRegularizationParamsClassMlp(const HString& GenParamName) const;
|
||
|
|
|
||
|
|
// Return the regularization parameters of a multilayer perceptron.
|
||
|
|
HTuple GetRegularizationParamsClassMlp(const char* GenParamName) const;
|
||
|
|
|
||
|
|
// Set the regularization parameters of a multilayer perceptron.
|
||
|
|
void SetRegularizationParamsClassMlp(const HString& GenParamName, const HTuple& GenParamValue) const;
|
||
|
|
|
||
|
|
// Set the regularization parameters of a multilayer perceptron.
|
||
|
|
void SetRegularizationParamsClassMlp(const HString& GenParamName, double GenParamValue) const;
|
||
|
|
|
||
|
|
// Set the regularization parameters of a multilayer perceptron.
|
||
|
|
void SetRegularizationParamsClassMlp(const char* GenParamName, double GenParamValue) const;
|
||
|
|
|
||
|
|
// Return the parameters of a multilayer perceptron.
|
||
|
|
Hlong GetParamsClassMlp(Hlong* NumHidden, Hlong* NumOutput, HString* OutputFunction, HString* Preprocessing, Hlong* NumComponents) const;
|
||
|
|
|
||
|
|
// Create a multilayer perceptron for classification or regression.
|
||
|
|
void CreateClassMlp(Hlong NumInput, Hlong NumHidden, Hlong NumOutput, const HString& OutputFunction, const HString& Preprocessing, Hlong NumComponents, Hlong RandSeed);
|
||
|
|
|
||
|
|
// Create a multilayer perceptron for classification or regression.
|
||
|
|
void CreateClassMlp(Hlong NumInput, Hlong NumHidden, Hlong NumOutput, const char* OutputFunction, const char* Preprocessing, Hlong NumComponents, Hlong RandSeed);
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
// forward declarations and types for internal array implementation
|
||
|
|
|
||
|
|
template<class T> class HSmartPtr;
|
||
|
|
template<class T> class HHandleBaseArrayRef;
|
||
|
|
|
||
|
|
typedef HHandleBaseArrayRef<HClassMlp> HClassMlpArrayRef;
|
||
|
|
typedef HSmartPtr< HClassMlpArrayRef > HClassMlpArrayPtr;
|
||
|
|
|
||
|
|
|
||
|
|
// Represents multiple tool instances
|
||
|
|
class LIntExport HClassMlpArray : public HHandleBaseArray
|
||
|
|
{
|
||
|
|
|
||
|
|
public:
|
||
|
|
|
||
|
|
// Create empty array
|
||
|
|
HClassMlpArray();
|
||
|
|
|
||
|
|
// Create array from native array of tool instances
|
||
|
|
HClassMlpArray(HClassMlp* classes, Hlong length);
|
||
|
|
|
||
|
|
// Copy constructor
|
||
|
|
HClassMlpArray(const HClassMlpArray &tool_array);
|
||
|
|
|
||
|
|
// Destructor
|
||
|
|
virtual ~HClassMlpArray();
|
||
|
|
|
||
|
|
// Assignment operator
|
||
|
|
HClassMlpArray &operator=(const HClassMlpArray &tool_array);
|
||
|
|
|
||
|
|
// Clears array and all tool instances
|
||
|
|
virtual void Clear();
|
||
|
|
|
||
|
|
// Get array of native tool instances
|
||
|
|
const HClassMlp* 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
|
||
|
|
HClassMlpArrayPtr *mArrayPtr;
|
||
|
|
};
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif
|