Free Motion Capture for Everyone πβ¨
TypeScript
altered calibration method to produce plottable charuco tracks
jon matthis82cae587889f
diff --git a/.gitignore b/.gitignoreindex 9aa53935..4d11118d 100644--- a/.gitignore+++ b/.gitignore@@ -6,6 +6,7 @@ Data/*.py[cod]*$py.classFreeMoCap_Data/+freemocap\user_preferences.yaml# C extensions*.so@@ -134,6 +135,3 @@ dmypy.json.vscode/launch.json-# other-src/-FreeMoCap_Data/sesh_21-07-13_110238/RawVideos/sesh_21-07-13_110238_timestamps.csvdiff --git a/freemocap/calibrate.py b/freemocap/calibrate.pyindex 2782f0c3..ad56ec67 100644--- a/freemocap/calibrate.py+++ b/freemocap/calibrate.py@@ -54,47 +54,9 @@ def CalibrateCaptureVolume(session,board, calVideoFrameLength = 120):"""Takes as input a list of list of video filenames, one list of each camera.Also takes a board which specifies what should be detected in the videos"""- # all_rows = cgroup.get_rows_videos(vidnames, board, verbose=True)+ error,charuco_data, charuco_frames = cgroup.calibrate_videos(vidnames, board)+ cgroup.dump(session.cameraCalFilePath) #JSM NOTE - let's just use .yaml's unless there is some reason to use .toml- # cgroup.set_camera_sizes_videos(vidnames)-- if session.debug:- fig = plt.figure(47290)- for camNum in range(len(all_rows)):- ax = fig.add_subplot(2, 2, camNum + 1)- # cap = cv2.VideoCapture(vidnames[camNum][0]) #this is crazy inefficient - we should save out the first image somewhere and save it in an accessible location- # ret, frame = cap.read()- # plt.imshow(frame)- # cap.release()- for frNum in range(len(all_rows[camNum])):- corners = np.squeeze(all_rows[camNum][frNum]["filled"])- plt.plot(corners[:, 0], corners[:, 1], ".-")- # xmin = np.nanmin(corners[:,0])*.9- # xmax = np.nanmax(corners[:,0])*1.1- # ymin = np.nanmin(corners[:,1])*.9- # ymax = np.nanmax(corners[:,1])*1.1- # ax.set_xlim(xmin, xmax)- # ax.set_xlim(ymin, ymax)- plt.show()-- #%% This next bit is a copy-paste of the inner bits of `cgroup.calibrate_videos` - Part 2 of 2- # error, merged = cgroup.calibrate_rows(all_rows, board,- # init_intrinsics=True,- # init_extrinsics=True)- #%% End of the copy-paste of the inner bits of `cgroup.calibrate_videos` - END--- #JSM NOTE - need add method to extract Charuco board points from the calibrate_videos pipeline-- ## if you need to save and load- ## example saving and loading for later- if not session.cameraCalFilePath.is_file():- error,merged = cgroup.calibrate_videos(vidnames, board)- cgroup.dump(session.cameraCalFilePath) #JSM NOTE - let's just use .yaml's unless there is some reason to use .toml- mergename = session.dataArrayPath/'charuco_2d_points.npy'- np.save(mergename,merged)- else:- cgroup = CameraGroup.load(session.cameraCalFilePath) #load previous calibration configsession.cgroup = cgroup@@ -103,19 +65,19 @@ def CalibrateCaptureVolume(session,board, calVideoFrameLength = 120):n_trackedPoints = 24framelist = range(startframe, startframe + n_frames)- charucoarray = np.empty([session.numCams, n_frames, n_trackedPoints, 1, 2])- charucoarray[:] = np.nan-- data = np.load(session.dataArrayPath/'charuco_2d_points.npy',allow_pickle = True)+ charuco_nCams_nFrames_nImgPts_XY = np.empty([session.numCams, n_frames, n_trackedPoints, 2])+ charuco_nCams_nFrames_nImgPts_XY[:] = np.nanfor cam in range(session.numCams):- for count, frame in enumerate(framelist):+ for charCount, thisCharFrame in enumerate(charuco_frames):try:- charucoarray[cam][count] = data[frame][cam]["filled"]+ charuco_nCams_nFrames_nImgPts_XY[cam, thisCharFrame, :,:] = np.squeeze(charuco_data[charCount][cam]["filled"])except:# print("failed frame:", frame)continue- charuco_nCams_nFrames_nImgPts_XY = np.squeeze(np.array(charucoarray))++ charuco2d_filename = session.dataArrayPath/'charuco_2d_points.npy'+ np.save(charuco2d_filename,charuco_nCams_nFrames_nImgPts_XY)session.charuco_nCams_nFrames_nImgPts_XY = charuco_nCams_nFrames_nImgPts_XYdiff --git a/freemocap/fmc_anipose.py b/freemocap/fmc_anipose.pyindex dcd1abc7..e42a14f0 100644--- a/freemocap/fmc_anipose.py+++ b/freemocap/fmc_anipose.py@@ -1679,6 +1679,8 @@ class CameraGroup:for i, (row, cam) in enumerate(zip(all_rows, self.cameras)):all_rows[i] = board.estimate_pose_rows(cam, row)+ charuco_frames = [f['framenum'][1] for f in all_rows[0]]+merged = merge_rows(all_rows)imgp, extra = extract_points(merged, board, min_cameras=2)@@ -1692,7 +1694,7 @@ class CameraGroup:error = self.bundle_adjust_iter(imgp, extra, verbose=verbose, **kwargs)- return error, merged+ return error, merged, charuco_framesdef get_rows_videos(self, videos, board, verbose=True):all_rows = []@@ -1734,7 +1736,7 @@ class CameraGroup:if init_extrinsics:self.set_camera_sizes_videos(videos)- error, merged = self.calibrate_rows(+ error, merged, charuco_frames = self.calibrate_rows(all_rows,board,init_intrinsics=init_intrinsics,@@ -1742,7 +1744,7 @@ class CameraGroup:verbose=verbose,**kwargs)- return error, merged+ return error, merged, charuco_framesdef get_dicts(self):out = []diff --git a/freemocap/fmc_runme.py b/freemocap/fmc_runme.pyindex c5db2797..444a61d2 100644--- a/freemocap/fmc_runme.py+++ b/freemocap/fmc_runme.py@@ -101,20 +101,20 @@ def RunMe(sessionID=None,# 2) Check that the data folder exists# 3) If no sessionID was user-input, search the chosen directory for the last session createdif sesh.setDataPath == True:- basePath = runmeGUI.RunChooseDataPathGUI(session)- sesh.basePath = Path(basePath)+ sesh.basePath = runmeGUI.RunChooseDataPathGUI(session)+ sesh.basePath = Path(sesh.basePath)#sesh.dataFolderPath = Path(basePath)/sesh.dataFolderNameelif sesh.userDataPath is not None:- basePath = sesh.userDataPath+ sesh.basePath = sesh.userDataPathelse:try:current_path_to_data = preferences['saved']['path_to_save']- basePath = current_path_to_data+ sesh.basePath = current_path_to_dataexcept KeyError:print('Saved Data path not found, please choose a new one')- basePath = runmeGUI.RunChooseDataPathGUI(session)- sesh.preferences['saved']['path_to_save'] = str(basePath)+ sesh.basePath = runmeGUI.RunChooseDataPathGUI(session)+ sesh.preferences['saved']['path_to_save'] = str(sesh.basePath)sesh.save_user_preferences(sesh.preferences)diff --git a/freemocap/play_skeleton_animation.py b/freemocap/play_skeleton_animation.pyindex 6c3713f5..91853084 100644--- a/freemocap/play_skeleton_animation.py+++ b/freemocap/play_skeleton_animation.py@@ -697,7 +697,7 @@ def PlaySkeletonAnimation(thisVidAxis.text(-150,510, 'github.com/jonmatthis/freemocap || jonmatthis.com/freemocap',color=humon_green, fontsize=6)logoAx = fig.add_subplot(position=[.85, .85, .15, .15])- logoIm = cv2.imread(r'freemocap\logo\fmc-logo-black-border-white-bkgd.png') #JSM NOTE - THis doesn't work, but SOMETIMES IT DOES?!+ logoIm = cv2.imread(r'logo\fmc-logo-black-border-white-bkgd.png') #JSM NOTE - THis doesn't work, but SOMETIMES IT DOES?!if logoIm is not None: logoAx.imshow(cv2.cvtColor(logoIm, cv2.COLOR_BGR2RGB))logoAx.axis('off')@@ -718,8 +718,12 @@ def PlaySkeletonAnimation(# vidSavePath = '{}_outVid.mp4'.format(str(session.sessionPath / session.sessionID))# Writer.saving(fig = fig, outfile=vidSavePath, dpi=150)- plt.pause(0.1)- plt.draw()++ try:+ plt.pause(0.1)+ plt.draw()+ except:+ passdiff --git a/freemocap/user_preferences.yaml b/freemocap/user_preferences.yamlindex 398ba434..2d944229 100644--- a/freemocap/user_preferences.yaml+++ b/freemocap/user_preferences.yaml@@ -1,5 +1,5 @@default:- path_to_save: C:\Users\aaron\Documents\GitHub\freemocap+ path_to_save: C:\Users\jonma\Dropbox\GitKrakenRepos\freemocapdlc_config_paths: []rotations: {}parameters:@@ -9,13 +9,4 @@ default:framerate: 25codec: DIVXsaved:- rotations:- 1: 0- 2: 90- parameters:- exposure: -6- resWidth: 640- resHeight: 480- framerate: 25- codec: DIVX- path_to_save: C:\Users\aaron\Documents\GitHub\freemocap+ path_to_save: C:/Users/jonma/Dropbox/FreeMoCapProjectdiff --git a/freemocap_runme_script.py b/freemocap_runme_script.pyindex 8b5fb9af..5d3a0195 100644--- a/freemocap_runme_script.py+++ b/freemocap_runme_script.py@@ -3,11 +3,10 @@ from pathlib import Pathimport socket--fmc.RunMe( stage=5,+fmc.RunMe( stage=5,useOpenPose=True,openPoseDummyRun=True,- useMediaPipe=True,+ useMediaPipe=False,useDLC=False,recordVid = True,reconstructionConfidenceThreshold = 0.2,diff --git a/freemocap/logo/fmc-logo-black-border-white-bkgd.png b/logo/fmc-logo-black-border-white-bkgd.pngsimilarity index 100%rename from freemocap/logo/fmc-logo-black-border-white-bkgd.pngrename to logo/fmc-logo-black-border-white-bkgd.pngdiff --git a/freemocap/logo/freemocap-logo-black-border.svg b/logo/freemocap-logo-black-border.svgsimilarity index 100%rename from freemocap/logo/freemocap-logo-black-border.svgrename to logo/freemocap-logo-black-border.svgdiff --git a/freemocap/logo/freemocap-logo-white-border.png b/logo/freemocap-logo-white-border.pngsimilarity index 100%rename from freemocap/logo/freemocap-logo-white-border.pngrename to logo/freemocap-logo-white-border.png