Having Problem with setZoomTarget, and looking for a method to use in a more complex code

Hello I am currently trying to attempting to use olympe to set the zoom on the camera of the gimbal camera of the drone. I am using a parrot anafi, but my code doesn’t seem to be doing anything.

Code:
import olympe
from olympe.messages.camera2.Command import SetZoomTarget
from olympe.messages.camera2.Event import ZoomLevel

DRONE_IP = “192.168.42.1”

drone = olympe.Drone(DRONE_IP)

Connect to the drone

drone.connect()

try:
# Perform zoom operation
set_zoom_command = SetZoomTarget(
camera_id=0,
control_mode=“level”, # You can use “velocity” if you prefer
target=0.5, # Set the zoom level (0.0 to 1.0)
)

zoom_result = drone(set_zoom_command).wait()

if zoom_result.success():
    print("Camera zoom set successfully.")
else:
    print("Failed to set camera zoom.")

except Exception as e:
print(f"Error: {e}")
finally:
# Disconnect from the drone
drone.disconnect()

The goal is to combine it with a larger code for object detection. Here is the github if anyone is interested:

Hi,

The Camera2 feature is only supported by Anafi AI. For Anafi 4K, Thermal or USA, you should use the Camera feature instead.

This topic was automatically closed after 30 days. New replies are no longer allowed.