diff --git a/db/GPSReading.sql b/db/GPSReading.sql new file mode 100644 index 000000000..d0eba34e8 --- /dev/null +++ b/db/GPSReading.sql @@ -0,0 +1,18 @@ + +DROP TABLE IF EXISTS `GPSReading`; +CREATE TABLE `GPSReading` ( + Id int(10) NOT NULL auto_increment, + `Latitude` DECIMAL(8,6), + `Longitude` DECIMAL(9,6), + `Accuracy` FLOAT, + `Altitude` FLOAT, + `AltitudeAccuracy` FLOAT, + `Heading` FLOAT, + `Speed` FLOAT, + `TimeStamp` TimeStamp, + `ObjectId` int(10), + `ObjectTypeId` int(10), + PRIMARY KEY (`Id`) +); + +CREATE INDEX GPSReading_Object_idx ON GPSReading (ObjectId, ObjectTypeId); diff --git a/db/Object_Types.sql b/db/Object_Types.sql new file mode 100644 index 000000000..7b2334e85 --- /dev/null +++ b/db/Object_Types.sql @@ -0,0 +1,6 @@ +CREATE TABLE Object_Types ( + Id int(10) NOT NULL AUTO_INCREMENT, + Name varchar(32) UNIQUE, + Human TEXT, + PRIMARY KEY (Id) +); diff --git a/scripts/ZoneMinder/lib/ZoneMinder/GPSReading.pm b/scripts/ZoneMinder/lib/ZoneMinder/GPSReading.pm new file mode 100644 index 000000000..ef1c9782e --- /dev/null +++ b/scripts/ZoneMinder/lib/ZoneMinder/GPSReading.pm @@ -0,0 +1,87 @@ +# ========================================================================== +# +# ZoneMinder GPS Reading Module +# Copyright (C) 2023 ZoneMinder Inc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# ========================================================================== + +package ZoneMinder::GPSReading; + +use 5.006; +use strict; +use warnings; + +require ZoneMinder::Base; +require ZoneMinder::Object; + +use parent qw(ZoneMinder::Object); + +use vars qw/ $table $primary_key %fields %defaults /; +$table = 'GPSReading'; +$primary_key = 'Id'; + +%fields = ( + Id => 'Id', + ObjectId => 'ObjectId', + ObjectTypeId => 'ObjectTypeId', + TimeStamp => 'TimeStamp', + Latitude => 'Latitude', + Longitude => 'Longitude' + Accuracy => 'Accuracy', + Altitude => 'Altitude', + AltitudeAccuracy => 'AltitudeAccuracy', + Heading => 'Heading', + Speed => 'Speed', +); +%defaults => ( + 'ObjectId' => undef, + 'ObjectTypeId' => undef, + 'TimeStamp' => 0, + 'Latitude' => '', + 'Longitude' => '', + 'Accuracy' => undef, + 'Altitude' => undef, + 'AltitudeAccuracy' => undef, + 'Heading' => undef, + 'Speed' => undef, + ); + +1; +__END__ + +=head1 NAME + +ZoneMinder::GPSReading - Perl Class for GPSReadings + +=head1 SYNOPSIS + +use ZoneMinder::GPSReading; + +=head1 AUTHOR + +Isaac Connor, Eisaac@zoneminder.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2001-2017 ZoneMinder LLC + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.8.3 or, +at your option, any later version of Perl 5 you may have available. + + +=cut diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 69377a0d2..1d84efe80 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -966,6 +966,7 @@ bool Monitor::connect() { if (alarm_image.Buffer() + image_size > mem_ptr + mem_size) { Warning("We will exceed memsize by %td bytes!", (alarm_image.Buffer() + image_size) - (mem_ptr + mem_size)); } + image_pixelformats = (AVPixelFormat *)(shared_images + (image_buffer_count*image_size)); if (purpose == CAPTURE) { memset(mem_ptr, 0, mem_size); @@ -2813,6 +2814,7 @@ bool Monitor::Decode() { index++; index = index % image_buffer_count; image_buffer[index]->Assign(*(packet->image)); + image_pixelformats[index] = packet->image->AVPixFormat(); shared_timestamps[index] = zm::chrono::duration_cast(packet->timestamp.time_since_epoch()); shared_data->signal = (capture_image and signal_check_points) ? CheckSignal(capture_image) : true; shared_data->last_write_index = index; diff --git a/src/zm_monitor.h b/src/zm_monitor.h index f38517925..68b71a172 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -519,6 +519,7 @@ protected: struct timeval *shared_timestamps; unsigned char *shared_images; std::vector image_buffer; + AVPixelFormat *image_pixelformats; int video_stream_id; // will be filled in PrimeCapture int audio_stream_id; // will be filled in PrimeCapture diff --git a/web/includes/GPSReading.php b/web/includes/GPSReading.php new file mode 100644 index 000000000..cee11d5eb --- /dev/null +++ b/web/includes/GPSReading.php @@ -0,0 +1,47 @@ + null, + 'ObjectId' => null, + 'ObjectTypeId' => null, + 'TimeStamp' => 0, + 'Latitude' => '', + 'Longitude' => '', + 'Accuracy' => null, + 'Altitude' => null, + 'AltitudeAccuracy' => null, + 'Heading' => null, + 'Speed' => null, + ); + private $Event = null; + + public static function find( $parameters = array(), $options = array() ) { + return ZM_Object::_find(get_class(), $parameters, $options); + } + + public static function find_one( $parameters = array(), $options = array() ) { + return ZM_Object::_find_one(get_class(), $parameters, $options); + } + + public function ZMObject($new=null) { + if ($new) { + $this->ZMObject = $new; + $this->ObjectId = $new->Id(); + $this->Object_Type = $new->Object_Type(); + $this->ObjectTypeId = $this->Object_Type->Id(); + } + if (!$this->ZMObject) { + if ($this->{'ObjectId'}) { + $this->ZMObject = ZM_Object::_find_one($this->Object_Type->Name(), ['Id'=> $this->{'ObjectId'}]); + } + } + return $this->ZMObject; + } +} # end class GPSReading +?>