Manually create Events in ZoneMinder
Posted: Thu Feb 24, 2011 12:11 am
Hi,
I've got a quite complicated project to setup a cluster of ip cameras controlled by ZoneMinder [cameras are remote to the server.
Due to network issues and the amount of data being transferred between the cameras and the server I wanted to setup one ZoneMinder instance per camera to record everything and then - at night - to send the data to the master ZoneMinder server where all the events would be available for viewing.
This way, if there's a need, one can connect to the remote ZoneMinder instance to view events from today [or live stream] and connect to the master server to view past events.
At night I would compress all the events recorded by all the slave ZoneMinder instances and send it to the master server to be loaded.
Unfortunately, ZoneMinder is quite a resource hog. It does a lot of things when it comes to image processing, and I use none of that. I simply record everything without the need for any alarms/signals... none of that matters to me.
I decided I will just write a simple script to gather the data and send it to the master server where I will load it to ZoneMinder.
As I thought, it's not that simple and one have to take quite a few things into consideration.
I went through the database and all the files stored by ZoneMinder and I think I've got everything covered when it comes to building a proper data structure which can be injected into ZoneMinder.
I will setup every remote camera in my master ZoneMinder, and I will put them all in Monitor mode. This way, when someone wants to view the live stream they will be able to get it from the master server.
Also this will enable me to inject all the Events and make them viewable easily.
This is the list of other things I have to do in order to make it work:
Files:
- One directory per Monitor
- Inside Monitor directory - one directory per 10mins
- Directory name - Event id (Event id unique across all monitors)
- Directory contains files - frames, filename: FrameId-capture.jpg
- FrameId unique per Event
Procedure:
- dump jpg files to an event directory
- every 10minutes change directory
- name files using iterator, when changing directory - reset iterator
- name directories using event id from the database
Database:
- Fill information into Events and Frames tables
- Events table to contain information:
- Id - auto_increment <- this id to be used to name event directories
- MonitorId - camera id
- Name - "Event-<Id>"
- Cause - "Continuous"
- StartTime - 001-capture.jpg timestamp for specific event
- EndTime - last *-capture.jpd timestamp for specific event
- Width - 320
- Height - 320
- Lenght - EndTime - StartTime
- Frames - file count
- AlarmFrames - 0
- TotScore - 0
- AvgScore - 0
- MaxScore - 0
- Archived - 0
- Videoed - 0
- Emailed - 0
- Messaged - 0
- Executed - 0
- Notes - blank
- Frames table to contain information:
- Id - Event Id
- FrameId - 1, 100, 200 ... - create entry for every 100th frame
- Type - Bulk
- TimeStamp - FrameId-capture.jpg file timestamp
- Delta - difference between FrameId n and FrameIf n - 1 timestamps
- Score - 0
Procedure:
- For every new event, get an id using auto_increment and add entry into Events
- Move files to a correct directory [name from the event id]
- Create entry in Frames for every 100 files in Event directory
Do you think there's something else I have to take care of?
I've got a quite complicated project to setup a cluster of ip cameras controlled by ZoneMinder [cameras are remote to the server.
Due to network issues and the amount of data being transferred between the cameras and the server I wanted to setup one ZoneMinder instance per camera to record everything and then - at night - to send the data to the master ZoneMinder server where all the events would be available for viewing.
This way, if there's a need, one can connect to the remote ZoneMinder instance to view events from today [or live stream] and connect to the master server to view past events.
At night I would compress all the events recorded by all the slave ZoneMinder instances and send it to the master server to be loaded.
Unfortunately, ZoneMinder is quite a resource hog. It does a lot of things when it comes to image processing, and I use none of that. I simply record everything without the need for any alarms/signals... none of that matters to me.
I decided I will just write a simple script to gather the data and send it to the master server where I will load it to ZoneMinder.
As I thought, it's not that simple and one have to take quite a few things into consideration.
I went through the database and all the files stored by ZoneMinder and I think I've got everything covered when it comes to building a proper data structure which can be injected into ZoneMinder.
I will setup every remote camera in my master ZoneMinder, and I will put them all in Monitor mode. This way, when someone wants to view the live stream they will be able to get it from the master server.
Also this will enable me to inject all the Events and make them viewable easily.
This is the list of other things I have to do in order to make it work:
Files:
- One directory per Monitor
- Inside Monitor directory - one directory per 10mins
- Directory name - Event id (Event id unique across all monitors)
- Directory contains files - frames, filename: FrameId-capture.jpg
- FrameId unique per Event
Procedure:
- dump jpg files to an event directory
- every 10minutes change directory
- name files using iterator, when changing directory - reset iterator
- name directories using event id from the database
Database:
- Fill information into Events and Frames tables
- Events table to contain information:
- Id - auto_increment <- this id to be used to name event directories
- MonitorId - camera id
- Name - "Event-<Id>"
- Cause - "Continuous"
- StartTime - 001-capture.jpg timestamp for specific event
- EndTime - last *-capture.jpd timestamp for specific event
- Width - 320
- Height - 320
- Lenght - EndTime - StartTime
- Frames - file count
- AlarmFrames - 0
- TotScore - 0
- AvgScore - 0
- MaxScore - 0
- Archived - 0
- Videoed - 0
- Emailed - 0
- Messaged - 0
- Executed - 0
- Notes - blank
- Frames table to contain information:
- Id - Event Id
- FrameId - 1, 100, 200 ... - create entry for every 100th frame
- Type - Bulk
- TimeStamp - FrameId-capture.jpg file timestamp
- Delta - difference between FrameId n and FrameIf n - 1 timestamps
- Score - 0
Procedure:
- For every new event, get an id using auto_increment and add entry into Events
- Move files to a correct directory [name from the event id]
- Create entry in Frames for every 100 files in Event directory
Do you think there's something else I have to take care of?