abishevs / wifi-car-with-raspberry-pi4 Goto Github PK
View Code? Open in Web Editor NEWFlask app with raspb camera view to control and see arduino based RC car from a browser.
Flask app with raspb camera view to control and see arduino based RC car from a browser.
i see video on page but it is bit too laggy.
so i tried to rewrite two parts of camera.py:
from picamera.array import PiRGBArray
from picamera import PiCamera
class VideoCamera(object):
def __init__(self, flip = False, file_type = ".jpg", photo_string = "photo-taken"):
#self.vs = PiVideoStream(resolution=(640, 480), framerate=30)
self.vs = PiCamera(resolution=(640, 480), framerate=30)
self.rawCapture = PiRGBArray(self.vs)
#self.vs.start()
#self.vs = PiVideoStream().start()
and
def get_frame(self):
#frame = self.flip_if_needed(self.vs.read())
for frame in self.vs.capture_continuous(self.rawCapture, format="bgr"):
#ret, jpeg = cv.imencode(self.file_type, frame)
self.rawCapture.truncate(0)
self.image = frame.array
ret, jpeg = cv.imencode(self.file_type, self.image)
#self.previous_frame = jpeg
return jpeg.tobytes()
dont know if it start working a bit faster...
may be a better solution is io.BytesIO()
https://stackoverflow.com/questions/40065328/picameravalueerror-incorrect-buffer-length-for-resolution-1920x1080
hi!
thanks for code. i use it in raspberry pi zero 2.
as far as i understand the main logic of control is here:
def retrieve_data():
id = request.args.get('id', 0)
id = int(id)
print(f"Recieved from the web id: {id}")
if 1 <= id <= 5:
write_to_arduino(id)
i have changed for my case this way (as i have no arduino and made direct connection to motor driver):
def retrieve_data():
id = request.args.get('id', 0)
id = int(id)
print(f"Recieved from the web id: {id}")
if 1 <= id <= 5:
#write_to_arduino(id)
if id==4:
setServoAngle(servo, 140)
if id==5:
setServoAngle(servo, 90)
if id==1:
mov.Forward(speed)
if id==2:
mov.Backward(speed)
if id==3:
mov.Stop()
but as i see there is synchronous code and when one key pressed there is no way to press another at the same time.
are you planning to add something async?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.