Optimize motion detector by using BitmapMat for Bitmap^ only.

This commit is contained in:
Peter Rekdal Sunde
2015-08-12 14:42:30 +02:00
parent 459dbb2266
commit 4015050512

View File

@@ -14,23 +14,20 @@ void AlprMotionDetectionNet::ResetMotionDetection(Bitmap^ bitmap)
void AlprMotionDetectionNet::ResetMotionDetection(String^ filename) void AlprMotionDetectionNet::ResetMotionDetection(String^ filename)
{ {
BitmapMat^ wrapper = gcnew BitmapMat(filename); cv::Mat mat = cv::imread(marshal_as<std::string>(filename));
ResetMotionDetection(wrapper->Value); ResetMotionDetection(mat);
delete wrapper;
} }
void AlprMotionDetectionNet::ResetMotionDetection(MemoryStream^ memoryStream) void AlprMotionDetectionNet::ResetMotionDetection(MemoryStream^ memoryStream)
{ {
BitmapMat^ wrapper = gcnew BitmapMat(memoryStream); return ResetMotionDetection(memoryStream->ToArray());
ResetMotionDetection(wrapper->Value);
delete wrapper;
} }
void AlprMotionDetectionNet::ResetMotionDetection(array<Byte>^ byteArray) void AlprMotionDetectionNet::ResetMotionDetection(array<Byte>^ byteArray)
{ {
BitmapMat^ wrapper = gcnew BitmapMat(byteArray); std::vector<char> buffer = AlprHelper::ToVector(byteArray);
ResetMotionDetection(wrapper->Value); cv::Mat mat = cv::imdecode(buffer, 1);
delete wrapper; ResetMotionDetection(mat);
} }
System::Drawing::Rectangle AlprMotionDetectionNet::MotionDetect(Bitmap^ bitmap) System::Drawing::Rectangle AlprMotionDetectionNet::MotionDetect(Bitmap^ bitmap)
@@ -43,26 +40,21 @@ System::Drawing::Rectangle AlprMotionDetectionNet::MotionDetect(Bitmap^ bitmap)
System::Drawing::Rectangle AlprMotionDetectionNet::MotionDetect(String^ filename) System::Drawing::Rectangle AlprMotionDetectionNet::MotionDetect(String^ filename)
{ {
BitmapMat^ wrapper = gcnew BitmapMat(filename); cv::Mat mat = cv::imread(marshal_as<std::string>(filename));
System::Drawing::Rectangle motion = MotionDetect(wrapper->Value); System::Drawing::Rectangle motion = MotionDetect(mat);
delete wrapper;
return motion; return motion;
} }
System::Drawing::Rectangle AlprMotionDetectionNet::MotionDetect(MemoryStream^ memoryStream) System::Drawing::Rectangle AlprMotionDetectionNet::MotionDetect(MemoryStream^ memoryStream)
{ {
BitmapMat^ wrapper = gcnew BitmapMat(memoryStream); return MotionDetect(memoryStream->ToArray());
System::Drawing::Rectangle motion = MotionDetect(wrapper->Value);
delete wrapper;
return motion;
} }
System::Drawing::Rectangle AlprMotionDetectionNet::MotionDetect(array<Byte>^ byteArray) System::Drawing::Rectangle AlprMotionDetectionNet::MotionDetect(array<Byte>^ byteArray)
{ {
BitmapMat^ wrapper = gcnew BitmapMat(byteArray); std::vector<char> buffer = AlprHelper::ToVector(byteArray);
System::Drawing::Rectangle motion = MotionDetect(wrapper->Value); cv::Mat mat = cv::imdecode(buffer, 1);
delete wrapper; return MotionDetect(mat);
return motion;
} }
void AlprMotionDetectionNet::ResetMotionDetection(cv::Mat mat) void AlprMotionDetectionNet::ResetMotionDetection(cv::Mat mat)