Add overloads for MemoryStream and byte array to motion detector.

This commit is contained in:
Peter Rekdal Sunde
2015-07-09 17:25:26 +02:00
parent 0987f6858a
commit 82cf3f95fb

View File

@@ -100,6 +100,21 @@ namespace openalprnet {
return dstMat; 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<Byte>^ byteArray)
{
MemoryStream^ ms = gcnew MemoryStream(byteArray);
cv::Mat mat(MemoryStreamBitmapToMat(ms));
delete ms;
return mat;
}
static Bitmap^ MatToBitmap(cv::Mat mat) static Bitmap^ MatToBitmap(cv::Mat mat)
{ {
const int width = mat.size().width; const int width = mat.size().width;
@@ -223,6 +238,16 @@ namespace openalprnet {
return ResetMotionDetection(Mat(filename, matType)); return ResetMotionDetection(Mat(filename, matType));
} }
void ResetMotionDetection(MemoryStream^ memoryStream)
{
return ResetMotionDetection(Mat(memoryStream));
}
void ResetMotionDetection(array<Byte>^ byteArray)
{
return ResetMotionDetection(Mat(byteArray));
}
System::Drawing::Rectangle MotionDetect(Bitmap^ bitmap) System::Drawing::Rectangle MotionDetect(Bitmap^ bitmap)
{ {
return MotionDetect(Mat(bitmap)); return MotionDetect(Mat(bitmap));
@@ -233,6 +258,16 @@ namespace openalprnet {
return MotionDetect(Mat(filename, matType)); return MotionDetect(Mat(filename, matType));
} }
System::Drawing::Rectangle MotionDetect(MemoryStream^ memoryStream)
{
return MotionDetect(Mat(memoryStream));
}
System::Drawing::Rectangle MotionDetect(array<Byte>^ byteArray)
{
return MotionDetect(Mat(byteArray));
}
private: private:
void ResetMotionDetection(cv::Mat mat) void ResetMotionDetection(cv::Mat mat)
{ {
@@ -257,6 +292,18 @@ namespace openalprnet {
return mat; return mat;
} }
cv::Mat Mat(MemoryStream^ memoryStream)
{
cv::Mat mat = AlprHelper::MemoryStreamBitmapToMat(memoryStream);
return mat;
}
cv::Mat Mat(array<Byte>^ byteArray)
{
cv::Mat mat = AlprHelper::ByteArrayToMat(byteArray);
return mat;
}
private: private:
~AlprMotionDetectionNet() ~AlprMotionDetectionNet()