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)]; diff --git a/src/bindings/csharp/openalpr-net/openalpr-net.cpp b/src/bindings/csharp/openalpr-net/openalpr-net.cpp index e2e114a..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,8 +428,9 @@ 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 buffer = AlprHelper::ToVector(imageBuffer); + std::vector rois = AlprHelper::ToVector(regionsOfInterest); + AlprResults results = m_Impl->recognize(buffer, rois); return gcnew AlprResultsNet(results); } 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..02975c2 100644 --- a/src/openalpr/alpr_impl.cpp +++ b/src/openalpr/alpr_impl.cpp @@ -345,6 +345,16 @@ namespace alpr return this->recognize(img); } + AlprResults AlprImpl::recognize(std::vector imageBytes, std::vector regionsOfInterest) + { + cv::Mat img = cv::imdecode(cv::Mat(imageBytes), 1); + + 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) { 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 );