[Python] Trying to send commands to Sony FCB-EV7520 camera

Discussão em 'Python' iniciado por Stack, Junho 9, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to send zoom commands, or any other commands to this camera:

    Sony FCB-EV7520

    I followed the instruction in their manual and tried to implement it in a Python script, but the none of the commands will work.

    When I go to its web page, and I use it to send the same messages for zoom in and out, it works perfectly.

    This is my current code: *I hide the actual camera information

    import cv2
    import socket
    import time

    # Camera details
    username = "****"
    password = "****"
    camera_ip = <IPADDRESS>
    camera_port = <PORT>
    rtsp_url = f"rtsp://{username}:{password}@{camera_ip}:8554/bandwidth_h264"

    # VISCA commands
    address_cmd = bytes.fromhex("88 30 01 FF") # Set address command
    if_clear_cmd = bytes.fromhex("81 01 00 01 FF") # IF_Clear command
    zoom_in_msg = bytes.fromhex("81 01 04 07 02 FF") # Zoom in command
    zoom_out_msg = bytes.fromhex("81 01 04 07 03 FF") # Zoom out command

    def send_visca_command(cmd):
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
    sock.connect((camera_ip, camera_port))
    sock.sendall(cmd)
    time.sleep(0.1)

    def initialize_camera():
    # Send Address command to set the camera's address
    send_visca_command(address_cmd)
    time.sleep(1)

    # Clear command buffers in the camera
    send_visca_command(if_clear_cmd)
    time.sleep(0.5)

    def main():
    # Initialize camera settings
    initialize_camera()

    # Open RTSP stream
    cap = cv2.VideoCapture(rtsp_url)

    if not cap.isOpened():
    print("Error: could not open RTSP stream")
    return

    while True:
    ret, frame = cap.read()

    if not ret:
    print("Error: Failed to capture frame.")
    break

    cv2.imshow('RTSP Stream', frame)

    key = cv2.waitKey(1) & 0xFF
    if key == ord('q'):
    break
    elif key == ord('+'):
    send_visca_command(zoom_in_msg)
    print("Zoom in command sent.")
    elif key == ord('-'):
    send_visca_command(zoom_out_msg)
    print("Zoom out command sent.")

    cap.release()
    cv2.destroyAllWindows()

    if __name__ == "__main__":
    main()

    Continue reading...

Compartilhe esta Página