mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 07:46:59 +08:00
Refactor so that we only have a single method that calls m_Impl->recognize.
This commit is contained in:
@@ -380,19 +380,6 @@ namespace openalprnet {
|
|||||||
return Recognize(bitmap, gcnew List<System::Drawing::Rectangle>());
|
return Recognize(bitmap, gcnew List<System::Drawing::Rectangle>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Recognize from a bitmap
|
|
||||||
/// </summary>
|
|
||||||
AlprResultsNet^ Recognize(Bitmap^ bitmap, List<System::Drawing::Rectangle>^ regionsOfInterest)
|
|
||||||
{
|
|
||||||
BitmapMat^ wrapper = gcnew BitmapMat(bitmap);
|
|
||||||
cv::Mat frame = wrapper->Value;
|
|
||||||
std::vector<AlprRegionOfInterest> rois = AlprHelper::ToVector(regionsOfInterest);
|
|
||||||
AlprResults results = m_Impl->recognize(frame.data, frame.elemSize(), frame.cols, frame.rows, rois);
|
|
||||||
delete wrapper;
|
|
||||||
return gcnew AlprResultsNet(results);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Recognize from MemoryStream representing an encoded image (e.g., BMP, PNG, JPG, GIF etc).
|
/// Recognize from MemoryStream representing an encoded image (e.g., BMP, PNG, JPG, GIF etc).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -412,38 +399,29 @@ namespace openalprnet {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc).
|
/// Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="imageBuffer">Bytes representing image data</param>
|
|
||||||
AlprResultsNet^ Recognize(array<Byte>^ imageBuffer) {
|
AlprResultsNet^ Recognize(array<Byte>^ imageBuffer) {
|
||||||
return Recognize(imageBuffer, gcnew List<System::Drawing::Rectangle>());
|
return Recognize(imageBuffer, gcnew List<System::Drawing::Rectangle>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Recognize from a bitmap
|
||||||
|
/// </summary>
|
||||||
|
AlprResultsNet^ Recognize(Bitmap^ bitmap, List<System::Drawing::Rectangle>^ regionsOfInterest)
|
||||||
|
{
|
||||||
|
BitmapMat^ wrapper = gcnew BitmapMat(bitmap);
|
||||||
|
AlprResultsNet^ results = Recognize(wrapper, regionsOfInterest);
|
||||||
|
delete wrapper;
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc).
|
/// Recognize from byte data representing an encoded image (e.g., BMP, PNG, JPG, GIF etc).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="imageBuffer">Bytes representing image data</param>
|
|
||||||
AlprResultsNet^ Recognize(array<Byte>^ imageBuffer, List<System::Drawing::Rectangle>^ regionsOfInterest) {
|
AlprResultsNet^ Recognize(array<Byte>^ imageBuffer, List<System::Drawing::Rectangle>^ regionsOfInterest) {
|
||||||
std::vector<char> buffer = AlprHelper::ToVector(imageBuffer);
|
BitmapMat^ wrapper = gcnew BitmapMat(imageBuffer);
|
||||||
std::vector<AlprRegionOfInterest> rois = AlprHelper::ToVector(regionsOfInterest);
|
AlprResultsNet^ results = Recognize(wrapper, regionsOfInterest);
|
||||||
AlprResults results = m_Impl->recognize(buffer, rois);
|
delete wrapper;
|
||||||
return gcnew AlprResultsNet(results);
|
return results;
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Recognize from raw pixel data
|
|
||||||
/// </summary>
|
|
||||||
AlprResultsNet^ Recognize(array<Byte>^ imageBuffer, int bytesPerPixel, int imgWidth, int imgHeight) {
|
|
||||||
return Recognize(imageBuffer, bytesPerPixel, imgWidth, imgHeight, gcnew List<System::Drawing::Rectangle>());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Recognize from raw pixel data
|
|
||||||
/// </summary>
|
|
||||||
AlprResultsNet^ Recognize(array<Byte>^ imageBuffer, int bytesPerPixel, int imgWidth, int imgHeight, List<System::Drawing::Rectangle>^ regionsOfInterest) {
|
|
||||||
unsigned char* p = AlprHelper::ToCharPtr(imageBuffer);
|
|
||||||
std::vector<AlprRegionOfInterest> rois = AlprHelper::ToVector(regionsOfInterest);
|
|
||||||
AlprResults results = m_Impl->recognize(p, bytesPerPixel, imgWidth, imgHeight, rois);
|
|
||||||
free(p); // ?? memory leak?
|
|
||||||
return gcnew AlprResultsNet(results);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -481,6 +459,14 @@ namespace openalprnet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
AlprResultsNet^ Recognize(BitmapMat^ bitmapMat, List<System::Drawing::Rectangle>^ regionsOfInterest) {
|
||||||
|
cv::Mat frame = bitmapMat->Value;
|
||||||
|
std::vector<AlprRegionOfInterest> 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
|
// Deallocate the native object on the finalizer just in case no destructor is called
|
||||||
!AlprNet() {
|
!AlprNet() {
|
||||||
delete m_Impl;
|
delete m_Impl;
|
||||||
|
Reference in New Issue
Block a user