From a88ccf793bd2ea4df790c3ae66f777294be1552b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 15 Dec 2020 16:32:19 -0500 Subject: [PATCH 1/5] correct zone points instead of skipping zone --- src/zm_zone.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index ea6c170ac..38d1a5ee3 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -922,10 +922,12 @@ int Zone::Load(Monitor *monitor, Zone **&zones) { if ( polygon.LoX() < 0 || polygon.HiX() >= (int)monitor->Width() || polygon.LoY() < 0 || polygon.HiY() >= (int)monitor->Height() ) { - Error("Zone %d/%s for monitor %s extends outside of image dimensions, (%d,%d), (%d,%d), ignoring", + Error("Zone %d/%s for monitor %s extends outside of image dimensions, (%d,%d), (%d,%d), fixing", Id, Name, monitor->Name(), polygon.LoX(), polygon.LoY(), polygon.HiX(), polygon.HiY()); - n_zones -= 1; - continue; + if ( polygon.LoX() < 0 ) polygon.LoX(0); + if ( polygon.HiX() >= (int)monitor->Width()) polygon.HiX((int)monitor->Width()); + if ( polygon.LoY() < 0 ) polygon.LoY(0); + if ( polygon.HiY() >= (int)monitor->Height() ) polygon.HiY((int)monitor->Height()); } if ( false && !strcmp( Units, "Percent" ) ) { From e9d34499299a9adf8895aeb900e56a47ab5d1da7 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 15 Dec 2020 16:32:41 -0500 Subject: [PATCH 2/5] Allow altering polygon coordinates --- src/zm_box.h | 4 ++++ src/zm_coord.h | 10 +++++----- src/zm_poly.h | 4 ++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/zm_box.h b/src/zm_box.h index efc12cb18..ca3e6fd39 100644 --- a/src/zm_box.h +++ b/src/zm_box.h @@ -47,10 +47,14 @@ public: inline const Coord &Lo() const { return lo; } inline int LoX() const { return lo.X(); } + inline int LoX(int p_lo_x) { return lo.X(p_lo_x); } inline int LoY() const { return lo.Y(); } + inline int LoY(int p_lo_y) { return lo.Y(p_lo_y); } inline const Coord &Hi() const { return hi; } inline int HiX() const { return hi.X(); } + inline int HiX(int p_hi_x) { return hi.X(p_hi_x); } inline int HiY() const { return hi.Y(); } + inline int HiY(int p_hi_y) { return hi.Y(p_hi_y); } inline const Coord &Size() const { return size; } inline int Width() const { return size.X(); } inline int Height() const { return size.Y(); } diff --git a/src/zm_coord.h b/src/zm_coord.h index c6234fb1c..9ddd4af0c 100644 --- a/src/zm_coord.h +++ b/src/zm_coord.h @@ -38,14 +38,14 @@ public: y = coord.y; return *this; } - inline int &X() { return( x ); } - inline const int &X() const { return( x ); } - inline int &Y() { return( y ); } - inline const int &Y() const { return( y ); } + inline int &X(int p_x) { x=p_x; return x; } + inline const int &X() const { return x; } + inline int &Y(int p_y) { y=p_y; return y; } + inline const int &Y() const { return y; } inline static Coord Range( const Coord &coord1, const Coord &coord2 ) { Coord result( (coord1.x-coord2.x)+1, (coord1.y-coord2.y)+1 ); - return( result ); + return result; } inline bool operator==( const Coord &coord ) { return( x == coord.x && y == coord.y ); } diff --git a/src/zm_poly.h b/src/zm_poly.h index be039ef3e..d45a13ea2 100644 --- a/src/zm_poly.h +++ b/src/zm_poly.h @@ -100,9 +100,13 @@ public: inline const Box &Extent() const { return extent; } inline int LoX() const { return extent.LoX(); } + inline int LoX(int p_lo_x) { return extent.LoX(p_lo_x); } inline int HiX() const { return extent.HiX(); } + inline int HiX(int p_hi_x) { return extent.HiX(p_hi_x); } inline int LoY() const { return extent.LoY(); } + inline int LoY(int p_lo_y) { return extent.LoY(p_lo_y); } inline int HiY() const { return extent.HiY(); } + inline int HiY(int p_hi_y) { return extent.HiY(p_hi_y); } inline int Width() const { return extent.Width(); } inline int Height() const { return extent.Height(); } From 7f9b977ec2368e4576de41c6971ffeb73b760c37 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 15 Dec 2020 16:56:05 -0500 Subject: [PATCH 3/5] rename onDownClick to onRenameClick cutnpaste error --- web/skins/classic/views/js/event.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/event.js b/web/skins/classic/views/js/event.js index 4e9a28745..d99594f2c 100644 --- a/web/skins/classic/views/js/event.js +++ b/web/skins/classic/views/js/event.js @@ -1160,7 +1160,7 @@ function initPage() { }); // Manage the Event RENAME button - document.getElementById("renameBtn").addEventListener("click", function onDownloadClick(evt) { + document.getElementById("renameBtn").addEventListener("click", function onRenameClick(evt) { evt.preventDefault(); $j.getJSON(thisUrl + '?request=modal&modal=eventrename&eid='+eventData.Id) .done(function(data) { From 6e2cfa6ca98a494368bb4eaf258ee2bbc3821068 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 15 Dec 2020 16:55:28 -0500 Subject: [PATCH 4/5] Add R and W short form options --- src/zmu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zmu.cpp b/src/zmu.cpp index 30a2a0ce7..1217ffe62 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -275,7 +275,7 @@ int main(int argc, char *argv[]) { while (1) { int option_index = 0; - int c = getopt_long(argc, argv, "d:m:vsEDLurwei::S:t::fz::ancqhlB::C::H::O::U:P:A:V:T:", long_options, &option_index); + int c = getopt_long(argc, argv, "d:m:vsEDLurwei::S:t::fz::ancqhlB::C::H::O::RWU:P:A:V:T:", long_options, &option_index); if ( c == -1 ) { break; } From 08d82fb86a5d883b6f8871f61ceb8eb91ba3f2c6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 15 Dec 2020 18:25:17 -0500 Subject: [PATCH 5/5] use nullptr instead of 0 when init'ing event --- src/zm_monitor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 51b8ba12a..fff2a096e 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -365,12 +365,12 @@ Monitor::Monitor( embed_exif( p_embed_exif ), delta_image( width, height, ZM_COLOUR_GRAY8, ZM_SUBPIX_ORDER_NONE ), ref_image( width, height, p_camera->Colours(), p_camera->SubpixelOrder() ), - purpose( p_purpose ), + purpose(p_purpose), last_motion_score(0), - camera( p_camera ), - event(0), - n_zones( p_n_zones ), - zones( p_zones ), + camera(p_camera), + event(nullptr), + n_zones(p_n_zones), + zones(p_zones), timestamps( nullptr ), images( nullptr ), privacy_bitmask( nullptr ),