Kurbas-640 (alpha): USB connection

[V.1.0] USB connection
Г
Written by Гліб
Updated 1 week ago

The camera has been confirmed to work with Raspberry Pi 5, Raspberry Pi Zero 2 W and Orange Pi 5.

Connection Diagram

  1. Solder the USB cable to the camera harness according to the pinout:
    Camera wire
    USB wire
    Signal
    Red Red Power Positive
    Black Black Power Negative
    Green Green USB_2.0_DP
    White White USB_2.0_DM

  2. Insert the cable into the USB connector on the board.

  3. Checking the Camera in the Console
  • Install the required utilities

    sudo apt update && sudo apt install -y v4l-utils ffmpeg

  • Verify that the camera is detected.
    Run the command below and look for a block whose name in parentheses starts with usb-… — this is your USB camera.
    The first line under that block (usually /dev/video0) is the video node you should use.
    If no such block appears, the system did not recognise the camera; check the cable, power supply, or reconnect the device.

    v4l2-ctl --list-device

  • Display the camera image


ffplay -f v4l2 -video_size 640x512 -i /dev/video0

Additional Check via Python + OpenCV

  • Install the required packages

    sudo apt update
    sudo apt install -y python3-opencv python3-numpy v4l-utils

  • Verify that the camera is detected.
    Run the command below and look for a block whose name in parentheses starts with usb-… — this is your USB camera.
    The first line under that block (usually /dev/video0) is the video node you should use.
    If no such block appears, the system did not recognise the camera; check the cable, power supply, or reconnect the device.

    v4l2-ctl --list-devices

  • Go to your home directory

    cd ~

  • Create a test file

    nano test.py

  • Paste the following code:

    import cv2
    import time

    DEVICE = "/dev/video0"          # замініть, якщо іншій нод
    WIDTH, HEIGHT = 640, 512

    cap = cv2.VideoCapture(DEVICE, cv2.CAP_V4L2)
    cap.set(cv2.CAP_PROP_FRAME_WIDTH,  WIDTH)
    cap.set(cv2.CAP_PROP_FRAME_HEIGHT, HEIGHT)

    if not cap.isOpened():
        raise IOError(f"Не вдалося відкрити {DEVICE}")

    print("Натисніть 'q' для виходу")
    t0, frames = time.time(), 0
    while True:
        ret, frame = cap.read()
        if not ret:
            print("Кадр не зчитано"); break
        cv2.imshow("UVC 640×512", frame)
        frames += 1
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    print(f"Середній FPS: {frames / (time.time() - t0):.1f}")
    cap.release()
    cv2.destroyAllWindows()

  • Save code → Ctrl + O, Enter, вийдіть → Ctrl + X.

  • Run the file

    python3 test.py



Did this answer your question?