diff --git a/main_calcIntrinsics.py b/main_calcIntrinsics.py index 368c7aad..3312bbe7 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 4d464e54..95de3bae 100644 --- a/utilsChecker.py +++ b/utilsChecker.py @@ -193,24 +193,28 @@ 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 = makeRequestWithRetry('GET', + if cameraModel is None: + resp = makeRequestWithRetry('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'] + trial = resp.json() + camModels.append(trial['videos'][0]['parameters']['model']) + trial_name = trial['name'] + else: + camModels.append(cameraModel) if trial_name == 'null': 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):