-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflash.py
More file actions
87 lines (63 loc) · 2.5 KB
/
flash.py
File metadata and controls
87 lines (63 loc) · 2.5 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""
Copyright (C) 2025 Allied Vision Technologies. All Rights Reserved.
Subject to the BSD 3-Clause License.
"""
import sys
from vmbpy import *
from vmbpy.camera import CamerasTuple
from vmbpy.transportlayer import TransportLayersTuple
def print_preamble():
print('////////////////////////////////////////')
print('/// Smart Camera Trigger I/O Example ///')
print('////////////////////////////////////////\n')
def print_usage():
print('Usage:')
print(' python flash.py')
print(' python flash.py -h')
print()
def abort(reason: str, return_code: int = 1, usage: bool = False):
print(reason + '\n')
if usage:
print_usage()
sys.exit(return_code)
def parse_args() -> None:
args = sys.argv[1:]
argc = len(args)
for arg in args:
if arg == '-h':
print_usage()
sys.exit(0)
if argc > 0:
abort(reason="Invalid number of arguments. Abort.", return_code=2, usage=True)
def frame_handler(camera: Camera, stream: Stream, frame: Frame):
print('{} acquired {}'.format(camera, frame), flush=True)
camera.queue_frame(frame)
if __name__ == '__main__':
print_preamble()
parse_args()
with VmbSystem.get_instance() as vmb_system:
transport_layers: TransportLayersTuple = vmb_system.get_all_transport_layers()
if len(transport_layers) == 0:
abort('No transport layer found.')
transport_layer: TransportLayer = transport_layers[0]
cameras: CamerasTuple = vmb_system.get_all_cameras()
if len(cameras) == 0:
abort('No camera found.')
with cameras[0] as camera:
# Set "Flashed Strobe" here for overdrive mode
transport_layer.LightControllerMode.set("Continuous Strobe")
transport_layer.LightBrightness.set(100)
camera.LineSelector.set("Line1")
try:
camera.LineMode.set("Output")
except:
pass
camera.LineSource.set("ExposureActive")
# invert the signal because the external light output line is connected to an opto-coupler
camera.LineInverter.set(True)
camera.ExposureTime.set(10000)
print('\nSetting external light output line to high whenever exposure is active.')
print('Press <enter> to stop frame acquisition.')
camera.start_streaming(handler=frame_handler)
input()
camera.stop_streaming()