diff --git a/chroma-previewer.spec b/chroma-previewer.spec new file mode 100644 index 0000000..ce0549e --- /dev/null +++ b/chroma-previewer.spec @@ -0,0 +1,52 @@ +# -*- mode: python ; coding: utf-8 -*- +import sys +from PyInstaller.utils.hooks import collect_submodules + +# Project name and entry script +app_name = "ChromaPreviewer" +entry_script = "main.py" + +# Gather hidden imports for PyQt6 and OpenCV +hidden_imports = collect_submodules("cv2") + collect_submodules("PyQt6") + +a = Analysis( + [entry_script], + pathex=["."], # Current directory + binaries=[], + datas=[], + hiddenimports=hidden_imports, + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=None, + noarchive=False, +) + +pyz = PYZ(a.pure, a.zipped_data, cipher=None) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name=app_name, + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=False +) + +app = BUNDLE( + exe, + name=app_name + ".app", + bundle_identifier="com.1060studios.chromapreviewer", + info_plist={ + "NSCameraUsageDescription": "This app requires access to the camera for live chroma keying." + }, + entitlements="entitlements.plist" +) \ No newline at end of file diff --git a/entitlements.plist b/entitlements.plist new file mode 100644 index 0000000..6472097 --- /dev/null +++ b/entitlements.plist @@ -0,0 +1,8 @@ + + + + + com.apple.security.device.camera + + + \ No newline at end of file diff --git a/main.py b/main.py index 9a911fc..cb3ade2 100644 --- a/main.py +++ b/main.py @@ -93,8 +93,11 @@ class ChromaPreviewer(QWidget): ], dtype=np.uint8) def update_frame(self): - ret, frame = self.cap.read() - if not ret: + try: + ret, frame = self.cap.read() + if not ret: + return + except AttributeError: return frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)