Skip to content

Free Motion Capture for Everyone πŸ’€βœ¨

TypeScript

solved the mystery of the 'cam[x]' file

Aaron Cherian51905ff7437c
diff --git a/freemocap/runcams.py b/freemocap/runcams.py
index 343f6f0d..b3c21131 100644
--- a/freemocap/runcams.py
+++ b/freemocap/runcams.py
@@ -30,6 +30,7 @@ def RecordCams(session,camInputs,parameterDictionary,rotationInputs):
threads = []
for n in numCamRange: # starts recording video, opens threads for each camera
camRecordings = startcamrecording.CamRecordingThread(
+ session,
camIDs[n],
camInputs[n],
vidNames[n],
@@ -53,7 +54,7 @@ def RecordCams(session,camInputs,parameterDictionary,rotationInputs):
) in (
numCamRange
): # open the saved pickle file for each camera, and add the timestamps to the dataList list
- with open(camIDs[e], "rb") as f:
+ with open(session.sessionPath/camIDs[e], "rb") as f:
camTimeList = pickle.load(f)
timeStampList.append(camTimeList)
diff --git a/freemocap/webcam/startcamrecording.py b/freemocap/webcam/startcamrecording.py
index bfd194d3..3e6edb48 100644
--- a/freemocap/webcam/startcamrecording.py
+++ b/freemocap/webcam/startcamrecording.py
@@ -6,7 +6,7 @@ import pickle
class CamRecordingThread(threading.Thread):
def __init__(
- self, camID, camInput, videoName, rawVidPath, beginTime, parameterDictionary
+ self, session, camID, camInput, videoName, rawVidPath, beginTime, parameterDictionary
):
threading.Thread.__init__(self)
self.camID = camID
@@ -15,10 +15,12 @@ class CamRecordingThread(threading.Thread):
self.rawVidPath = rawVidPath
self.beginTime = beginTime
self.parameterDictionary = parameterDictionary
+ self.session = session
def run(self):
print("Starting " + self.camID)
self.timeStamps = CamRecording(
+ self.session,
self.camID,
self.camInput,
self.videoName,
@@ -33,7 +35,7 @@ class CamRecordingThread(threading.Thread):
# the recording function that each threaded camera object runs
def CamRecording(
- camID, camInput, videoName, rawVidPath, beginTime, parameterDictionary
+ session, camID, camInput, videoName, rawVidPath, beginTime, parameterDictionary
):
# the flag is triggered when the user shuts down one webcam to shut down the rest.
# normally I'd try to avoid global variables, but in this case it's
@@ -76,7 +78,7 @@ def CamRecording(
success
): # while the camera is opened, record the data until the escape button is hit
if flag: # when the flag is triggered, stop recording and dump the data
- with open(camID, "wb") as f:
+ with open(session.sessionPath/camID, "wb") as f:
pickle.dump(timeStamps, f)
break
success, frame = cam.read()
@@ -90,7 +92,7 @@ def CamRecording(
key = cv2.waitKey(20)
if key == 27: # exit on ESC
flag = True # set flag to true to shut down all other webcams
- with open(camID, "wb") as f:
+ with open(session.sessionPath/camID, "wb") as f:
pickle.dump(timeStamps, f) # dump the data
break
cv2.destroyWindow(camID)