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] 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):