How can I make video streaming and robot control work smoothly together in my Flask project?
i am doing project using Flask where I’m streaming video to a website and also have a buttons iicons to control a robot (left and right up and down ..). Both the video streaming and the button works on their own, but I’m struggling to get them to run smoothly together. I need the video stream to stay continuous and responsive while still being able to control the robot without any hiccups , any body have ideas how to do that ?
10 Replies
you can make a system with esp32 which can talk with the Pc via uart then you can send the degrees of angle for the arm and you can interface with pyserial and flask
i already did the streaming and controling , i used pi 3 , but am looking for way to do both in the same time ,
what was the unusual behaviour if you can be a bit more specific?
i don't want the streaming to stop when i control the robot , i mean i want to do both at the same time , also am controling weels not arm
i will share my code
do you have any idea about
ajax
?
with ajax you can make http requests without loading the website
maybe your issue is when you try to control your url changes?
something like that happens and your stream got interrupted if i’m not wrong?
no i didn't try it before
mm no , so it's like if i run the streaming i can't control the robot and if i control the robot i can't run the streaming , am looking to add maybe a library or a code ollow me to do both
my code is a bit long to share it here , i will lookfor a way to share it
can I see your code also how you were sending the data to the wheel
you can use github gist
the vedio over HTTP using Flask and control over HTTP POST requests
yes , give me a minutei think I figured out your issue
so when we make a http request our webpage reloads
to avoid that please look about ajax
it is
ajax just work with html
so that you can make post requests without reloading the page
so you just have to add it into your html
ow okay i got it
it’s a Jquery library
i was looking for it and i underdtand your idea , i will try it
let me know if it fixes your problem or we have to look for any other solutions
yes , i will thanx
experimenting with adding first class support for the
esp32-cam
https://i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2020/03/ESP32-CAM-AI-Thinker-schematic-diagram.png?quality=100&strip=all&ssl=1 to zephyr still early stages but you can check it out here. So far so good.
https://github.com/DevHeadsCommunity/zephyr/tree/origin/esp32-cam-board-support/boards/espressif/esp32s2_camGitHub
zephyr/boards/espressif/esp32s2_cam at origin/esp32-cam-board-suppo...
Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures. - DevHeadsCommunity/zephyr
I found a library call 'schedule', for running tasks at specific intervals without blocking other parts of the program , so that means they can run in parallel, what do you think
That’s just time slicing, to run two things in parallel you would need more than once processor
Read about parallelism vs concurrency
GeeksforGeeks
Difference between Concurrency and Parallelism - GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Yes i understand the difference but I’m trying to run both tasks (control and streaming) in a way that feels as simultaneous as possible.
Ah well then you would run them concurrently not parallel. If you know what your deadlines are you can basically do everything in time and that should satisfy the simultaneous nature of your need.
this is the my code after the edit .