Program to view MJPEG stream in gui

Post your working scripts, libraries and tools for AHK v1.1 and older
colt
Posts: 291
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Program to view MJPEG stream in gui

Post by colt » 09 Oct 2020, 17:37

This code will let you view a live MJPEG stream inside a gui. My original need for this functionality was to view python opencv output in my gui. See this thread for discussion viewtopic.php?f=76&t=81795&hilit=opencv

The heavy lifting is done by an activex plugin that can be accessed by installing the media control sdk that was provided by axis communications Axis-Media-Control. You do need to create an account to download the sdk, but it is free.

For testing I created a MJPEG stream using python and opencv. And connected to the stream using viewer.ahk
The python scripts create a webserver that pushes the modified frames from opencv. When the viewer.ahk navigates to the stream the viewer plugin will be installed.

main.py creates the flask webserver to host index.html
camera.py does image manipulation on the webcam frames
index.hml has code to load activex plugin to begin stream
viewer.ahk launches the python webserver and connects to the stream


This is the result. Lag is minimal, and time to live is very quick.

Image

User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Program to view MJPEG stream in gui

Post by kczx3 » 09 Oct 2020, 19:44

Do you really need to use an activex plugin for this? Seems like you can just set an img tags src property to the url and it will automatically stream the mjpeg

https://stackoverflow.com/questions/60509538/how-do-i-stream-python-opencv-output-to-html-canvas

colt
Posts: 291
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Re: Program to view MJPEG stream in gui

Post by colt » 09 Oct 2020, 20:25

kczx3 wrote:Do you really need to use an activex plugin for this?
Maybe not? In my experience the code from stack overflow was a turnkey solution for all browsers except for IE and internal gui. On IE and gui it resulted in a black x where image should be like image not found. If it works for you turn key I would be very interested in the details of your settings/setup.

User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Program to view MJPEG stream in gui

Post by kczx3 » 10 Oct 2020, 08:55

Ah I see. The only times I’ve played with python and cameras was with a RaspberryPi and that used Chromium so I had no issues. You could try to use WebView2. I have a post in the v2 scripts forum that hosts the Chromium based Edge in a GUI.

colt
Posts: 291
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Re: Program to view MJPEG stream in gui

Post by colt » 11 Oct 2020, 22:32

Embedding edge would do the trick, I'll keep this solution in mind. Unfortunately, I have yet to make the leap to v2. I am not sure if I ever will, kinda getting set in my ways. I will add this to my growing list of benefits of upgrading.

Post Reply

Return to “Scripts and Functions (v1)”