diff --git a/README.md b/README.md index 1a842f4..4556ad4 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ Please follow these detailed compilation guides for your respective operating sy * [Windows] (https://github.com/openalpr/openalpr/wiki/Compilation-instructions-(Windows)) * [Ubuntu Linux] (https://github.com/openalpr/openalpr/wiki/Compilation-instructions-(Ubuntu-Linux)) +* [OS X] (https://github.com/openalpr/openalpr/wiki/Compilation-instructions-(OS-X)) * [Android] (https://github.com/sujaybhowmick/OpenAlprDroidApp) * [iOS] (https://github.com/twelve17/openalpr-ios) diff --git a/src/bindings/csharp/openalpr-net/openalpr-net.cpp b/src/bindings/csharp/openalpr-net/openalpr-net.cpp index a8103d0..7eee6da 100644 --- a/src/bindings/csharp/openalpr-net/openalpr-net.cpp +++ b/src/bindings/csharp/openalpr-net/openalpr-net.cpp @@ -291,6 +291,49 @@ namespace openalprnet { }; + public ref class AlprFrameEventArgs : public EventArgs + { + public: + AlprFrameEventArgs(int frameNumber, System::Drawing::Image^ frame, AlprResultsNet^ results) { + m_frameNumber = frameNumber; + m_frame = frame; + m_results = results; + m_cancel = false; + } + + property int FrameNumber { + int get() { + return m_frameNumber; + } + } + + property System::Drawing::Image^ Frame { + System::Drawing::Image^ get() { + return m_frame; + } + } + + property AlprResultsNet^ Results { + AlprResultsNet^ get() { + return m_results; + } + } + + property bool Cancel { + bool get() { + return m_cancel; + } + void set( bool cancel ) { + m_cancel = cancel; + } + } + private: + int m_frameNumber; + System::Drawing::Image^ m_frame; + AlprResultsNet^ m_results; + bool m_cancel; + }; + public ref class AlprNet sealed { public: @@ -332,6 +375,37 @@ namespace openalprnet { } } + event EventHandler^ FrameProcessed; + + void recognizeFromVideo(System::String^ videoPath) { + if (System::IO::File::Exists(videoPath)) { + int framenum = 0; + cv::VideoCapture cap = cv::VideoCapture(); + cap.open(marshal_as(videoPath)); + + cv::Mat frame; + + while (cap.read(frame)) + { + std::vector regionsOfInterest; + regionsOfInterest.push_back(AlprRegionOfInterest(0, 0, frame.cols, frame.rows)); + + AlprResults results = m_Impl->recognize(frame.data, frame.elemSize(), frame.cols, frame.rows, regionsOfInterest); + Image^ frameImage = gcnew Bitmap(frame.cols, frame.rows, frame.step, Imaging::PixelFormat::Format24bppRgb, IntPtr(frame.data)); + AlprFrameEventArgs^ alprFrameEventArgs = gcnew AlprFrameEventArgs(framenum, frameImage, gcnew AlprResultsNet(results)); + FrameProcessed(this, alprFrameEventArgs); + delete frameImage; + if (alprFrameEventArgs->Cancel) { + break; + } + framenum++; + } + } + else { + throw gcnew System::IO::FileNotFoundException("No video was not found at " + videoPath, videoPath); + } + } + /// /// Recognize from an image on disk /// diff --git a/src/openalpr/detection/detectormorph.cpp b/src/openalpr/detection/detectormorph.cpp index 5582d23..e641feb 100644 --- a/src/openalpr/detection/detectormorph.cpp +++ b/src/openalpr/detection/detectormorph.cpp @@ -137,6 +137,7 @@ const int num_thresholds = 7; int numValidChars = 0; Mat rotated; for (int i = 0; i < rects.size(); i++) { + numValidChars = 0; RotatedRect PlateRect = rects[i]; Size rect_size = PlateRect.size; diff --git a/src/openalpr/support/timing.cpp b/src/openalpr/support/timing.cpp index 0a93507..82c8374 100644 --- a/src/openalpr/support/timing.cpp +++ b/src/openalpr/support/timing.cpp @@ -83,7 +83,7 @@ namespace alpr timespec time_start; time_start.tv_sec = 0; - time_start.tv_nsec = 0; + time_start.tv_usec = 0; return diffclock(time_start, time); } diff --git a/src/openalpr/support/windows/unistd_partial.h b/src/openalpr/support/windows/unistd_partial.h index a335c26..c4efc98 100644 --- a/src/openalpr/support/windows/unistd_partial.h +++ b/src/openalpr/support/windows/unistd_partial.h @@ -30,7 +30,7 @@ #define STDOUT_FILENO 1 #define STDERR_FILENO 2 /* should be in some equivalent to */ -typedef __int8 int8_t; +//typedef __int8 int8_t; typedef __int16 int16_t; typedef __int32 int32_t; typedef __int64 int64_t;