No ISP, video encoder drivers in beagley ai.

I tried to use hardware isp in beagley ai. But its failing again and again.

I was able to capture raw image from the imx219 sensor in bayer format and processed it using a python script.

When i tried checking available hardware. I was able to confirm the availability of jpeg encoder e5010 , wave5 decoder.

There seems to not be any driver for ISP to convert bayer format, no h.264 or hevc encoder drivers.

Does anyone know how can i find these drivers and activate them (if already present in BeagleY-AI Debian 12.9 2025-03-05 XFCE (v6.6.x-ti) image ) or how can i import them into beagley ai.

1 Like

I have been following the forum on this subject but none of the methods worked for me.

May you share the command you used to get the raw image and the python script you used?

Thank you.

This one shows how to get the raw image.

You need to configure camera to get a raw image.

In the below thread there is a setup_cameras.sh file. Which takes care of setup.

Compile this script and run it. After setup run below commands to capture the raw image.

$ ./setup_cameras.sh
$ gst-launch-1.0 -v v4l2src num-buffers=5 device=/dev/video-rpi-cam0 io-mode=dmabuf ! \
video/x-bayer, width=1920, height=1080, framerate=30/1, format=rggb ! \
multifilesink location="imx219-cam0-image-%d.raw"

$ gst-launch-1.0 -v v4l2src num-buffers=5 device=/dev/video-rpi-cam1 io-mode=dmabuf ! \
video/x-bayer, width=1920, height=1080, framerate=30/1, format=rggb ! \
multifilesink location="imx219-cam1-image-%d.raw"
pip install rawpy imageio

The python code

import rawpy
import imageio
import numpy as np

# --- Configuration ---
raw_file_path = 'your_image.raw'  # Replace with the path to your .raw file
jpeg_file_path = 'output_image.jpeg' # Replace with the desired output JPEG path
image_height = 1080
image_width = 1920
# Bayer pattern (for rawpy, often auto-detected, but good to know)
# 0=RGGB, 1=GRBG, 2=GBRG, 3=BGGR (Check your camera/sensor spec if unsure)
# 'RGGB' corresponds to pattern 0 typically.

try:
    # --- Using rawpy (Recommended for camera RAW files) ---
    print(f"Attempting to read RAW file: {raw_file_path} using rawpy")
    with rawpy.imread(raw_file_path) as raw:
        print("RAW file read successfully. Post-processing...")
        # postprocess() handles demosaicing, color correction, etc.
        # use_camera_wb=True tries to use the white balance from the camera metadata
        # output_bps=8 sets the output bit depth to 8 for JPEG compatibility
        rgb_image = raw.postprocess(use_camera_wb=True, output_bps=8)

        # Check if the output dimensions match (rawpy might auto-detect)
        print(f"Processed image dimensions: {rgb_image.shape}")
        if rgb_image.shape[0] != image_height or rgb_image.shape[1] != image_width:
             print(f"Warning: Processed dimensions ({rgb_image.shape[0]}x{rgb_image.shape[1]}) differ from expected ({image_height}x{image_width}).")

        print(f"Saving processed image to: {jpeg_file_path}")
        imageio.imwrite(jpeg_file_path, rgb_image, quality=95) # Adjust quality (0-100) as needed
        print("JPEG image saved successfully.")

except rawpy.LibRawNoMetadataError:
    print("rawpy couldn't find metadata. The file might be headerless raw data.")
    print("Attempting manual read with NumPy and OpenCV...")
    # --- Fallback for Headerless RAW Data (Requires OpenCV) ---
    # You might need: pip install opencv-python
    import cv2

    try:
        print("Reading raw data with NumPy...")
        # Assuming 8-bit raw data for simplicity. Adjust dtype if it's 10-bit, 12-bit, 16-bit etc.
        # e.g., np.uint16 for 16-bit. You might need specific unpacking for packed formats (like 10/12-bit).
        bayer_data = np.fromfile(raw_file_path, dtype=np.uint8).reshape((image_height, image_width))

        print("Demosaicing using OpenCV (RGGB pattern)...")
        # Use cv2.COLOR_BAYER_RG2BGR for RGGB pattern
        # Other patterns include: _BG, _GB, _GR
        rgb_image_cv = cv2.cvtColor(bayer_data, cv2.COLOR_BAYER_RG2BGR)

        print(f"Saving processed image to: {jpeg_file_path}")
        # OpenCV uses BGR order, imwrite handles it correctly for JPEG
        cv2.imwrite(jpeg_file_path, rgb_image_cv, [int(cv2.IMWRITE_JPEG_QUALITY), 95])
        print("JPEG image saved successfully using OpenCV.")

    except ImportError:
        print("Error: OpenCV is required for the fallback method. Please install it: pip install opencv-python")
    except Exception as e:
        print(f"Error processing headerless RAW data: {e}")

except FileNotFoundError:
    print(f"Error: Input file not found at {raw_file_path}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")
1 Like