-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Very very helpful #1
Comments
Hello, I'm glad you found it helpful. |
Things are a bit hectic here at the moment, and I got off on a bender playing with this. But we get done I'll upload it, somehow lol |
A follow up. The additional code to just detect and report AI state is minor, call it a dozen lines which I'll post if you want. But this in turn led to other things like reporting a different score for face, people, vehicles, and pets, which makes it easy to work with in ZM events. Call it another dozen lines half of which are definitions. While changing the ZM trigger command line to report that I added the "showtext" parameter with %Q in my ZM cam timestamp and it will now show on screen in the captures. Here's where things got deep. Continual trigger commands sent within the Trigger_Time period extends the first trigger which is really nice. But you do not need or even want to wait for a reply. Connect and send is blazingly fast, less than 0.001s. But receive is a consistent 0.25s if my server is "idling" (quad Xeon 3.7 64G SSD+HDD), and I've seen close to 5s if it's "in use". Motion detection queries are also fairly fast, 0.06 to 0.12s per camera, but these are their latest hardware and are on two dedicated gigabit ports. By changing the inter camera delay to a loop delay, and removing the wait for trigger reply, I can now easily poll a half dozen cameras each second with headroom to spare. But I want to be able to do twice that many so I stepped off into threads, found out about Python's GIL, then processes, then a combination of the two. Wrote some test code that can best be described as overkill. Outside of benchmarks and video encoding I've never seen my 7950x max all 16 cores before lmao. Now I'm looking at asyncio which should do the job just fine up to some arbitrary point. Wish I knew more about Python cuz there is a part of me that says "this would have been easy in assembler" :) As I get time I'll wrap that up and we'll go from there. |
@SoonerCentral Would you mind posting your extra/altered code? I've just discovered that my new Reolink doorbell has an API and, better still, that it's AI-driven person detection works really rather well and seemingly far better and more reliably than what my Zoneminder instance itself can achieve (or is achieving - maybe I just need to configured the zones better). Whilst I started to roll my own code to tap into the API and got things working, albeit crudely, I then stumbled across @ArthurMitchell42's code (thanks for sharing) and your additions sound like what I'd likely go on to explore also. |
My apologies for the slow reply. I've been busy helping the "kids", and about to be grandad x2 lol. I've got the "simple" AI test part mentioned when I wrote the above and will dig it out ASAP. Were I stopped at, and really need to get back to, is a different beast. So let me explain where I went first. |
Whoops, hit ctrl-enter. I've 5 different models of Reolink cams now and while the doorbell is one of them and on the network I've not "done anything with it" yet. That's when life popped up. Right before I started messing with asyncio I had changed the config to only need make, dns/ip, and zoneminder ID. KISS principle, which was handy as I was moving cams models around. This fleshed out the structure for calling different "modules" for different manufacturers to detect the camera's capabilities, and said "module" would set what function to call for the detection check for a particular model. If motion was detected that function would call our trigger routine with a cam id and text argument of what caused it, which is passed as part of the descriptive text to ZM. I was getting a lot of "false" events. Trimming a few tree limbs and blocking off the rest within the cam setup helped with a lot but sunrise liked to set them off, as did bugs due to the IR lights. Some looked liked flying dragons in the playback lol. But wind in particular was an issue especially with my 12MP shooting down a long driveway. Having memory cards in each cam for event storage, and how the Reolink app/program handles those, gave me some ideas. |
Event detection is one thing, but actual alerts are another. I don't want the latter unless it's highly like that it's "real". I've got one cam that way but it covers a very restricted area. A 2nd has two spots that it likes to confuse as "human". The driveway 12MP is about worthless for vehicle detection but the person part works great. And what about when I'm out there, |
Gotta learn to quit hitting ctrl-enter. I can use the "score" parameter when calling zm_trigger, and from that likely "do something different" depending on time of day and cam. But what it really needs to do is detect the presence of a file or receive a signal that indicates to ignore motion detection for all cameras in a "zone". And that's were I stopped, after spending days tracking down all the prior API version documention. Only to find out that a lot of the higher end calls don't work which is a separate story. Now, with all of this out, yeah, I'll get you the code that queries for AI detection and will return a string indicating why an event happened. But that's not all you want, I promise lol. But it will take me a day or three. I'm not actually "home" right now :) |
Congratulations @SoonerCentral on becoming a grandfather. Does the 'x2' mean twins, or second time over? Either way I'm sure you'll be kept busy! :-) Since my initial post I wrote my own Bash script to poll my doorbell for AI person detection and have been really pleased with its performance. So pleased in fact that not only do I use it to trigger Zoneminder to record but also to trigger my security lights (if it is also nighttime) as the person detection seems even more reliable than my PIR sensors which inevitably get falsely triggered by other things too. To scale this up though I was keen to take advantage of Reolink's support for ONVIF push notifications (rather than relying on periodic polling) and found the reolink_aio Python tool but unfortunately haven't been able to try it yet as it requires a later version of Python than I've got so I need to update my OS first. That said, the same guy writes the Reolink integration for Home Assistant and it is not the first time that tool has been flashed in front of me so I probably ought to explore the use of something like that rather than rolling my own code each and every time I want to do something like this. |
I have ZoneMinder setup to do a Record at high res and Nodetc at low for each camera. Both are in passthrough with no decoding and the system literally just idles, almost no CPU usage, by using this script. From what I saw 1.37 will be able to do this with ONVIF so strictly speaking this script won't be necessary when it's fully released.
But I didn't see anything about being able to issue commands via the camera's API. There is another one that was easy to adapt this script to, and that's GetAiState. Now I have a log of what type of motion is tripping the camera's detection. That is proving invaluable for initial setup but I have no idea how to send it to you. Never used github, I'm old school assembler, started with punch cards, now retired lol.
I do disagree with using crontab to launch this as it will crash if you edit your camera definitions in ZM, so I made it a system service so it will auto restart.
The text was updated successfully, but these errors were encountered: