diff --git a/src/bindings/csharp/openalpr-net/openalpr-net.cpp b/src/bindings/csharp/openalpr-net/openalpr-net.cpp index d2d6cde..6aa2a39 100644 --- a/src/bindings/csharp/openalpr-net/openalpr-net.cpp +++ b/src/bindings/csharp/openalpr-net/openalpr-net.cpp @@ -380,19 +380,6 @@ namespace openalprnet { return Recognize(bitmap, gcnew List()); } - /// - /// Recognize from a bitmap - /// - AlprResultsNet^ Recognize(Bitmap^ bitmap, List^ regionsOfInterest) - { - BitmapMat^ wrapper = gcnew BitmapMat(bitmap); - cv::Mat frame = wrapper->Value; - std::vector rois = AlprHelper::ToVector(regionsOfInterest); - AlprResults results = m_Impl->recognize(frame.data, frame.elemSize(), frame.cols, frame.rows, rois); - delete wrapper; - return gcnew AlprResultsNet(results); - } - /// /// Recognize from MemoryStream representing an encoded image (e.g., BMP, PNG, JPG, GIF etc). /// @@ -412,38 +399,29 @@ namespace openalprnet { /// /// Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc). /// - /// Bytes representing image data AlprResultsNet^ Recognize(array^ imageBuffer) { return Recognize(imageBuffer, gcnew List()); } + /// + /// Recognize from a bitmap + /// + AlprResultsNet^ Recognize(Bitmap^ bitmap, List^ regionsOfInterest) + { + BitmapMat^ wrapper = gcnew BitmapMat(bitmap); + AlprResultsNet^ results = Recognize(wrapper, regionsOfInterest); + delete wrapper; + return results; + } + /// /// Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc). /// - /// Bytes representing image data AlprResultsNet^ Recognize(array^ imageBuffer, List^ regionsOfInterest) { - std::vector buffer = AlprHelper::ToVector(imageBuffer); - std::vector rois = AlprHelper::ToVector(regionsOfInterest); - AlprResults results = m_Impl->recognize(buffer, rois); - return gcnew AlprResultsNet(results); - } - - /// - /// Recognize from raw pixel data - /// - AlprResultsNet^ Recognize(array^ imageBuffer, int bytesPerPixel, int imgWidth, int imgHeight) { - return Recognize(imageBuffer, bytesPerPixel, imgWidth, imgHeight, gcnew List()); - } - - /// - /// Recognize from raw pixel data - /// - AlprResultsNet^ Recognize(array^ imageBuffer, int bytesPerPixel, int imgWidth, int imgHeight, List^ regionsOfInterest) { - unsigned char* p = AlprHelper::ToCharPtr(imageBuffer); - std::vector rois = AlprHelper::ToVector(regionsOfInterest); - AlprResults results = m_Impl->recognize(p, bytesPerPixel, imgWidth, imgHeight, rois); - free(p); // ?? memory leak? - return gcnew AlprResultsNet(results); + BitmapMat^ wrapper = gcnew BitmapMat(imageBuffer); + AlprResultsNet^ results = Recognize(wrapper, regionsOfInterest); + delete wrapper; + return results; } /// @@ -481,6 +459,14 @@ namespace openalprnet { } protected: + + AlprResultsNet^ Recognize(BitmapMat^ bitmapMat, List^ regionsOfInterest) { + cv::Mat frame = bitmapMat->Value; + std::vector rois = AlprHelper::ToVector(regionsOfInterest); + AlprResults results = m_Impl->recognize(frame.data, frame.elemSize(), frame.cols, frame.rows, rois); + return gcnew AlprResultsNet(results); + } + // Deallocate the native object on the finalizer just in case no destructor is called !AlprNet() { delete m_Impl;