diff --git a/src/bindings/csharp/openalpr-net/openalpr-net.cpp b/src/bindings/csharp/openalpr-net/openalpr-net.cpp index 38a8ebb..05a5ecd 100644 --- a/src/bindings/csharp/openalpr-net/openalpr-net.cpp +++ b/src/bindings/csharp/openalpr-net/openalpr-net.cpp @@ -100,6 +100,21 @@ namespace openalprnet { return dstMat; } + static cv::Mat MemoryStreamBitmapToMat(MemoryStream^ memoryStream) + { + Bitmap^ bitmap = gcnew Bitmap(memoryStream); + cv::Mat mat = BitmapToMat(bitmap); + return mat; + } + + static cv::Mat ByteArrayToMat(array^ byteArray) + { + MemoryStream^ ms = gcnew MemoryStream(byteArray); + cv::Mat mat(MemoryStreamBitmapToMat(ms)); + delete ms; + return mat; + } + static Bitmap^ MatToBitmap(cv::Mat mat) { const int width = mat.size().width; @@ -223,6 +238,16 @@ namespace openalprnet { return ResetMotionDetection(Mat(filename, matType)); } + void ResetMotionDetection(MemoryStream^ memoryStream) + { + return ResetMotionDetection(Mat(memoryStream)); + } + + void ResetMotionDetection(array^ byteArray) + { + return ResetMotionDetection(Mat(byteArray)); + } + System::Drawing::Rectangle MotionDetect(Bitmap^ bitmap) { return MotionDetect(Mat(bitmap)); @@ -233,6 +258,16 @@ namespace openalprnet { return MotionDetect(Mat(filename, matType)); } + System::Drawing::Rectangle MotionDetect(MemoryStream^ memoryStream) + { + return MotionDetect(Mat(memoryStream)); + } + + System::Drawing::Rectangle MotionDetect(array^ byteArray) + { + return MotionDetect(Mat(byteArray)); + } + private: void ResetMotionDetection(cv::Mat mat) { @@ -257,6 +292,18 @@ namespace openalprnet { return mat; } + cv::Mat Mat(MemoryStream^ memoryStream) + { + cv::Mat mat = AlprHelper::MemoryStreamBitmapToMat(memoryStream); + return mat; + } + + cv::Mat Mat(array^ byteArray) + { + cv::Mat mat = AlprHelper::ByteArrayToMat(byteArray); + return mat; + } + private: ~AlprMotionDetectionNet()