Merge pull request #76 from masroore/master

openalpr-net fixes
This commit is contained in:
Matthew Hill
2015-01-06 22:32:22 -05:00
2 changed files with 11 additions and 15 deletions

View File

@@ -336,18 +336,19 @@ namespace openalprnet {
/// Recognize from an image on disk /// Recognize from an image on disk
/// </summary> /// </summary>
AlprResultsNet^ recognize(System::String^ filepath) { AlprResultsNet^ recognize(System::String^ filepath) {
/*
AlprResults results = m_Impl->recognize(marshal_as<std::string>(filepath)); AlprResults results = m_Impl->recognize(marshal_as<std::string>(filepath));
return gcnew AlprResultsNet(results); return gcnew AlprResultsNet(results);
*/ }
/// <summary>
/// Recognize from an image on disk
/// </summary>
AlprResultsNet^ recognize(System::String^ filepath, List<System::Drawing::Rectangle>^ regionsOfInterest) {
cv::Mat frame = cv::imread( marshal_as<std::string>(filepath) ); cv::Mat frame = cv::imread( marshal_as<std::string>(filepath) );
std::vector<AlprRegionOfInterest> rois = AlprHelper::ToVector(regionsOfInterest);
std::vector<AlprRegionOfInterest> regionsOfInterest; AlprResults results = m_Impl->recognize(frame.data, frame.elemSize(), frame.cols, frame.rows, rois );
regionsOfInterest.push_back(AlprRegionOfInterest(0,0, frame.cols, frame.rows));
AlprResults results = m_Impl->recognize(frame.data, frame.elemSize(), frame.cols, frame.rows, regionsOfInterest );
return gcnew AlprResultsNet(results); return gcnew AlprResultsNet(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).
@@ -378,11 +379,6 @@ namespace openalprnet {
return AlprHelper::ToManagedString(Alpr::getVersion()); return AlprHelper::ToManagedString(Alpr::getVersion());
} }
// System::String^ toJson(AlprResultsNet^ results) {
// std::string json = Alpr::toJson(marshal_as<AlprResults>(results));
// return AlprHelper::ToManagedString(json);
// }
protected: protected:
// 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() {

View File

@@ -138,9 +138,9 @@ namespace openalprnet_windemo
var results = alpr.recognize(fileName); var results = alpr.recognize(fileName);
var images = new List<Image>(results.Count()); var images = new List<Image>(results.plates.Count());
var i = 1; var i = 1;
foreach (var result in results) foreach (var result in results.plates)
{ {
var rect = boundingRectangle(result.plate_points); var rect = boundingRectangle(result.plate_points);
var img = Image.FromFile(fileName); var img = Image.FromFile(fileName);