pyorbbecsdk icon indicating copy to clipboard operation
pyorbbecsdk copied to clipboard

Support for harware frame sync between color and depth frames on Astra2

Open lwqqwerf opened this issue 7 months ago • 1 comments

Hi, Does the Astra2 camera support hardware-based frame synchronization with zero time offset between color and depth frames?

I'm currently testing synchronization using the following code. With pipeline.enable_frame_sync() enabled, I still observe timestamp differences between the color and depth frames — typically fluctuating around 0–20 ms. My goal is to always have both frames captured at exactly the same moment (i.e., a timestamp difference of 0 ms).

Is this possible with Astra2?

Thanks!

def main(argv):
    pipeline = Pipeline()
    config = Config()
    parser = argparse.ArgumentParser()
    parser.add_argument("-s", "--enable_sync", help="enable sync", type=bool, default=True)
    args = parser.parse_args(argv)

    enable_sync = args.enable_sync
    try:
        profile_list = pipeline.get_stream_profile_list(OBSensorType.COLOR_SENSOR)
        color_profile = profile_list.get_video_stream_profile(1920, 1080, OBFormat.RGB, 30)        
        config.enable_stream(color_profile)

        profile_list = pipeline.get_stream_profile_list(OBSensorType.DEPTH_SENSOR)
        depth_profile = profile_list.get_video_stream_profile(1600, 1200, OBFormat.Y16, 30)
        config.enable_stream(depth_profile)

    except Exception as e:
        print(e)
        return

    if enable_sync:
        try:
            pipeline.enable_frame_sync()
        except Exception as e:
            print(e)

    try:
        print("Starting pipeline")
        pipeline.start(config)
    except Exception as e:
        print(e)
        return

    align_filter = AlignFilter(align_to_stream=OBStreamType.COLOR_STREAM)

    while True:
        try:
            frames = pipeline.wait_for_frames(100)
            if not frames:
                continue
            color_frame = frames.get_color_frame()
            depth_frame = frames.get_depth_frame()
            if not color_frame or not depth_frame:
                continue
            depth_width = depth_frame.get_width()
            depth_height = depth_frame.get_height()
            color_width = color_frame.get_width()
            color_height = color_frame.get_height()
            print(f"Depth Width: {depth_width},Depth Height: {depth_height}, Color Width: {color_width},Color Height: {color_height}")
            frames = align_filter.process(frames)
            if not frames:
                continue
            frames  = frames.as_frame_set()
            color_frame = frames.get_color_frame()
            depth_frame = frames.get_depth_frame()

            if not color_frame or not depth_frame:
                continue
            
            color_timestamp = color_frame.get_timestamp()
            depth_timestamp = depth_frame.get_timestamp()
            diff = abs(color_timestamp - depth_timestamp)
            print(f"Diff: {diff}")

        except KeyboardInterrupt:
            break
        
    cv2.destroyAllWindows()
    pipeline.stop()


if __name__ == "__main__":
    main(sys.argv[1:])

lwqqwerf avatar Jun 10 '25 15:06 lwqqwerf

请问解决了吗,我使用orbbec336L也是timestamp一直为0

cvki avatar Sep 19 '25 03:09 cvki