Free Motion Capture for Everyone πβ¨
TypeScript
setting cv2.VideoCapture to use 'cv2.CAP_DSHOW' for windows and 'cv2.CAP_ANY' for others
jon matthise5f265b75754
diff --git a/freemocap/webcam/camsetup.py b/freemocap/webcam/camsetup.pyindex c24c3de5..c4c175af 100644--- a/freemocap/webcam/camsetup.py+++ b/freemocap/webcam/camsetup.py@@ -2,6 +2,7 @@ import threadingimport cv2import imutilsimport os+import platformimport mediapipe as mp@@ -31,7 +32,7 @@ class VideoSetup(threading.Thread):cv2.namedWindow(camName)- if os.name == 'nt': #use CAP_DSHOW for windows, CAP_ANY otherwise (*might* make things ubuntu/mac compatible, but not sure. See https://github.com/jonmatthis/freemocap/issues/52)+ if platform.system() == 'Windows':cap = cv2.VideoCapture(self.camID, cv2.CAP_DSHOW)else:cap = cv2.VideoCapture(self.camID, cv2.CAP_ANY)@@ -94,7 +95,7 @@ class MediaPipeVideoSetup(threading.Thread):cv2.namedWindow(camName)- if os.name == 'nt': #use CAP_DSHOW for windows, CAP_ANY otherwise (*might* make things ubuntu/mac compatible, but not sure. See https://github.com/jonmatthis/freemocap/issues/52)+ if platform.system() == 'Windows':cap = cv2.VideoCapture(self.camID, cv2.CAP_DSHOW)else:cap = cv2.VideoCapture(self.camID, cv2.CAP_ANY)diff --git a/freemocap/webcam/checkcams.py b/freemocap/webcam/checkcams.pyindex 1a31dd1d..7a29d8f0 100644--- a/freemocap/webcam/checkcams.py+++ b/freemocap/webcam/checkcams.py@@ -1,12 +1,13 @@from tqdm import tqdmimport cv2import os+import platformdef TestDevice(source):"""Checks to see if there is a camera available at the input"""- if os.name == 'nt': #use CAP_DSHOW for windows, CAP_ANY otherwise (*might* make things ubuntu/mac compatible, but not sure. See https://github.com/jonmatthis/freemocap/issues/52)+ if platform.system() == 'Windows':cap = cv2.VideoCapture(source, cv2.CAP_DSHOW)else:cap = cv2.VideoCapture(source, cv2.CAP_ANY)diff --git a/freemocap/webcam/startcamrecording.py b/freemocap/webcam/startcamrecording.pyindex 3a791cc2..6826df0f 100644--- a/freemocap/webcam/startcamrecording.py+++ b/freemocap/webcam/startcamrecording.py@@ -3,6 +3,7 @@ import cv2import timeimport pickleimport os+import platformclass CamRecordingThread(threading.Thread):def __init__(@@ -51,7 +52,7 @@ def CamRecording(cv2.namedWindow(camID) # name the preview window for the camera its showing- if os.name == 'nt': #use CAP_DSHOW for windows, CAP_ANY otherwise (*might* make things ubuntu/mac compatible, but not sure. See https://github.com/jonmatthis/freemocap/issues/52)+ if platform.system() == 'Windows':cam = cv2.VideoCapture(camInput, cv2.CAP_DSHOW)else:cam = cv2.VideoCapture(camInput, cv2.CAP_ANY)