MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / undistort_points

Function undistort_points

deeplabcut/pose_estimation_3d/triangulation.py:504–544  ·  view source on GitHub ↗
(config, dataframe, camera_pair)

Source from the content-addressed store, hash-verified

502
503
504def undistort_points(config, dataframe, camera_pair):
505 cfg_3d = auxiliaryfunctions.read_config(config)
506 path_camera_matrix = auxiliaryfunctions_3d.Foldernames3Dproject(cfg_3d)[2]
507 """path_undistort = destfolder filename_cam1 = Path(dataframe[0]).stem filename_cam2
508 = Path(dataframe[1]).stem.
509
510 #currently no intermediate saving of this due to high speed.
511 # check if the undistorted files are already present
512 if os.path.exists(os.path.join(path_undistort,filename_cam1 + \
513 '_undistort.h5')) and os.path.exists(os.path.join(path_undistort,filename_cam2 + '_undistort.h5')):
514 print("The undistorted files are already present at %s" % os.path.join(path_undistort,filename_cam1))
515 dataFrame_cam1_undistort = pd.read_hdf(os.path.join(path_undistort,filename_cam1 + '_undistort.h5'))
516 dataFrame_cam2_undistort = pd.read_hdf(os.path.join(path_undistort,filename_cam2 + '_undistort.h5'))
517 else:
518 """
519 if len(dataframe) != 2:
520 raise ValueError(
521 "undistort_points(config, dataframe, camera_pair) "
522 f"needs filenames to two data frames, but got dataframe={dataframe}."
523 )
524 for filename in dataframe:
525 if not os.path.exists(filename):
526 raise FileNotFoundError(f"Dataframe path '{filename}' could not be found in the filesystem.")
527 if not os.path.exists(path_camera_matrix):
528 raise FileNotFoundError(f"Camera matrix file '{path_camera_matrix}' could not be found in the filesystem.")
529 # Create an empty dataFrame to store the undistorted 2d coordinates and likelihood
530 dataframe_cam1 = pd.read_hdf(dataframe[0])
531 dataframe_cam2 = pd.read_hdf(dataframe[1])
532 path_stereo_file = os.path.join(path_camera_matrix, "stereo_params.pickle")
533 stereo_file = auxiliaryfunctions.read_pickle(path_stereo_file)
534 dataFrame_cam1_undistort, dataFrame_cam2_undistort = _undistort_views(
535 [(dataframe_cam1, dataframe_cam2)],
536 stereo_file,
537 )[0]
538
539 return (
540 dataFrame_cam1_undistort,
541 dataFrame_cam2_undistort,
542 stereo_file[camera_pair],
543 path_stereo_file,
544 )

Callers 1

triangulateFunction · 0.85

Calls 2

_undistort_viewsFunction · 0.85
read_configMethod · 0.45

Tested by

no test coverage detected