From 6d1e97807df1d3a4dbf25d3aeaf6a2514222341d Mon Sep 17 00:00:00 2001 From: mattpetrucci <48534856+mattpetrucci@users.noreply.github.com> Date: Thu, 5 Jan 2023 11:10:25 -0800 Subject: [PATCH 1/3] add inputs for cameraModel and videoType Added inputs to computeAverageIntrinsics for camera model and video type. --- main_calcIntrinsics.py | 6 ++++-- utilsChecker.py | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/main_calcIntrinsics.py b/main_calcIntrinsics.py index eeace83d..2e58909a 100644 --- a/main_calcIntrinsics.py +++ b/main_calcIntrinsics.py @@ -26,6 +26,9 @@ saveIntrinsicsForDeployment = True deployedFolderNames = ['Deployed_720_60fps','Deployed'] # both folder names if want to keep the detailed folder + +cameraModel = "iPhoneTest" +videoType = ".mov" #can be .avi or other file formats # %% Paths to data folder for local testing. dataDir = os.path.join(getDataDirectory(),'Data') @@ -34,7 +37,6 @@ intrinsicComparisonFile = os.path.join(sessionDir,'intrinsicComparison.pkl') # %% Get checker parameters and filenames if they exist - # TODO this should come from the server API # Get checkerboard parameters from metadata. metadataPath = os.path.join(sessionDir,'sessionMetadata.yaml') @@ -61,7 +63,7 @@ # Compute average intrinsic values from multiple trials of same camera -CamParamsAverage, CamParamList, intrinsicComparisons, cameraModel = computeAverageIntrinsics(sessionDir,trials,CheckerBoardParams,nImages=50) +CamParamsAverage, CamParamList, intrinsicComparisons, cameraModel = computeAverageIntrinsics(sessionDir,trials,CheckerBoardParams,nImages=50,cameraModel=cameraModel,videoType=videoType) # Save intrinsics from first camera for deployement diff --git a/utilsChecker.py b/utilsChecker.py index 035b9873..2bac83b6 100644 --- a/utilsChecker.py +++ b/utilsChecker.py @@ -192,23 +192,27 @@ def calcIntrinsics(folderName, CheckerBoardParams=None, filenames=['*.jpg'], return CamParams # %% -def computeAverageIntrinsics(session_path,trialIDs,CheckerBoardParams,nImages=25): +def computeAverageIntrinsics(session_path,trialIDs,CheckerBoardParams,nImages=25,cameraModel= None,videoType=".mov"): CamParamList = [] camModels = [] + trial_name = '' for trial_id in trialIDs: - resp = requests.get(API_URL + "trials/{}/".format(trial_id), - headers = {"Authorization": "Token {}".format(API_TOKEN)}) - trial = resp.json() - camModels.append(trial['videos'][0]['parameters']['model']) - trial_name = trial['name'] - if trial_name == 'null': + if cameraModel is None: + resp = requests.get(API_URL + "trials/{}/".format(trial_id), + headers = {"Authorization": "Token {}".format(API_TOKEN)}) + trial = resp.json() + camModels.append(trial['videos'][0]['parameters']['model']) + trial_name = trial['name'] + else: + camModels.append(cameraModel) + if trial_name == '': trial_name = trial_id # Make directory (folder for trialname, intrinsics also saved there) video_dir = os.path.join(session_path,trial_name) os.makedirs(video_dir, exist_ok=True) - video_path = os.path.join(video_dir,trial_name + ".mov") + video_path = os.path.join(video_dir,trial_name + videoType) # Download video if not done if not os.path.exists(video_path): From c627bb20cb265549316cf2efb281b827831ae85e Mon Sep 17 00:00:00 2001 From: mattpetrucci <48534856+mattpetrucci@users.noreply.github.com> Date: Thu, 27 Aug 2026 10:45:35 -0600 Subject: [PATCH 2/3] Update line 199 to 'null' to ensure following if statement for trial_name gets triggered. --- utilsChecker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilsChecker.py b/utilsChecker.py index 95de3bae..2392f351 100644 --- a/utilsChecker.py +++ b/utilsChecker.py @@ -196,7 +196,7 @@ def calcIntrinsics(folderName, CheckerBoardParams=None, filenames=['*.jpg'], def computeAverageIntrinsics(session_path,trialIDs,CheckerBoardParams,nImages=25,cameraModel= None,videoType=".mov"): CamParamList = [] camModels = [] - trial_name = '' + trial_name = 'null' for trial_id in trialIDs: if cameraModel is None: From 83293dc77431cae2c77c832a306f2a47d6c86f2f Mon Sep 17 00:00:00 2001 From: mattpetrucci <48534856+mattpetrucci@users.noreply.github.com> Date: Thu, 27 Aug 2026 12:37:11 -0600 Subject: [PATCH 3/3] Update per PR review. --- utilsChecker.py | 1 + 1 file changed, 1 insertion(+) diff --git a/utilsChecker.py b/utilsChecker.py index 2392f351..040f7758 100644 --- a/utilsChecker.py +++ b/utilsChecker.py @@ -208,6 +208,7 @@ def computeAverageIntrinsics(session_path,trialIDs,CheckerBoardParams,nImages=25 trial_name = trial['name'] else: camModels.append(cameraModel) + trial_name = trial_id if trial_name == 'null': trial_name = trial_id