Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions main_calcIntrinsics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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
Expand Down
16 changes: 10 additions & 6 deletions utilsChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down