def create_detector_drawer_circles(): rows = 5 cols = 3 square_size = 0.04 #4 cm pattern_type = ASYMMETRIC_CIRCLES_GRID return (PatternDetector(rows=rows, cols=cols, pattern_type=pattern_type, square_size=square_size), PatternDrawer(rows=rows, cols=cols))
def create_detector_drawer_chessboard(): rows = 7 cols = 6 square_size = 0.108 #108 mmc pattern_type = CHESSBOARD return (PatternDetector(rows=rows, cols=cols, pattern_type=pattern_type, square_size=square_size), PatternDrawer(rows=rows, cols=cols))
image_reader = ImageReader(file_list=ecto.list_of_strings(args.images)) rows = 4 cols = 5 square_size = 0.025 #2.5 cm pattern_type = CHESSBOARD rgb2gray = cvtColor(flag=Conversion.RGB2GRAY) detector = PatternDetector(rows=rows, cols=cols, pattern_type=pattern_type, square_size=square_size) pattern_drawer = PatternDrawer(rows=rows, cols=cols) camera_intrinsics = CameraIntrinsics(camera_file=args.camera) poser = FiducialPoseFinder() pose_drawer = PoseDrawer() plasm = ecto.Plasm() plasm.connect( image_reader['image'] >> (pattern_drawer['input'], rgb2gray['image']), rgb2gray['image'] >> detector['input'], detector['ideal', 'out', 'found'] >> poser['ideal', 'points', 'found'], camera_intrinsics['K'] >> poser['K'], detector['out', 'found'] >> pattern_drawer['points', 'found'], poser['R', 'T'] >> pose_drawer['R', 'T'], poser['R'] >> MatPrinter(name='R')['mat'], poser['T'] >> MatPrinter(name='T')['mat'], pattern_drawer['out'] >> pose_drawer['image'], camera_intrinsics['K'] >> pose_drawer['K'],
rows = 5 cols = 3 square_size = 0.04 #4 cm pattern_type = ASYMMETRIC_CIRCLES_GRID n_obs = 50 calibration_file = 'camera_new.yml' video = VideoCapture(video_device=0) rgb2gray = cvtColor(flag=Conversion.RGB2GRAY) circle_detector = PatternDetector(rows=rows, cols=cols, pattern_type=pattern_type, square_size=square_size) camera_calibrator = CameraCalibrator(output_file_name=calibration_file, n_obs=n_obs) circle_drawer = PatternDrawer(rows=rows, cols=cols) plasm = ecto.Plasm() plasm.connect( video['image'] >> (circle_drawer['input'], camera_calibrator['image'], rgb2gray['image']), rgb2gray['image'] >> circle_detector['input'], circle_drawer['out'] >> imshow(name='pattern')['image'], circle_detector['ideal', 'out', 'found'] >> camera_calibrator['ideal', 'points', 'found'], circle_detector['out', 'found'] >> circle_drawer['points', 'found'], ) if __name__ == '__main__': from ecto.opts import doit doit(plasm, description='Calibrate a camera using a dot pattern.')