automan_archiver_2.py 1.4 KB

12345678910111213141516171819202122232425
  1. def archive(cls, automan_info, archive_info):
  2. print(archive_info)
  3. annotations_dir = os.path.join(TEMP_DIR, 'Annotations')
  4. images_dir = os.path.join(TEMP_DIR, 'Images')
  5. image_annotations_dir = os.path.join(TEMP_DIR, 'Images_Annotations')
  6. # whether or not to write image in bag file to image files
  7. is_including_image = archive_info.get('include_image', False)
  8. max_frame = cls.__get_frame_range(
  9. automan_info, archive_info['project_id'], archive_info['annotation_id'])
  10. colors = cls.__get_annotation_color(automan_info, archive_info['project_id'])
  11. candidates = cls.__get_candidates(
  12. automan_info, archive_info['project_id'], archive_info['original_id'])
  13. for i in range(max_frame):
  14. annotation = cls.__get_annotation(
  15. automan_info, archive_info['project_id'], archive_info['annotation_id'], i + 1, annotations_dir)
  16. if is_including_image:
  17. for candidate in candidates:
  18. file_name = cls.__get_annotation_image(
  19. automan_info, archive_info['project_id'],
  20. archive_info['dataset_id'], candidate['id'], i + 1, candidate['ext'], images_dir)
  21. if file_name is not None:
  22. cls.__draw_annotation(file_name, annotation, colors, images_dir, image_annotations_dir)