zayfod / pycozmo

A pure-Python communication library, alternative SDK, and application for the Cozmo robot.
MIT License
178 stars 58 forks source link

camera always in black and white #62

Closed cozmo14047 closed 10 months ago

cozmo14047 commented 10 months ago

hi how can i make the camera show color video here is my code @zayfod @gimait @solosito @ca2-chambers

import tkinter as tk from PIL import Image, ImageTk import pycozmo

root = tk.Tk()

root.title("Cozmo Camera Feed")

image_label = tk.Label(root) image_label.pack()

last_im = None

def on_camera_image(cli, new_im): """Handle new images from the robot.""" COLOR_CAMERA = True global last_im, image_label last_im = new_im

if last_im:

    im = last_im.resize((1700, 725))  
    im = im.convert('RGB')  
    photo = ImageTk.PhotoImage(image=im)

    image_label.config(image=photo)
    image_label.image = photo  # Keep a reference to avoid garbage collection

with pycozmo.connect(enable_procedural_face=True) as cli:

cli.add_handler(pycozmo.event.EvtNewRawCameraImage, on_camera_image)
cli.enable_camera()

root.mainloop()