viz_synthetic_seq.py 804 B

1234567891011121314151617181920212223242526
  1. import cv2 as cv
  2. import argparse
  3. def main():
  4. argparser = argparse.ArgumentParser(description='Vizualization of the SyntheticSequenceGenerator.')
  5. argparser.add_argument('-b', '--background', help='Background image.', required=True)
  6. argparser.add_argument('-o', '--obj', help='Object image. It must be strictly smaller than background.', required=True)
  7. args = argparser.parse_args()
  8. bg = cv.imread(args.background)
  9. obj = cv.imread(args.obj)
  10. generator = cv.bgsegm.createSyntheticSequenceGenerator(bg, obj)
  11. while True:
  12. frame, mask = generator.getNextFrame()
  13. cv.imshow('Generated frame', frame)
  14. cv.imshow('Generated mask', mask)
  15. k = cv.waitKey(int(1000.0 / 30))
  16. if k == 27:
  17. break
  18. if __name__ == '__main__':
  19. main()