Free Motion Capture for Everyone πβ¨
TypeScript
fmc_demo + paths
aaroncherian75f5ee47ffed
diff --git a/freemocap/__init__.py b/freemocap/__init__.pyindex 2764cdd1..b2ca9c89 100644--- a/freemocap/__init__.py+++ b/freemocap/__init__.py@@ -4,6 +4,7 @@ __version__ = get_versions()["version"]del get_versionsfrom freemocap.fmc_runme import RunMe+from freemocap import fmc_demo, fmc_runme# from freemocap import fmc_runme, fmc_demo #JSM NOTE - there's gotta be a better way to do this lol@@ -40,6 +41,6 @@ def RunDemo():"""Will (eventually) download sample data from Figshare, and run the animation for it"""- sample_data_location = fmc_demo.DemoSetup() #run a bunch of GUIs, get the location of the directory where the data folder with the sample data is- fmc_runme.Run(sessionID = 'sesh_21-07-18_170130',stage = 6,useOpenPose = True,useDLC = True, userDataPath = sample_data_location)+ sample_data_location, sample_data_name = fmc_demo.DemoSetup() #run a bunch of GUIs, get the location of the directory where the data folder with the sample data is+ fmc_runme.RunMe(sessionID = sample_data_name,stage = 5,useOpenPose = False, useMediaPipe = True,useDLC = True, userDataPath = sample_data_location)diff --git a/freemocap/fmc_demo.py b/freemocap/fmc_demo.pyindex 39aefc8c..70fd679d 100644--- a/freemocap/fmc_demo.py+++ b/freemocap/fmc_demo.py@@ -13,47 +13,52 @@ def DemoSetup():download_data = runDataDownloadGUI() #ask for user input on downloadingzip_file_url = "https://ndownloader.figshare.com/files/28927743"+ sample_session_name = 'sesh_21-07-20_165209'+ sample_session_zip = sample_session_name + '.zip'if download_data: #if they want to download#code to download stuff from online will go here- r = requests.get(zip_file_url)- z = zipfile.ZipFile(io.BytesIO(r.content))- #z.extractall()+ destinationPath = runDemoGUI()+#error seems to expect the sample session to still be a zip file even though it is unzipped below++ if 'FreeMocap_Data' in str(destinationPath):+ print('using a freemocap data folder')+ #extractToPath = destinationPath/sample_session_zip+ extractToPath = destinationPath+ else:+ extractToFolder = Path(destinationPath)/recordingconfig.dataFolder #append the name of the data folder to the destination path+ extractToFolder.mkdir(exist_ok=True) #make the data folder if it doesn't current exist+ #extractToPath = extractToFolder/sample_session_name+ extractToPath = extractToFolder#run the GUI to get the directory locations of the zipped folder, and where to extract it to- locationPath, destinationPath = runDemoGUI()- zipPath = Path(locationPath)/'sesh_21-07-18_170130.zip' #append the name of the zipped sample file to the path to find it- extractToPath = Path(destinationPath)/recordingconfig.dataFolder #append the name of the data folder to the destination path- extractToPath.mkdir(exist_ok=True) #make the data folder if it doesn't current exist-- with zipfile.ZipFile(zipPath,'r') as zip_ref:- zip_ref.extractall(extractToPath) #extract stuff to the data folder+ #locationPath, destinationPath = runDemoGUI()+ #zipPath = Path(locationPath)/'sesh_21-07-18_170130.zip' #append the name of the zipped sample file to the path to find it+++ print('Starting demo session download')+ r = requests.get(zip_file_url)+ z = zipfile.ZipFile(io.BytesIO(r.content))+ z.extractall(extractToPath)++ print('Demo session downloaded to: ' + str(destinationPath) + '/' + str(sample_session_zip))+ #with zipfile.ZipFile(zipPath,'r') as zip_ref:+ # zip_ref.extractall(extractToPath) #extract stuff to the data folderelse:- root = tk.Tk() #brinng up a window to select the data folder directory+ root = tk.Tk() #bring up a window to select the data folder directoryroot.withdraw()destinationPath = filedialog.askdirectory( title='Select the directory where the Freemocap_data folder with the sample data is located',initialdir= Path.cwd())- return destinationPath #take the path to the directory where the data folder is located+ return extractToPath, sample_session_name #take the path to the directory where the data folder is locatedclass DemoGUI(): #GUI to pick the location and the destination directories for the sample datadef __init__(self, master):self.master = master- dataText = "Select the directory where your sample data is located"- dataLable = Label(master, text=dataText)- dataLable.pack(side="top")-- self.locationPathVar = tk.StringVar()- savedLocationLabel = Label(master,textvariable=self.locationPathVar)- savedLocationLabel.pack()-- dataButton = Button(master,text = 'Select the current sample data location',command = self.openLocationDialog)- dataButton.pack()-sampleDestinationText = "If a {} folder already exists, choose the directory where it is located. \n Otherwise, choose a directory to create a {} folder".format(recordingconfig.dataFolder,recordingconfig.dataFolder)sampleDestinationLabel = Label(master, text=sampleDestinationText)sampleDestinationLabel.pack()@@ -68,15 +73,7 @@ class DemoGUI(): #GUI to pick the location and the destination directories for tsubmitButton = Button(master,text = 'Submit',command = self.submit)submitButton.pack()- def openLocationDialog(self):-- self.locationPath = filedialog.askdirectory(- title='Select the directory where the sample data zip file is located',- initialdir= Path.cwd())- self.locationPathVar.set(self.locationPath)- f = 2-def openDestinationDialog(self):self.destinationPath = filedialog.askdirectory(@@ -124,11 +121,9 @@ def runDemoGUI():root = tk.Tk()pathchoices = DemoGUI(root)root.mainloop()-- locationPath = pathchoices.locationPathdestinationPath = pathchoices.destinationPath- return locationPath,destinationPath+ return destinationPathdef runDataDownloadGUI():root = tk.Tk()diff --git a/freemocap/fmc_mediapipe.py b/freemocap/fmc_mediapipe.pyindex c61ab3b0..ad50c21f 100644--- a/freemocap/fmc_mediapipe.py+++ b/freemocap/fmc_mediapipe.py@@ -297,15 +297,13 @@ def parseMediaPipe(session):mediaPipeData_nCams_nFrames_nImgPts_XYC[camNum, frNum, :, 1] = thisFrame_YmediaPipeData_nCams_nFrames_nImgPts_XYC[camNum, frNum, :, 2] = thisFrame_C+# convert from normalized screen coordinates to pixel coordinatesmediaPipeData_nCams_nFrames_nImgPts_XYC[:, :, :, 0] *= session.image_widthmediaPipeData_nCams_nFrames_nImgPts_XYC[:, :, :, 1] *= session.image_heightmediaPipeData_nCams_nFrames_nImgPts_XYC[:, :, 34:, 2] = 1- np.save(- session.dataArrayPath / "mediaPipe_2d.npy",- mediaPipeData_nCams_nFrames_nImgPts_XYC,- )+ np.save(session.dataArrayPath / "mediaPipe_2d.npy", mediaPipeData_nCams_nFrames_nImgPts_XYC,)return mediaPipeData_nCams_nFrames_nImgPts_XYCdiff --git a/runme_FreeMoCap.py b/runme_FreeMoCap.pyindex 5facfe25..f52265eb 100644--- a/runme_FreeMoCap.py+++ b/runme_FreeMoCap.py@@ -1,3 +1,14 @@+from freemocap import sessionimport freemocap as fmc-fmc.RunMe(useOpenPose = False, useMediaPipe=True, stage = 1)\ No newline at end of file+#fmc.RunMe(useOpenPose = False, useMediaPipe=True, stage = 5, sessionID ='sesh_2021-09-13_14_34_12', recordVid=False)++fmc.RunDemo()++#fmc.RunMe()++# word = 'data'++# mystring = 'freemocap_data'+# if word in mystring:+# print('success')\ No newline at end of file