Keyboard Shortcuts
Likes
Search
ONVIF Camera PTZ Control Protocol
There is kind of a good news/bad news situation going on with Crestron Onvif support at the moment.
The good news? ? Crestron has created a Simpl# class to deal with Onvif. ? This should make creating an Onvif control reasonably easy. The bad news? ?Their toolchain is broken and won't properly link/copy the necessary DLLs, so it is currently dead in the water. |
Recently I've been investigating ONVIF to control an IP PTZ camera. Looked through all the ONVIF protocol documentation and did some snooping with Wireshark. I found this old thread in here, but I see it's been over a year since anybody added to it. Is there anything new on this front? Has anybody successfully written a Crestron module that uses ONVIF for camera control? Has anybody even tried, or is the Simpl # stuff still broken as previously mentioned? As ONVIF becomes more ubiquitous, seems like this could be really useful. |
Since the last inquiry was made almost four years ago, I'm wondering if anyone has found a solution for this - specifically, an ONVIF module for Simpl programs?
toggle quoted message
Show quoted text
On Mon, Sep 25, 2017 at 09:48 AM, <bryanga@...> wrote:
|
Everyone on this tread is asking for a generic ONVIF driver, when I think they should be asking for a Manufacturer specific driver.
I've been using an ICRealtime NVR, and IP module. It actually controls the PTZ cameras better than its own WebGUI. The WebGUI moves it a little roboticly. But when put on the buttons of a HR310, through the module, it drives like an RC Car. |
This is one of those problems I'd try to solve by using ChatGPT, Raspberry Pi, and Python.? The reason for these is simpl(e): ChatGPT has access to billions of lines of Python code, yet virtually no SIMPL / S+ / S# code, in order to be proficient at giving high quality solutions.? By ChatGPT, I'm referring to the premium version that costs $20/month -- there's a huge quality difference.? ChatGPT will write "hello world" scripts to talk to new hardware and get it about 95% right on the first try, reducing the workload to just filling in that 5% gap.
The basic premise is this:? Can I get ChatGPT to help me write code to get a Raspberry Pi to move that camera the way I'd like?? Generally I can get something new and novel talking in 20 minutes or less to a RasPi, with a fair bit of luck.? When I ask it to write for ONVIF, it already knows how to pull in open-source ONVIF libraries and take advantage of other people's hard work. If I succeed, then it's a simple matter of getting SIMPL to "push the buttons" on that Raspberry Pi over serial or UDP (which works reliably), and then configuring the RasPi to automatically start my middleware upon boot.? Set and forget.? RasPi's weak spots are overheating and corrupting SD cards, both of which are solved just by buying commercial grade (e.g. DIN-rail-mount) RasPi's with inbuilt eMMC memory so that SD cards aren't needed.? Passive cooling works better than fans (because a RasPi with these middleware scripts sits at 0-2% CPU usage all day...they don't generate much CPU heat to need the fan... fans become a mechanical point of failure and I'd like a solution I can set and forget)... |
Just to see if my word was good, I tried exactly what I proposed, and got results in less than 20 minutes on an Axis PTZ camera.
First minute: I opened ChatGPT and typed "How on a Raspberry Pi in Python can I send PTZ commands to an ONVIF-compliant IP camera?" Second to fifth minute: reviewed the script it gave me, and put my actual camera IP, username, and password in place of its placeholders.? Ran the script.? Got an error. Sixth through tenth minutes: troubleshot "Sender not authorized" error message.? Turns out I have to add a special ONVIF username and password to the camera. Eleventh through fifteen minutes: still got the "sender not authorized" message.? Googled for help, turns out there's also a checkbox I had to click on Axis cameras to unblock something. Sixteenth through seventeenth minute: got an "Unknown Error", turns out the Python script asks the camera for all of its configuration info and never uses it.? Commented that part out, problem went away. Eighteenth minute: ran the script again.? The camera started moving to the right (the sample action that ChatGPT coded) for 10 seconds.? Awesome.? Other than my PTZ cam is now pointed a at wall :) , so, I manually moved the camera back through its web UI. Since I'm done with this script, I need do no further...but to make it talk to Crestron, I would add a UDP listener and add actions for each of the four cardinal directions (or ask ChatGPT how to load a named/numbered preset) and then a SIMPL UDP/IP connection to trigger this from within a project.? I'm too lazy to do this myself, but maybe ChatGPT could do this for me. Working script that simply moves the camera (with no UDP listener)
Not to beat a dead horse, but my next request to ChatGPT was: "Great! Let's modify this script to first 1) remove the request for the configuration information we aren't using, and 2) also listen on UDP port 5555 for packets containing a single string "UP", "DOWN", "LEFT", "RIGHT", and upon receipt, move the camera the named direction." The script it generated did exactly as requested and needed no modifications (beyond re-adding my credentials), and I used a "UDP Packet Sender" app to craft test packets to make it work.? It moves the camera too far per step, but it's easy to see where I can change a number to fix that.? Not pasting it for the sake of brevity unless someone asks (it gets long since ChatGPT made it multi-threaded) I'm into this 30 minutes just for the glee, and have a working solution... that is, if a RasPi is a tolerable addition to the setup. |
The fact you¡¯re using chatGPT, and that you use phrases like ¡°needs a special Onvif username and password¡±, and that you no doubt don¡¯t a) understand what Onvif is, or how it works and b) have no idea what that code (script!) is actually doing, fills me with dread, and reminds me of one colleague of mine that thinks that getting some resemblance of a working result using chatGPT puts the them in a better place than understanding the the hell is going on.? Do yourself a massive favour, download the Onvif device manager (official), read the Onvif api, learn what UDP and HTTP actually mean, and become an actual developer. |
Hi DizzyEgg -- "needs a special Onvif username and password" is a characteristic of the specific Axis camera I tested this on, which uses a separate authentication system for ONVIF?.? My professional accomplishments earning a living solving problems writing code are such, that whether I'm an "actual developer" isn't a serious question for me or anyone who knows me personally.
While HTTP and UDP are something I understand down to the frame level, I am not in the business of developing driver products for cameras -- the point is that I don't WANT to implement Onvif, I want to be able to let my user push a button and move their camera without waiting for 8 more years (this thread started in 2016) for someone to put together a quality S# driver.? This simple Python script does it today.? And I have ChatGPT to thank for putting a script together, which I'm able to follow and tweak, but certainly not compose from scratch in under 30 minutes.? A $350 din-mountable Raspberry Pi from DigiKey (e.g. Iono Pi by Sfera Labs) is robust enough to host it for me looking 100% professional, and then I'm off to solving another problem. I don't think anyone who posted in this thread wants to implement Onvif from scratch either.? I think any of us would gladly use an open-source library from a Python repository to solve a customer's problem.? There's no extra credit for originality, only functionality.? It's open source software running on an isolated device, so, not even intellectual property concerns arise.? I think the point I'm trying to make, is that Python and ChatGPT are tools we can use to solve problems in less than 8 years and that S# isn't the only tool in the toolchain in the world of installing Crestron gear. Also UDP is GREAT for getting signals out of SIMPL and into Raspberry Pi.? Despite being "connectionless" by definition, in my experience running it over Ethernet it's more reliable than IR and is definitely adequate for transporting UI button presses.? You send a string to SIMPL's UDP/IP block, and it shows up intact on the Raspberry Pi that's listening, well over 99.9% of the time, and it's really that simple.? If I go read RFC 768 defining UDP, that knowledge is a bonus, but not necessary for me to solve problems with it! One more benefit using Pi's is there's an HDMI port that can be plugged in for troubleshooting issues with the script (and RPi's also support VNC out of the box).? Any time I dedicate a Pi to something like this, I set it to boot up so the script runs with its output onscreen 24/7, so troubleshooting is as simple as viewing HDMI Out or connecting with VNC.? I'm happy to share the scripts I use to quickly set up Pi's this way from out-of-the-box condition, autobooting to the script(s) of your choice, onscreen. |
I¡¯ve been playing around with Bitfocus Companion as a ¡°gateway¡± to devices that are a hassle to control from Crestron, or not worth the effort to write my own code from scratch. Similar approach to yours. Send serial strings (that I define) from Crestron over UDP or TCP connection to Bitfocus, which performs desired action based on received string. I¡¯ve been testing with a PC, next step is to install Companion on Pi.? |
I like the being able to test on a PC.? Python is very much a "get things done" language, and works identically on PC and Mac (for development and testing's sake).? Good on you for picking the tool that does the job of talking best to the gear you want to use.
My favorite integration I've done is an SMS text messaging bot, to & from Crestron.? The homeowner can open gates, lock/unlock doors, and request a check all of the doors for the whole house (done via the security system), and other things (like fireplaces left on), just by sending a text message (the status comes back as reply).? This works by using Twilio SMS to provide a dedicated phone number for the messenger, and then my Python messenger code is hosted on a dinrail RPi, and talks to Crestron processor via RS232, where I've got logic blocks that forward on the signals the text messenger would care about.? Most of the work of properly communicating with Twilio (including proper authentication) would be cumbersome to do in S# but is comfortable in Python, especially where Twilio themselves gives you sample Python code to utilize their services. The ONVIF test code I did at first "for the glee" but now that I did it, at some point I will likely actually implement it in real life, now that I've gone to the effort of observing that it actually works (and in a vendor-neutral way as a bonus!)? Before it's production ready, it'll need proper error handling (so it doesn't crash with a TCP exception if a camera is offline), support for multiple cameras (why control just one?)... the ability to recall "home position" and other presets (originally set by homeowner via camera web UI) as well as making it so that the "stop" command happens upon a UI button release, rather than having chunky steps of movement per button press. |