From 2fc60ae0bea84c944d02ff5e2b23f20eda5dfe3a Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Fri, 7 Aug 2015 11:21:22 +0200 Subject: [PATCH 1/5] Add overload for regionsOfInterest. --- src/openalpr/alpr.cpp | 5 +++++ src/openalpr/alpr.h | 7 +++++-- src/openalpr/alpr_impl.cpp | 7 +++++++ src/openalpr/alpr_impl.h | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/openalpr/alpr.cpp b/src/openalpr/alpr.cpp index 840b96b..a89ce21 100644 --- a/src/openalpr/alpr.cpp +++ b/src/openalpr/alpr.cpp @@ -68,6 +68,11 @@ namespace alpr return impl->recognize(imageBytes); } + AlprResults Alpr::recognize(std::vector imageBytes, std::vector regionsOfInterest) + { + return impl->recognize(imageBytes, regionsOfInterest); + } + AlprResults Alpr::recognize(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector regionsOfInterest) { return impl->recognize(pixelData, bytesPerPixel, imgWidth, imgHeight, regionsOfInterest); diff --git a/src/openalpr/alpr.h b/src/openalpr/alpr.h index 7146322..c94ed9b 100644 --- a/src/openalpr/alpr.h +++ b/src/openalpr/alpr.h @@ -132,8 +132,11 @@ namespace alpr // Recognize from an image on disk AlprResults recognize(std::string filepath); - // Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc). - AlprResults recognize(std::vector imageBytes); + // Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc). + AlprResults recognize(std::vector imageBytes); + + // Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc). + AlprResults recognize(std::vector imageBytes, std::vector regionsOfInterest); // Recognize from raw pixel data. AlprResults recognize(unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector regionsOfInterest); diff --git a/src/openalpr/alpr_impl.cpp b/src/openalpr/alpr_impl.cpp index fc8ca37..aa10796 100644 --- a/src/openalpr/alpr_impl.cpp +++ b/src/openalpr/alpr_impl.cpp @@ -345,6 +345,13 @@ namespace alpr return this->recognize(img); } + AlprResults AlprImpl::recognize(std::vector imageBytes, std::vector regionsOfInterest) + { + cv::Mat img = cv::imdecode(cv::Mat(imageBytes), 1); + + return this->recognize(img, regionsOfInterest); + } + AlprResults AlprImpl::recognize( unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector regionsOfInterest) { diff --git a/src/openalpr/alpr_impl.h b/src/openalpr/alpr_impl.h index f5fcbd9..776807b 100644 --- a/src/openalpr/alpr_impl.h +++ b/src/openalpr/alpr_impl.h @@ -76,6 +76,7 @@ namespace alpr AlprFullDetails recognizeFullDetails(cv::Mat img, std::vector regionsOfInterest); AlprResults recognize( std::vector imageBytes ); + AlprResults recognize( std::vector imageBytes, std::vector regionsOfInterest ); AlprResults recognize( unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector regionsOfInterest ); AlprResults recognize( cv::Mat img ); AlprResults recognize( cv::Mat img, std::vector regionsOfInterest ); From 3f63dab7e1a857d474ace3ec5e80fcc5b390bb11 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Fri, 7 Aug 2015 11:23:12 +0200 Subject: [PATCH 2/5] Bugfix: Regions of interest. --- src/bindings/csharp/openalpr-net/openalpr-net.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bindings/csharp/openalpr-net/openalpr-net.cpp b/src/bindings/csharp/openalpr-net/openalpr-net.cpp index e2e114a..f109740 100644 --- a/src/bindings/csharp/openalpr-net/openalpr-net.cpp +++ b/src/bindings/csharp/openalpr-net/openalpr-net.cpp @@ -428,7 +428,8 @@ namespace openalprnet { /// Bytes representing image data AlprResultsNet^ Recognize(cli::array^ imageBuffer, List^ regionsOfInterest) { std::vector p = AlprHelper::ToVector(imageBuffer); - AlprResults results = m_Impl->recognize(p); + std::vector rois = AlprHelper::ToVector(regionsOfInterest); + AlprResults results = m_Impl->recognize(p, rois); return gcnew AlprResultsNet(results); } From 1729f48ba8ab790a00d5acb75f41d6f073dd8f6a Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Fri, 7 Aug 2015 14:30:17 +0200 Subject: [PATCH 3/5] Fix visual studio deprecation warning. --- src/bindings/csharp/openalpr-net/AssemblyInfo.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bindings/csharp/openalpr-net/AssemblyInfo.cpp b/src/bindings/csharp/openalpr-net/AssemblyInfo.cpp index ac5af8d..cc20aa3 100644 --- a/src/bindings/csharp/openalpr-net/AssemblyInfo.cpp +++ b/src/bindings/csharp/openalpr-net/AssemblyInfo.cpp @@ -38,5 +38,3 @@ using namespace System::Security::Permissions; [assembly:ComVisible(false)]; [assembly:CLSCompliantAttribute(true)]; - -[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; From 3ff3e31bf87247a85f511ec042c765ec026bce66 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Fri, 7 Aug 2015 14:33:39 +0200 Subject: [PATCH 4/5] Bugfix: Stackoverflow. --- src/openalpr/alpr_impl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openalpr/alpr_impl.cpp b/src/openalpr/alpr_impl.cpp index aa10796..02975c2 100644 --- a/src/openalpr/alpr_impl.cpp +++ b/src/openalpr/alpr_impl.cpp @@ -349,7 +349,10 @@ namespace alpr { cv::Mat img = cv::imdecode(cv::Mat(imageBytes), 1); - return this->recognize(img, regionsOfInterest); + std::vector rois = convertRects(regionsOfInterest); + + AlprFullDetails fullDetails = recognizeFullDetails(img, rois); + return fullDetails.results; } AlprResults AlprImpl::recognize( unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector regionsOfInterest) From 31d502194aa874e617b73f6cc2c2b41fe5d93835 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Fri, 7 Aug 2015 14:34:22 +0200 Subject: [PATCH 5/5] Bugfix: Region of interest. --- src/bindings/csharp/openalpr-net/openalpr-net.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bindings/csharp/openalpr-net/openalpr-net.cpp b/src/bindings/csharp/openalpr-net/openalpr-net.cpp index f109740..a691f20 100644 --- a/src/bindings/csharp/openalpr-net/openalpr-net.cpp +++ b/src/bindings/csharp/openalpr-net/openalpr-net.cpp @@ -409,8 +409,9 @@ namespace openalprnet { /// AlprResultsNet^ Recognize(MemoryStream^ memoryStream, List^ regionsOfInterest) { - std::vector p = AlprHelper::MemoryStreamToVector(memoryStream); - AlprResults results = m_Impl->recognize(p); + std::vector buffer = AlprHelper::MemoryStreamToVector(memoryStream); + std::vector rois = AlprHelper::ToVector(regionsOfInterest); + AlprResults results = m_Impl->recognize(buffer, rois); return gcnew AlprResultsNet(results); } @@ -427,9 +428,9 @@ namespace openalprnet { /// /// Bytes representing image data AlprResultsNet^ Recognize(cli::array^ imageBuffer, List^ regionsOfInterest) { - std::vector p = AlprHelper::ToVector(imageBuffer); + std::vector buffer = AlprHelper::ToVector(imageBuffer); std::vector rois = AlprHelper::ToVector(regionsOfInterest); - AlprResults results = m_Impl->recognize(p, rois); + AlprResults results = m_Impl->recognize(buffer, rois); return gcnew AlprResultsNet(results); }