Untitled
unknown
plain_text
a year ago
904 B
3
Indexable
Never
import cv2 import requests import base64 def capture_image(): # Access the webcam video_capture = cv2.VideoCapture(0) # Capture a frame ret, frame = video_capture.read() # Release the webcam video_capture.release() return frame def send_image(image): # Encode the image as base64 _, buffer = cv2.imencode('.jpg', image) image_base64 = base64.b64encode(buffer) # Send the image to the server url = "https://2651-103-87-58-117.ngrok-free.app/upload" # Replace with your server URL response = requests.post(url, json={"image": str(image_base64)}) # Process the server response if response.status_code == 200: print("Image uploaded successfully.") else: print("Error uploading the image.") # Capture an image using the webcam captured_image = capture_image() # Send the image to the server send_image(captured_image)