Pointcept / SegmentAnything3D

[ICCV'23 Workshop] SAM3D: Segment Anything in 3D Scenes
https://arxiv.org/abs/2306.03908
MIT License
938 stars 67 forks source link

can't find intrinsic_depth.txt #37

Open wangxingxing opened 1 year ago

wangxingxing commented 1 year ago

when run sam3d will report intrinsics/intrinsic_depth.txt not found i check code def export_intrinsics(self, output_path): in SegmentAnything3D/scannet-preprocess/prepare_2d_data/SensorData.py will save intrinsics/intrinsic_depth.txt. but not find prepare_2d_data call this function

RyanG41 commented 1 year ago

Yes, you need to call the function manully by yourself. Here's the code after changes by me, hope it can help you. It is in _prepare_2ddata.py, starting from line 75:

for i in range(0,len(scenes)):
        sens_file = os.path.join(opt.scannet_path, scenes[i], scenes[i] + '.sens')
        label_path = os.path.join(opt.scannet_path, scenes[i], opt.label_type)
        if opt.export_label_images and not os.path.isdir(label_path):
            print_error('Error: using export_label_images option but label path %s does not exist' % label_path)
        output_color_path = os.path.join(opt.output_path, scenes[i], 'color')
        if not os.path.isdir(output_color_path):
            os.makedirs(output_color_path)
        output_depth_path = os.path.join(opt.output_path, scenes[i], 'depth')
        if not os.path.isdir(output_depth_path):
            os.makedirs(output_depth_path)
        output_pose_path = os.path.join(opt.output_path, scenes[i], 'pose')
        if not os.path.isdir(output_pose_path):
            os.makedirs(output_pose_path)
        output_intrinsics_path = os.path.join(opt.output_path, scenes[i], 'intrinsics')
        if not os.path.isdir(output_intrinsics_path):
            os.makedirs(output_intrinsics_path)
        output_label_path = os.path.join(opt.output_path, scenes[i], 'label')
        if opt.export_label_images and not os.path.isdir(output_label_path):
            os.makedirs(output_label_path)

        # read and export
        sys.stdout.write('\r[ %d | %d ] %s\tloading...' % ((i + 1), len(scenes), scenes[i]))
        sys.stdout.flush()
        sd = SensorData(sens_file)
        sys.stdout.write('\r[ %d | %d ] %s\texporting...' % ((i + 1), len(scenes), scenes[i]))
        sys.stdout.flush()
        sd.export_color_images(output_color_path, image_size=[opt.output_image_height, opt.output_image_width],
                               frame_skip=opt.frame_skip)
        sd.export_depth_images(output_depth_path, image_size=[opt.output_image_height, opt.output_image_width],
                               frame_skip=opt.frame_skip)
        sd.export_poses(output_pose_path, frame_skip=opt.frame_skip)
        sd.export_intrinsics(output_intrinsics_path)
kenomo commented 1 year ago

Fixed in #38