python-camera-manager-directshow 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
1
+ import os
2
+ import sys
3
+ import clr
4
+
5
+ class CameraInspectorBridge:
6
+ def __init__(self):
7
+ self._inspector = None
8
+ self._initialize_bridge()
9
+
10
+ def _initialize_bridge(self):
11
+ """Loads the DLLs once during instantiation."""
12
+ current_dir = os.path.dirname(os.path.abspath(__file__))
13
+ project_root = os.path.dirname(current_dir)
14
+ dotnet_runtime_dir = os.path.join(project_root, "runtime", "dotnet")
15
+
16
+ # Prefer runtime/dotnet layout, but keep camera/ fallback for compatibility.
17
+ candidate_paths = [dotnet_runtime_dir, current_dir]
18
+ for candidate in candidate_paths:
19
+ if os.path.isdir(candidate) and candidate not in sys.path:
20
+ sys.path.append(candidate)
21
+
22
+ try:
23
+ # Add references once
24
+ clr.AddReference("DirectShowLib") # Good practice to include the dependency
25
+ clr.AddReference("DirectShowLibWrapper")
26
+
27
+ # Import the static class from the DLL
28
+ from DirectShowLibWrapper import CameraInspector
29
+ self._inspector = CameraInspector
30
+ # print("Successfully initialized .NET Camera Bridge.")
31
+
32
+ except Exception as e:
33
+ print(f"CRITICAL: Failed to load .NET DLLs: {e}")
34
+ self._inspector = None
35
+
36
+ def get_connected_cameras(self):
37
+ if not self._inspector: return None
38
+ return self._inspector.GetConnectedCameras()
39
+
40
+ def get_camera_ranges(self, device_path):
41
+ if not self._inspector: return None
42
+ return self._inspector.GetCameraRanges(device_path)
43
+
44
+ def get_camera_formats(self, device_path):
45
+ if not self._inspector: return None
46
+ return self._inspector.GetSupportedFormats(device_path)