Hi,

In my application, I run the pipeline in 30 FPS for object detection, then the pipeline publish image to ROS topics for downstream tasks, which only need 5 FPS. The node publishing image to ROS is similar to this example.

The example use `dai::rosBridge::BridgePublisher` to publish image data in the same rate as the pipeline. Publishing ROS image message in such high rate costs a lot of network bandwidth and CPU especially for devices like Raspberry Pi. Is there a way to publish in a lower FPS than the original pipeline?

Thanks

Lincoln

  • jakaskerl replied to this.
  • lincolnxlw
    The is no way to do this from ROS (publisher) side, but you can add a filter on depthai side using a Script node.

    # Define the script content
    script.setScript("""
    # Python script to pass only every sixth frame
    counter = 0
    
    while True:
        # Get incoming frame
        frame = node.io['in'].get()
        
        # Check if counter is a multiple of 6
        if counter % 6 == 0:
            node.io['out'].send(frame)
        
        # Increment counter
        counter += 1
    """)

    Thansk,
    Jaka

    lincolnxlw
    The is no way to do this from ROS (publisher) side, but you can add a filter on depthai side using a Script node.

    # Define the script content
    script.setScript("""
    # Python script to pass only every sixth frame
    counter = 0
    
    while True:
        # Get incoming frame
        frame = node.io['in'].get()
        
        # Check if counter is a multiple of 6
        if counter % 6 == 0:
            node.io['out'].send(frame)
        
        # Increment counter
        counter += 1
    """)

    Thansk,
    Jaka

      a month later