Free Motion Capture for Everyone πβ¨
TypeScript
tweaks and bugfixes
jon matthisd7490f09dab2
diff --git a/freemocap/dev_scratchpad/dev_alpha/FMC_Camera.py b/freemocap/dev_scratchpad/dev_alpha/FMC_Camera.pyindex 8cc6d750..b1cee361 100644--- a/freemocap/dev_scratchpad/dev_alpha/FMC_Camera.py+++ b/freemocap/dev_scratchpad/dev_alpha/FMC_Camera.py@@ -25,7 +25,7 @@ from rich.console import Consolecap_default_parameters_dict = {- 'exposure': -8,+ 'exposure': -6,'cap_resolution_width': 640,'cap_resolution_height': 480,}diff --git a/freemocap/dev_scratchpad/dev_alpha/FMC_MultiCamera.py b/freemocap/dev_scratchpad/dev_alpha/FMC_MultiCamera.pyindex d20331e6..bae15f28 100644--- a/freemocap/dev_scratchpad/dev_alpha/FMC_MultiCamera.py+++ b/freemocap/dev_scratchpad/dev_alpha/FMC_MultiCamera.py@@ -97,10 +97,9 @@ class FMC_MultiCamera:self._num_cams = num_camsself._cams_to_use_list = cams_to_use_list- if rotation_codes_list:- self._rotation_codes_list = rotation_codes_list- else:- self._rotation_codes_list = [None] * self.num_cams++ self._rotation_codes_list = rotation_codes_list+self._show_multi_cam_stream_bool = show_multi_cam_stream_bool@@ -201,7 +200,8 @@ class FMC_MultiCamera:for camNum in range(num_cams_to_check):#track(range(num_cams_to_check), description='[green]Finding available cameras...' ):print('ATTEMPTING TO OPEN CAMERA AT PORT# {}'.format(camNum))cap = cv2.VideoCapture(camNum, capBackend)- if cap.isOpened():+ success, image = cap.read()+ if success: #this is apparently a more power check than `cap.isOpened()` which sometimes returns false positives for unknown reason. Will lose the first frame if this method is ever applied to reading in videos instead of streaming from camerasrich_console.print('SUCCESS - CAMERA FOUND at # {}'.format(camNum), style="bold cyan")self._cams_to_use_list.append(camNum)cap.release()@@ -242,9 +242,10 @@ class FMC_MultiCamera:in_frame_q_list = [self.cam_frame_queue]*self.num_camsin_barrier_list = [self.barrier]*self.num_camsin_exit_event_list = [self.exit_event]*self.num_cams- # nsole_list = [self.rich_console]*self.num_cams--++ if self._rotation_codes_list is None:+ self._rotation_codes_list = [None]*self.num_cams+num_jobs = self.num_camswith pathos_mp.ProcessingPool(num_jobs) as self.cam_process_pool:self.cam_process_pool.amap(@@ -365,17 +366,19 @@ class FMC_MultiCamera:key = cv2.waitKey(1)if key == 27: # exit on ESC- self.exit_event.set()+ breakif cv2.getWindowProperty(self._rec_name, cv2.WND_PROP_VISIBLE) < 1: #break loop if window closed- self.exit_event.set()+ breakcv2.destroyAllWindows()+if self._save_multi_cam_to_mp4:self._output_multi_cam_video_object.release()- if self._save_each_cam_to_mp4:- for this_cam_num in range(self.num_cams):- self._each_cam_video_writer_object_list[this_cam_num].release()++ if self._save_each_cam_to_mp4:+ for this_cam_num in range(self.num_cams):+ self._each_cam_video_writer_object_list[this_cam_num].release()rich_console.rule('Shutting down MultiCamera Viewer')self.exit_event.set() #send the 'Exit' signal to everyone.@@ -422,7 +425,7 @@ class FMC_MultiCamera:self._each_cam_video_writer_object_list=[None]*self.num_camsself._each_cam_video_filename_list=[None]*self.num_cams- self.syncedVidsPath = self._save_path / self._rec_name / 'SyncedVids'+ self.syncedVidsPath = self._save_path / self._rec_name / 'SyncedVideos'self.syncedVidsPath.mkdir(parents=True)for this_cam_num in range(self.num_cams):@@ -527,12 +530,15 @@ if __name__ == '__main__':import socketthis_computer_name = socket.gethostname()+ freemocap_data_path=None+ in_rotation_codes_list=None+if this_computer_name=='jon-hallway-XPS-8930':freemocap_data_path = Path('/home/jon/Dropbox/FreeMoCapProject/FreeMocap_Data')in_rotation_codes_list = ['cv2.ROTATE_90_COUNTERCLOCKWISE', 'cv2.ROTATE_90_COUNTERCLOCKWISE', 'cv2.ROTATE_90_CLOCKWISE', 'cv2.ROTATE_90_CLOCKWISE', 'cv2.ROTATE_90_CLOCKWISE', ]- else:- freemocap_data_path=None- in_rotation_codes_list=None+ elif this_computer_name == 'DESKTOP-DCG6K4F':+ freemocap_data_path = Path(r'C:\Users\jonma\Dropbox\FreeMoCapProject\FreeMocap_Data')+try:multi_cam = FMC_MultiCamera(save_path=str(freemocap_data_path), rotation_codes_list=in_rotation_codes_list)diff --git a/freemocap/dev_scratchpad/dev_alpha/__init__.py b/freemocap/dev_scratchpad/dev_alpha/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/freemocap/dev_scratchpad/dev_alpha/freemocap_alpha_runme_script.py b/freemocap/dev_scratchpad/dev_alpha/freemocap_alpha_runme_script.pynew file mode 100644index 00000000..d237fe5a--- /dev/null+++ b/freemocap/dev_scratchpad/dev_alpha/freemocap_alpha_runme_script.py@@ -0,0 +1,35 @@+from pathlib import Path++from pathos.helpers import mp as pathos_mp_helper+from rich.console import Console++from FMC_MultiCamera import FMC_MultiCamera+import freemocap as fmc++++if __name__ == '__main__':+ pathos_mp_helper.freeze_support()+ console = Console() #create rich console to catch and print exceptions++ import socket+ this_computer_name = socket.gethostname()++ freemocap_data_path=None+ in_rotation_codes_list=None++ if this_computer_name=='jon-hallway-XPS-8930':+ freemocap_data_path = Path('/home/jon/Dropbox/FreeMoCapProject/FreeMocap_Data')+ in_rotation_codes_list = ['cv2.ROTATE_90_COUNTERCLOCKWISE', 'cv2.ROTATE_90_COUNTERCLOCKWISE', 'cv2.ROTATE_90_CLOCKWISE', 'cv2.ROTATE_90_CLOCKWISE', 'cv2.ROTATE_90_CLOCKWISE', ]+ elif this_computer_name == 'DESKTOP-DCG6K4F':+ freemocap_data_path = Path(r'C:\Users\jonma\Dropbox\FreeMoCapProject\FreeMocap_Data')+++ try:+ multi_cam = FMC_MultiCamera(save_path=str(freemocap_data_path), rotation_codes_list=in_rotation_codes_list)+ multi_cam.start(standalone_mode=True)+ except Exception:+ console.print_exception()++ fmc.RunMe(multi_cam._rec_name, stage=3)+\ No newline at end of filediff --git a/freemocap/fmc_runme.py b/freemocap/fmc_runme.pyindex b8014dff..800ea4a4 100644--- a/freemocap/fmc_runme.py+++ b/freemocap/fmc_runme.py@@ -212,7 +212,7 @@ def RunMe(sessionID=None,thisStage=4console.rule(style="color({})".format(thisStage))console.rule('Starting 2D Point Trackers'.upper(),style="color({})".format(thisStage))- stage4_msg ='This step implements various computer vision that track the skeleton (and other objects) in the 2d videos, to produce the data that will be combined with the `camera projection matrices` from the calibration stage to produce the estimates of 3d movement. \n \n Each algorithm is different, but most involve using [bold magenta] convolutional neural networks [/bold magenta] trained from labeled videos to produce a 2d probability map of the likelihood that the tracked bodypart/object/feature (e.g. \'LeftElbow\') is in a given location. \n \n The peak of that distrubtion on each frame is recorded as the pixel-location of that item on that frame (e.g. \'LeftElbow(pixel-x, pixel-y, confidence\') where the a confidence value proportional to the underlying probability distribution (i.e. tall peaks in the probablitiy distribution -> high confidence that the LeftElbow actually is at this pixel-x, pixel-y location) \n \nThis part is crazy future tech sci fi stuff. Seriously unbelievable this kind of thing is possible β¨'+ stage4_msg ='This step implements various computer vision that track the skeleton (and other objects) in the 2d videos, to produce the data that will be combined with the `camera projection matrices` from the calibration stage to produce the estimates of 3d movement. \n \n Each algorithm is different, but most involve using [bold magenta] convolutional neural networks [/bold magenta] trained from labeled videos to produce a 2d probability map of the likelihood that the tracked bodypart/object/feature (e.g. \'LeftElbow\') is in a given location. \n \n The peak of that distrubtion on each frame is recorded as the pixel-location of that item on that frame (e.g. \'LeftElbow(pixel-x, pixel-y, confidence\') where the a confidence value proportional to the underlying probability distribution (i.e. tall peaks in the probablitiy distribution indicate high confidence that the LeftElbow actually is at this pixel-x, pixel-y location) \n \nThis part is crazy future tech sci fi stuff. Seriously unbelievable this kind of thing is possible β¨'console.print(Padding(stage4_msg, (1,4)), overflow="fold", justify='center',style="color({})".format(thisStage))console.rule(style="color({})".format(thisStage))time.sleep(pauseBetweenStages)