Skip to content
Snippets Groups Projects
Commit 22e751fb authored by s47700's avatar s47700
Browse files

Upload New File

parent e11ec3b2
No related branches found
No related tags found
No related merge requests found
import requests
from PIL import Image
from io import BytesIO
# Fetch camera image from OctoPrint
def fetch_camera_image():
#url = "http://192.168.0.205/webcam/?action=stream"
url = "https://www.example.com/image.jpg"
try:
response = requests.get(url, timeout=10)
print(f"Response status code: {response.status_code}") # Check the status code of the response
print(f"Response size: {len(response.content)} bytes") # Check the size of the response
return response.content
except Exception as e:
print(f"Error fetching image: {e}") # Log any errors
return None
def display_image(image_data):
if image_data:
try:
image = Image.open(BytesIO(image_data))
image.show()
except Exception as e:
print(f"Error displaying image: {e}") # Log any errors
else:
print("No image data to display")
if __name__ == "__main__":
image_data = fetch_camera_image()
display_image(image_data)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment