Manually create Events in ZoneMinder

Forum for questions and support relating to the 1.24.x releases only.
Locked
krystian
Posts: 7
Joined: Fri Jan 21, 2011 9:37 am
Location: PL

Manually create Events in ZoneMinder

Post by krystian »

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?
krystian
Posts: 7
Joined: Fri Jan 21, 2011 9:37 am
Location: PL

Post by krystian »

One thing I am not sure about is the difference between entries in Frames table.
I can have Single or Bulk frames.
I will never have Alarm frames.

I am wondering what's the difference.
I've tried to go through the database and I can see that if I have less than 100 frames per Event I will have Normal frames.
If I have more than 100 frames I have 10 Normal frames with id: 1..10 and then I've got Bulk frames with ids:
100
200
300
343
Where 343 is the last frame and it has Type: Normal

I've gone through the source code of ZoneMinder when it comes to Frames handling and I couldn't see where would the 90 frames between 11 and 99 be changed to single entry.
Nor can I see where last frame would be updated to something else.
All I can see are Inserts.


I'm wondering if it would be fine if I treat all frames as bulk and last one as Normal and update the entry after each frame and create a new one every 100 frames?

Code: Select all

if (currentFrameId = 1) {
insert frame type single
} else if (currentFrameId == 3) {
update frame type = bulk where frameId = 1
update frameId = currentFrameId where frameId = 2
} else if (currentFrameIf % 100 == 99) {
update frame type = bulk where frameId = currentFrameId - 1
insert frame type single
} else  {
update frame frameId = currentFrameId where frameId = currentFrameId - 1
}
This should give me entries like:

Frame 1:
FrameId = 1, Type = Single

Frame 2:
FrameId = 1, Type = Single
FrameId = 2, Type = Single

Frame 3:
FrameId = 1, Type = Bulk
FrameId = 3, Type = Single

Frame 4
FrameId = 1, Type = Bulk
FrameId = 4, Type = Single

Frame 100
FrameId = 1, Type = Bulk
FrameId = 100, Type = Single

Frame 101
FrameId = 1, Type = Bulk
FrameId = 100, Type = Bulk
FrameId = 101, Type = Single

Frame 201
FrameId = 1, Type = Bulk
FrameId = 100, Type = Bulk
FrameId = 200, Type = Bulk
FrameId = 201, Type = Single


Is this ok?

I know I should just load the damn data and see for myself, but it will take a bit of time before I will so maybe I could get some pointers?

Thanks,
Krystian
Locked