-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmultiprocess_camera_example.py
More file actions
69 lines (51 loc) · 2.4 KB
/
multiprocess_camera_example.py
File metadata and controls
69 lines (51 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env -S uv run --script
import time
import logging
import sys
import os
import numpy as np
sys.path.append(os.path.dirname(os.path.realpath(__file__))+'/..')
from emioapi import MultiprocessEmioCamera
from emioapi._logging_config import logger
def main():
emio = MultiprocessEmioCamera()
emio.show_frames = True # Show camera frames. Default is False.
emio.track_markers = True # Track objects. Default is True.
emio.compute_point_cloud = True # Compute point cloud. Default is False.
# Camera tracking parameters. If None, a config file is read. If there is no config file, default values are used {"hue_h": 90, "hue_l": 36, "sat_h": 255, "sat_l": 138, "value_h": 255, "value_l": 35, "erosion_size": 0, "area": 100}
emio.parameters = None
try:
logger.info("List of available cameras: "+str(MultiprocessEmioCamera.listCameras()))
if emio.open(): # Open the camera with the current parameters. This will start the camera process.
logger.info(f"Camera {emio.camera_serial} opened successfully.")
i = 0
while i<20:
time.sleep(1)
print("--" * 20)
# all properties of the emiocamera
logger.info(f"Camera parameters: {emio.parameters}")
logger.info(f"Camera show: {emio.show_frames}")
logger.info(f"Camera tracking: {emio.track_markers}")
logger.info(f"Camera compute point cloud: {emio.compute_point_cloud}")
logger.info(f"Camera is running: {emio.is_running}")
logger.info(f"Count tracker positions: {len(emio.trackers_pos)}")
logger.info(f"Point cloud shape: {emio.point_cloud.shape}")
logger.info(f"HSV Frame shape: {emio.hsv_frame.shape}")
logger.info(f"Mask Frame shape: {emio.mask_frame.shape}")
i += 1
emio.close()
except KeyboardInterrupt:
logger.info("Keyboard interrupt received. Closing camera...")
emio.close()
return
except Exception as e:
logger.exception(f"Failed running camera: {e}")
emio.close()
return
if __name__ == "__main__":
try:
logger.info("Starting EMIO API test...")
main()
logger.info("EMIO API test completed successfully.")
except Exception as e:
logger.exception(f"An error occurred: {e}")