Opencv on browser

Hi everyone,

I’m working on converting a Python Tkinter GUI application into a web app, with Flask as the backend and React for the frontend. For real-time communication, I’m using Socket.IO.

To give some context, the application is a digital microscope that captures images using OpenCV by setting the appropriate camera properties. These images are then processed using PyTorch and other libraries.

As I transition to a web app, I’m facing a challenge: the camera will be on the client side, and opencv.VideoCapture() won’t be able to access the client’s hardware directly.

Does anyone have suggestions on how to overcome this technical issue? I’m really stuck and would appreciate any advice.

Thanks in advance!

crosspost:

hmm, at least you see the elephant in the room …

as you found out, that won’t work anymore, you’ll have to do with html5&js. would the microscope still work then ?

tell us more about this cam, please !
do you get opencv.js to run with it, locally ?

this is the code that’s being done in the python gui application, i want to replicate it in the web app.

cam = cv2.VideoCapture(camera_port, cv2.CAP_DSHOW)

    cam.set(cv2.CAP_PROP_FRAME_WIDTH, x_res_.value)
    cam.set(cv2.CAP_PROP_FRAME_HEIGHT, y_res_.value)

    # Set camera properties
    cam.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*"MJPG"))
    cam.set(cv2.CAP_PROP_EXPOSURE, exposure.value) # -8
    cam.set(cv2.CAP_PROP_GAIN, gain.value) # 1.0

related: