I already have a web server set up with NGINX showing a live webcam feed from the mjpg streamer as part of a laser tag game where the idea is for the user to be able to view a live camera stream by going to a local website. However, at this stage I would like to add motion detection capabilities by using the motion package, as shown here to process the mjpg live stream.
The reason I don't want to simply use motion is because it has more of a delay than mjpg-streamer. When the user is viewing the live camera feed from a page on the local web server, I would like for the user to be notified if there is any motion detection (possibly through a JavaScript alert). Motion allows for any command to be run through the command line if motion is detected.
Is there a shell command (maybe even to start a python script, etc.) which could communicate real-time (AJAX setup on the web server?) to the live HTML page showing the live camera feed running on the client device?
I would really appreciate it if you could answer my question and help me with this issue! Thanks for taking the time to read the question!
Update:
Ok, so I've been doing some research, and I believe (but I am not completely sure) that a publish-subscribe API could work for my purposes. I found PubNub to be a popular for real-time communication. I have also found some people using it with the Raspberry Pi like in this example (I am comfortable with C programming so I would prefer to use it to work with PubNub).
Looking around their website, I found it is possible to also use PubNub with JavaScript as well, and I was curious to see if the two languages might be able to work together with PubNub. Theoretically, I would call a C program which would publish a message to the javascript on my NGINX web server, subscribed to the same channel. Finally, the JavaScript might respond with an alert. I think this would all happen without reloading the page.
I have not completely solved the problem yet, so I am curious to see if others would have any thoughts on how to implement this.