0

Let's suppose I'm streaming a video to a browser, for example using one of the solutions reported here:

Streaming openCV C++ video to the browser

Let's suppose I would like to select a region of the streamed video for example with a rectangle drawn with the mouse and then I want to send the coordinates of the vertexes of the rectangle to the server.

I could connect server and client with websockets, for example, but I do not know how to handle the fact that I have a streaming loop in the server that cannot be interrupted, while at the same time I have to check for mouse input on the client and then send the result of the mouse position to the server that could decide to modify the streamed output depending on the mouse position (for example I would like to apply a specific image filter to the selected rectangle).

How could I achieve this?

Obsidian
  • 3,719
  • 8
  • 17
  • 30
egev
  • 33
  • 1
  • 5
  • The question seems a bit broad. Do you have control over the server code? If the streaming loop is fast enough you could add hooks and process input. Or you could do it via concurrency or ...? Maybe you can share more specifics about your problem? – Seriously Jan 24 '22 at 12:07
  • Hello, thank for your comment. Yes, I am trying to develope both the server and client code. In the server code I have a simple loop with a certain frame rate. Basically it is a while loop in which at every thick I want to process the inputs and diplay a new image frame of the video that will be processed depending on the inputs of the user on the client. In the client I would like to implement a series of button like: start stream, apply a filter and stuff like this. But how can I read the websocket messages coming from the client during the while loop and process the inputs? – egev Feb 09 '22 at 13:42
  • And, of course, websockets will send also mouse position to the server that will have to process also this kind of input for example to apply a specific filter around the current mouse position or something like that – egev Feb 09 '22 at 13:59

0 Answers0