We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to do live stream webcam frames but stuck in for loop pubstub listen. Is there any way to do this?
Python code
import redis import base64 import cv2 r = redis.Redis(host="localhost", port=6379, db=0, decode_responses=True) pubsub = r.pubsub() pubsub.subscribe("send") r.set("hello", "world") r.publish("message", "hello") print("Waiting for messages...") cam = cv2.VideoCapture(0) while True: success, frame = cam.read() for request in pubsub.listen(): if request["data"] == "img": with open("test.jpg", "rb") as img_file: my_string = base64.b64encode(img_file.read()) r.publish("imageBase64", my_string) if request["data"] == "imgcv": source = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) success, encoded_image = cv2.imencode('.jpg', source) content = encoded_image.tobytes() r.publish("imageBase64", base64.b64encode(content).decode('ascii'))
The text was updated successfully, but these errors were encountered:
My bad. changing success, frame inside of request solved it.
Sorry, something went wrong.
No branches or pull requests
I want to do live stream webcam frames but stuck in for loop pubstub listen.
Is there any way to do this?
Python code
The text was updated successfully, but these errors were encountered: