From 26a45d5fa9ccac2964177e24d409ade66de95bde Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 25 Apr 2016 13:55:28 -0400 Subject: [PATCH 1/4] Don't rotate dimensions when constructing the monitor because they are already rotated --- src/zm_monitor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index e96997ebc..e66256dea 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -306,8 +306,12 @@ Monitor::Monitor( server_id( p_server_id ), function( (Function)p_function ), enabled( p_enabled ), - width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ), - height( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Width():p_camera->Height() ), + // When we instantiate the camera, the dimensions are rotated. So if we rotate them again here, we undo the rotation. + // With this change, calls to Monitor->Width and Height will give the rotated dimesions.So this will trickle down + width( p_camera->Width() ), + height( p_camera->Height() ), + //width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ), + //height( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Width():p_camera->Height() ), orientation( (Orientation)p_orientation ), deinterlacing( p_deinterlacing ), label_coord( p_label_coord ), From 85798932ee3f9bb69b357c7825369a88e084d99b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 25 Apr 2016 14:10:26 -0400 Subject: [PATCH 2/4] Use Event Width and Height, not the Monitor Width and Height. THe Monitor dimensions are not rotated --- web/skins/classic/views/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/event.php b/web/skins/classic/views/event.php index a0b97e35e..d3a185f33 100644 --- a/web/skins/classic/views/event.php +++ b/web/skins/classic/views/event.php @@ -27,7 +27,7 @@ if ( !canView( 'Events' ) ) $eid = validInt( $_REQUEST['eid'] ); $fid = !empty($_REQUEST['fid'])?validInt($_REQUEST['fid']):1; -$sql = 'SELECT E.*,M.Name AS MonitorName,M.Width,M.Height,M.DefaultRate,M.DefaultScale FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?'; +$sql = 'SELECT E.*,M.Name AS MonitorName,E.Width,E.Height,M.DefaultRate,M.DefaultScale FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?'; $sql_values = array( $eid ); if ( $user['MonitorIds'] ) { From 8c53925fdc75c47d894eeda1cd4156ee9ffeabb1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 25 Apr 2016 16:00:34 -0400 Subject: [PATCH 3/4] redo rotation fix. cameras have to be given the width and height that the camera will be sending. The monitor will report rotated dimensions. --- src/zm_monitor.cpp | 67 +++++++++++++++++----------------------------- src/zm_monitor.h | 4 +-- 2 files changed, 26 insertions(+), 45 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index e66256dea..4fe59b5e8 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -306,12 +306,8 @@ Monitor::Monitor( server_id( p_server_id ), function( (Function)p_function ), enabled( p_enabled ), - // When we instantiate the camera, the dimensions are rotated. So if we rotate them again here, we undo the rotation. - // With this change, calls to Monitor->Width and Height will give the rotated dimesions.So this will trickle down width( p_camera->Width() ), height( p_camera->Height() ), - //width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ), - //height( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Width():p_camera->Height() ), orientation( (Orientation)p_orientation ), deinterlacing( p_deinterlacing ), label_coord( p_label_coord ), @@ -2150,9 +2146,6 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); col++; bool embed_exif = (*dbrow[col] != '0'); col++; - int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); - int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); - int extras = (deinterlacing>>24)&0xff; Camera *camera = new LocalCamera( @@ -2163,8 +2156,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); v4l_multi_buffer, v4l_captures_per_frame, method, - cam_width, - cam_height, + width, + height, colours, palette, brightness, @@ -2306,9 +2299,6 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c int track_motion = atoi(dbrow[col]); col++; bool embed_exif = (*dbrow[col] != '0'); col++; - int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); - int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); - Camera *camera = 0; if ( protocol == "http" ) { @@ -2318,8 +2308,8 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c host, // Host port, // Port path, // Path - cam_width, - cam_height, + width, + height, colours, brightness, contrast, @@ -2337,8 +2327,8 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c host, // Host port, // Port path, // Path - cam_width, - cam_height, + width, + height, rtsp_describe, colours, brightness, @@ -2481,14 +2471,11 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu int track_motion = atoi(dbrow[col]); col++; bool embed_exif = (*dbrow[col] != '0'); col++; - int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); - int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); - Camera *camera = new FileCamera( id, path, // File - cam_width, - cam_height, + width, + height, colours, brightness, contrast, @@ -2626,16 +2613,13 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose int track_motion = atoi(dbrow[col]); col++; bool embed_exif = (*dbrow[col] != '0'); col++; - int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); - int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); - Camera *camera = new FfmpegCamera( id, path, // File method, options, - cam_width, - cam_height, + width, + height, colours, brightness, contrast, @@ -2796,9 +2780,6 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); col++; bool embed_exif = (*dbrow[col] != '0'); col++; - int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); - int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); - int extras = (deinterlacing>>24)&0xff; Camera *camera = 0; @@ -2813,8 +2794,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); v4l_multi_buffer, v4l_captures_per_frame, method, - cam_width, - cam_height, + width, + height, colours, palette, brightness, @@ -2838,8 +2819,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); host.c_str(), port.c_str(), path.c_str(), - cam_width, - cam_height, + width, + height, colours, brightness, contrast, @@ -2857,8 +2838,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); host.c_str(), port.c_str(), path.c_str(), - cam_width, - cam_height, + width, + height, rtsp_describe, colours, brightness, @@ -2881,8 +2862,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); camera = new FileCamera( id, path.c_str(), - cam_width, - cam_height, + width, + height, colours, brightness, contrast, @@ -2899,8 +2880,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); path.c_str(), method, options, - cam_width, - cam_height, + width, + height, colours, brightness, contrast, @@ -2920,8 +2901,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); path.c_str(), method, options, - cam_width, - cam_height, + width, + height, colours, brightness, contrast, @@ -2941,8 +2922,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); path.c_str(), user.c_str(), pass.c_str(), - cam_width, - cam_height, + width, + height, colours, brightness, contrast, diff --git a/src/zm_monitor.h b/src/zm_monitor.h index a9cd05674..d1a619a4c 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -358,8 +358,8 @@ public: return( embed_exif ); } - unsigned int Width() const { return( width ); } - unsigned int Height() const { return( height ); } + unsigned int Width() const { return( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ); } + unsigned int Height() const { return( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Width():p_camera->Height() ); } unsigned int Colours() const { return( camera->Colours() ); } unsigned int SubpixelOrder() const { return( camera->SubpixelOrder() ); } From 2d8c484792a9518a0c308c6d8d2e6ade06959b6b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 25 Apr 2016 16:48:26 -0400 Subject: [PATCH 4/4] rotate dimensions when instantiating the Monitor object --- src/zm_monitor.cpp | 4 ++-- src/zm_monitor.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 4fe59b5e8..e9998c181 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -306,8 +306,8 @@ Monitor::Monitor( server_id( p_server_id ), function( (Function)p_function ), enabled( p_enabled ), - width( p_camera->Width() ), - height( p_camera->Height() ), + width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ), + height( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Width():p_camera->Height() ), orientation( (Orientation)p_orientation ), deinterlacing( p_deinterlacing ), label_coord( p_label_coord ), diff --git a/src/zm_monitor.h b/src/zm_monitor.h index d1a619a4c..a9cd05674 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -358,8 +358,8 @@ public: return( embed_exif ); } - unsigned int Width() const { return( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ); } - unsigned int Height() const { return( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Width():p_camera->Height() ); } + unsigned int Width() const { return( width ); } + unsigned int Height() const { return( height ); } unsigned int Colours() const { return( camera->Colours() ); } unsigned int SubpixelOrder() const { return( camera->SubpixelOrder() ); }