diff --git a/src/bindings/csharp/openalpr-net/openalpr-net.cpp b/src/bindings/csharp/openalpr-net/openalpr-net.cpp index 521988a..17ea868 100644 --- a/src/bindings/csharp/openalpr-net/openalpr-net.cpp +++ b/src/bindings/csharp/openalpr-net/openalpr-net.cpp @@ -19,6 +19,7 @@ #include "stdafx.h" #include "openalpr-net.h" #include "alpr.h" +#include "config.h" // alpr #include #include #include @@ -89,6 +90,655 @@ namespace openalprnet { } }; + public enum class AlprDetectorTypeNet : int { + DetectorLbpCpu = alpr::DETECTOR_LBP_CPU, + DetectorLbpGpu = alpr::DETECTOR_LBP_GPU, + DetectorLbpMorphCpu = alpr::DETECTOR_MORPH_CPU + }; + + public ref class AlprConfigNet sealed + { + public: + + AlprConfigNet(Config* config) : m_config (config) + { + + } + + property bool IsLoaded { + bool get() + { + return this->m_config->loaded; + } + } + + property AlprDetectorTypeNet Detector { + AlprDetectorTypeNet get() { + return static_cast(this->m_config->detector); + } + void set(AlprDetectorTypeNet value) + { + this->m_config->detector = static_cast(value); + } + } + + property float DetectionIterationIncrease { + float get() + { + return this->m_config->detection_iteration_increase; + } + void set(float value) + { + this->m_config->detection_iteration_increase = value; + } + } + + property float DetectionStrictness { + float get() + { + return this->m_config->detectionStrictness; + } + void set(float value) + { + this->m_config->detectionStrictness = value; + } + } + + property float MaxPlateWidthPercent { + float get() + { + return this->m_config->maxPlateWidthPercent; + } + void set(float value) + { + this->m_config->maxPlateWidthPercent = value; + } + } + + property float MaxPlateHeightPercent { + float get() + { + return this->m_config->maxPlateHeightPercent; + } + void set(float value) + { + this->m_config->maxPlateHeightPercent = value; + } + } + + property int MaxDetectionInputWidth { + int get() + { + return this->m_config->maxDetectionInputWidth; + } + void set(int value) + { + this->m_config->maxDetectionInputWidth = value; + } + } + + property int MaxDetectionInputHeight { + int get() + { + return this->m_config->maxDetectionInputHeight; + } + void set(int value) + { + this->m_config->maxDetectionInputHeight = value; + } + } + + property bool SkipDetection { + bool get() + { + return this->m_config->skipDetection; + } + void set(bool value) + { + this->m_config->skipDetection = true; + } + } + + property String^ PreWarp { + String^ get() + { + return AlprHelper::ToManagedString(this->m_config->prewarp); + } + void set(String^ value) + { + this->m_config->prewarp = marshal_as(value); + } + } + + property int MaxPlateAngleDegrees { + int get() + { + return this->m_config->maxPlateAngleDegrees; + } + void set(int value) + { + this->m_config->maxPlateAngleDegrees = value; + } + } + + property float MinPlateSizeWidthPx { + float get() + { + return this->m_config->minPlateSizeWidthPx; + } + void set(float value) + { + this->m_config->minPlateSizeWidthPx = value; + } + } + + property float minPlateSizeHeightPx { + float get() + { + return this->m_config->minPlateSizeHeightPx; + } + void set(float value) + { + this->m_config->minPlateSizeHeightPx = value; + } + } + + property bool Multiline { + bool get() + { + return this->m_config->multiline; + } + void set(bool value) + { + this->m_config->multiline = value; + } + } + + property float PlateWidthMM { + float get() + { + return this->m_config->plateWidthMM; + } + void set(float value) + { + this->m_config->plateWidthMM = value; + } + } + + property float PlateHeightMM { + float get() + { + return this->m_config->plateHeightMM; + } + void set(float value) + { + this->m_config->plateHeightMM = value; + } + } + + property float CharHeightMM { + float get() + { + return this->m_config->charHeightMM; + } + void set(float value) + { + this->m_config->charHeightMM = value; + } + } + + property float CharWidthMM { + float get() + { + return this->m_config->charWidthMM; + } + void set(float value) + { + this->m_config->charWidthMM = value; + } + } + + property float CharWhitespaceTopMM { + float get() + { + return this->m_config->charWhitespaceTopMM; + } + void set(float value) + { + this->m_config->charWhitespaceTopMM = value; + } + } + + property float CharWhitespaceBotMM { + float get() + { + return this->m_config->charWhitespaceBotMM; + } + void set(float value) + { + this->m_config->charWhitespaceBotMM = value; + } + } + + property int TemplateWidthPx { + int get() + { + return this->m_config->templateWidthPx; + } + void set(int value) + { + this->m_config->templateWidthPx = value; + } + } + + property int TemplateHeightPx { + int get() + { + return this->m_config->templateHeightPx; + } + void set(int value) + { + this->m_config->templateHeightPx = value; + } + } + + property int OcrImageWidthPx { + int get() + { + return this->m_config->ocrImageWidthPx; + } + void set(int value) + { + this->m_config->ocrImageWidthPx = value; + } + } + + property int OcrImageHeightPx { + int get() + { + return this->m_config->ocrImageHeightPx; + } + void set(int value) + { + this->m_config->ocrImageHeightPx = value; + } + } + + property int StateIdImageWidthPx { + int get() + { + return this->m_config->stateIdImageWidthPx; + } + void set(int value) + { + this->m_config->stateIdImageWidthPx = value; + } + } + + property int StateIdimageHeightPx { + int get() + { + return this->m_config->stateIdimageHeightPx; + } + void set(int value) + { + this->m_config->stateIdimageHeightPx = value; + } + } + + property float CharAnalysisMinPercent { + float get() + { + return this->m_config->charAnalysisMinPercent; + } + void set(float value) + { + this->m_config->charAnalysisMinPercent = value; + } + } + + property float CharAnalysisHeightRange { + float get() + { + return this->m_config->charAnalysisHeightRange; + } + void set(float value) + { + this->m_config->charAnalysisHeightRange = value; + } + } + + property float CharAnalysisHeightStepSize { + float get() + { + return this->m_config->charAnalysisHeightStepSize; + } + void set(float value) + { + this->m_config->charAnalysisHeightStepSize = value; + } + } + + property int CharAnalysisNumSteps { + int get() + { + return this->m_config->charAnalysisNumSteps; + } + void set(int value) + { + this->m_config->charAnalysisNumSteps = value; + } + } + + property float PlateLinesSensitivityVertical { + float get() + { + return this->m_config->plateLinesSensitivityVertical; + } + void set(float value) + { + this->m_config->plateLinesSensitivityVertical = value; + } + } + + property float PlateLinesSensitivityHorizontal { + float get() + { + return this->m_config->plateLinesSensitivityHorizontal; + } + void set(float value) + { + this->m_config->plateLinesSensitivityHorizontal = value; + } + } + + property int SegmentationMinBoxWidthPx { + int get() + { + return this->m_config->segmentationMinBoxWidthPx; + } + void set(int value) + { + this->m_config->segmentationMinBoxWidthPx = value; + } + } + + property float SegmentationMinCharHeightPercent { + float get() + { + return this->m_config->segmentationMinCharHeightPercent; + } + void set(float value) + { + this->m_config->segmentationMinCharHeightPercent = value; + } + } + + property float SegmentationMaxCharWidthvsAverage { + float get() + { + return this->m_config->segmentationMaxCharWidthvsAverage; + } + void set(float value) + { + this->m_config->segmentationMaxCharWidthvsAverage = value; + } + } + + property String^ OcrLanguage { + String^ get() + { + return AlprHelper::ToManagedString(this->m_config->ocrLanguage); + } + void set(String^ value) + { + this->m_config->ocrLanguage = marshal_as(value); + } + } + + property int OcrMinFontSize { + int get() + { + return this->m_config->ocrMinFontSize; + } + void set(int value) + { + this->m_config->ocrMinFontSize = value; + } + } + + property float PostProcessMinConfidence { + float get() + { + return this->m_config->postProcessMinConfidence; + } + void set(float value) + { + this->m_config->postProcessMinConfidence = value; + } + } + + property float PostProcessConfidenceSkipLevel { + float get() + { + return this->m_config->postProcessConfidenceSkipLevel; + } + void set(float value) + { + this->m_config->postProcessConfidenceSkipLevel = value; + } + } + + property unsigned int PostProcessMinCharacters { + unsigned int get() + { + return this->m_config->postProcessMinCharacters; + } + void set(unsigned int value) + { + this->m_config->postProcessMinCharacters = value; + } + } + + property unsigned int PostProcessMaxCharacters { + unsigned int get() + { + return this->m_config->postProcessMaxCharacters; + } + void set(unsigned int value) + { + this->m_config->postProcessMaxCharacters = value; + } + } + + property bool DebugGeneral { + bool get() + { + return this->m_config->debugGeneral; + } + void set(bool value) + { + this->m_config->debugGeneral = value; + } + } + + property bool DebugTiming { + bool get() + { + return this->m_config->debugTiming; + } + void set(bool value) + { + this->m_config->debugTiming = value; + } + } + + property bool DebugPrewarp { + bool get() + { + return this->m_config->debugPrewarp; + } + void set(bool value) + { + this->m_config->debugPrewarp = value; + } + } + + property bool DebugDetector { + bool get() + { + return this->m_config->debugDetector; + } + void set(bool value) + { + this->m_config->debugDetector = value; + } + } + + property bool DebugStateId { + bool get() + { + return this->m_config->debugStateId; + } + void set(bool value) + { + this->m_config->debugStateId = value; + } + } + + property bool DebugPlateLines { + bool get() + { + return this->m_config->debugPlateLines; + } + void set(bool value) + { + this->m_config->debugPlateLines = value; + } + } + + property bool DebugPlateCorners { + bool get() + { + return this->m_config->debugPlateCorners; + } + void set(bool value) + { + this->m_config->debugPlateCorners = value; + } + } + + property bool DebugCharSegmenter { + bool get() + { + return this->m_config->debugCharSegmenter; + } + void set(bool value) + { + this->m_config->debugCharSegmenter = value; + } + } + + property bool DebugCharAnalysis { + bool get() + { + return this->m_config->debugCharAnalysis; + } + void set(bool value) + { + this->m_config->debugCharAnalysis = value; + } + } + + property bool DebugColorFiler { + bool get() + { + return this->m_config->debugColorFiler; + } + void set(bool value) + { + this->m_config->debugColorFiler = value; + } + } + + property bool DebugOcr { + bool get() + { + return this->m_config->debugOcr; + } + void set(bool value) + { + this->m_config->debugOcr = value; + } + } + + property bool DebugPostProcess { + bool get() + { + return this->m_config->debugPostProcess; + } + void set(bool value) + { + this->m_config->debugPostProcess = value; + } + } + + property bool DebugShowImages { + bool get() + { + return this->m_config->debugShowImages; + } + void set(bool value) + { + this->m_config->debugShowImages = value; + } + } + + property bool DebugPauseOnFrame { + bool get() + { + return this->m_config->debugPauseOnFrame; + } + void set(bool value) + { + this->m_config->debugPauseOnFrame = value; + } + } + + void DebugOff(bool value) + { + this->m_config->debugOff(value); + } + + String^ GetKeypointsRuntimeDir() + { + return AlprHelper::ToManagedString(this->m_config->getKeypointsRuntimeDir()); + } + + String^ GetCascadeRuntimeDir() + { + return AlprHelper::ToManagedString(this->m_config->getCascadeRuntimeDir()); + } + + String^ GetPostProcessRuntimeDir() + { + return AlprHelper::ToManagedString(this->m_config->getPostProcessRuntimeDir()); + } + + String^ GetTessdataPrefix() + { + return AlprHelper::ToManagedString(this->m_config->getTessdataPrefix()); + } + + ~AlprConfigNet() + { + // void + } + + private: + Config *m_config; + }; + public ref class AlprPlateNet sealed { public: @@ -338,13 +988,23 @@ namespace openalprnet { { public: // Allocate the native object on the C++ Heap via a constructor - AlprNet(System::String^ country, System::String^ configFile, System::String^ runtimeDir) : m_Impl( new Alpr(marshal_as(country), marshal_as(configFile), marshal_as(runtimeDir)) ) { } + AlprNet(System::String^ country, System::String^ configFile, System::String^ runtimeDir) : m_Impl( new Alpr(marshal_as(country), marshal_as(configFile), marshal_as(runtimeDir)) ) + { + this->m_config = gcnew AlprConfigNet(this->m_Impl->getConfig()); + } // Deallocate the native object on a destructor ~AlprNet(){ delete m_Impl; } + property AlprConfigNet^ Configuration { + AlprConfigNet^ get() + { + return this->m_config; + } + } + property int TopN { int get() { return m_topN; @@ -459,10 +1119,12 @@ namespace openalprnet { // Deallocate the native object on the finalizer just in case no destructor is called !AlprNet() { delete m_Impl; + delete m_config; } - + private: Alpr * m_Impl; + AlprConfigNet^ m_config; int m_topN; bool m_detectRegion; System::String^ m_defaultRegion; diff --git a/src/openalpr/alpr.cpp b/src/openalpr/alpr.cpp index bb4bf28..840b96b 100644 --- a/src/openalpr/alpr.cpp +++ b/src/openalpr/alpr.cpp @@ -108,5 +108,8 @@ namespace alpr return AlprImpl::getVersion(); } - + Config* Alpr::getConfig() + { + return impl->config; + } } \ No newline at end of file diff --git a/src/openalpr/alpr.h b/src/openalpr/alpr.h index 9c90a88..7146322 100644 --- a/src/openalpr/alpr.h +++ b/src/openalpr/alpr.h @@ -116,6 +116,7 @@ namespace alpr }; + class Config; class AlprImpl; class Alpr { @@ -145,6 +146,8 @@ namespace alpr static std::string getVersion(); + Config* getConfig(); + private: AlprImpl* impl; }; diff --git a/src/openalpr/config.cpp b/src/openalpr/config.cpp index 7146a4c..d89b7a3 100644 --- a/src/openalpr/config.cpp +++ b/src/openalpr/config.cpp @@ -241,19 +241,19 @@ namespace alpr } - void Config::debugOff() + void Config::debugOff(bool value) { - debugGeneral = false; - debugTiming = false; - debugStateId = false; - debugPlateLines = false; - debugPlateCorners = false; - debugCharSegmenter = false; - debugCharAnalysis = false; - debugColorFiler = false; - debugOcr = false; - debugPostProcess = false; - debugPauseOnFrame = false; + debugGeneral = !value; + debugTiming = !value; + debugStateId = !value; + debugPlateLines = !value; + debugPlateCorners = !value; + debugCharSegmenter = !value; + debugCharAnalysis = !value; + debugColorFiler = !value; + debugOcr = !value; + debugPostProcess = !value; + debugPauseOnFrame = !value; } diff --git a/src/openalpr/config.h b/src/openalpr/config.h index aad1588..2a1105c 100644 --- a/src/openalpr/config.h +++ b/src/openalpr/config.h @@ -119,7 +119,7 @@ namespace alpr bool debugShowImages; bool debugPauseOnFrame; - void debugOff(); + void debugOff(bool value); std::string getKeypointsRuntimeDir(); std::string getCascadeRuntimeDir();