aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authormorefigs <morefigs@gmail.com>2019-01-30 13:59:01 +1100
committermorefigs <morefigs@gmail.com>2019-01-30 13:59:01 +1100
commit01587d8ba4d5a1f8371f44e719eda6547d3ed459 (patch)
tree76fc58dedcb8b4aec9dd3c260ddd7badbd3e7fd7 /examples
parent837d3af93e55b3a2714832092e1581df51cef1ec (diff)
downloadpymba-01587d8ba4d5a1f8371f44e719eda6547d3ed459.tar.gz
pymba-01587d8ba4d5a1f8371f44e719eda6547d3ed459.zip
clean up examples into separate dirs
Diffstat (limited to 'examples')
-rw-r--r--examples/camera/get_camera_object.py (renamed from examples/get_camera.py)0
-rw-r--r--examples/camera/list_camera_ids.py (renamed from examples/get_camera_ids.py)0
-rw-r--r--examples/camera/list_feature_infos.py (renamed from examples/get_camera_feature_infos.py)0
-rw-r--r--examples/camera/list_feature_names.py (renamed from examples/get_camera_feature_names.py)0
-rw-r--r--examples/camera/list_feature_values_and_ranges.py (renamed from examples/get_camera_feature_values.py)11
-rw-r--r--examples/camera/opencv_capture_image.py34
-rw-r--r--examples/camera/opencv_capture_image_with_callback.py44
-rw-r--r--examples/camera/write_feature_value.py (renamed from examples/set_camera_feature_value.py)10
-rw-r--r--examples/interface/get_interface_object.py (renamed from examples/get_interface.py)0
-rw-r--r--examples/interface/list_feature_infos.py (renamed from examples/get_interface_feature_infos.py)0
-rw-r--r--examples/interface/list_feature_names.py (renamed from examples/get_interface_feature_names.py)0
-rw-r--r--examples/interface/list_feature_values_and_ranges.py (renamed from examples/get_interface_feature_values.py)12
-rw-r--r--examples/interface/list_interface_ids.py (renamed from examples/get_interface_ids.py)0
-rw-r--r--examples/interface/write_feature_value.py (renamed from examples/set_interface_feature_value.py)9
-rw-r--r--examples/show_version.py (renamed from examples/get_version.py)0
-rw-r--r--examples/system/get_system_object.py (renamed from examples/get_system.py)0
-rw-r--r--examples/system/list_feature_values_and_ranges.py (renamed from examples/get_system_feature_values.py)12
17 files changed, 118 insertions, 14 deletions
diff --git a/examples/get_camera.py b/examples/camera/get_camera_object.py
index 7a830f7..7a830f7 100644
--- a/examples/get_camera.py
+++ b/examples/camera/get_camera_object.py
diff --git a/examples/get_camera_ids.py b/examples/camera/list_camera_ids.py
index 670d71f..670d71f 100644
--- a/examples/get_camera_ids.py
+++ b/examples/camera/list_camera_ids.py
diff --git a/examples/get_camera_feature_infos.py b/examples/camera/list_feature_infos.py
index 03ad935..03ad935 100644
--- a/examples/get_camera_feature_infos.py
+++ b/examples/camera/list_feature_infos.py
diff --git a/examples/get_camera_feature_names.py b/examples/camera/list_feature_names.py
index d3415dc..d3415dc 100644
--- a/examples/get_camera_feature_names.py
+++ b/examples/camera/list_feature_names.py
diff --git a/examples/get_camera_feature_values.py b/examples/camera/list_feature_values_and_ranges.py
index 33d454b..353d48e 100644
--- a/examples/get_camera_feature_values.py
+++ b/examples/camera/list_feature_values_and_ranges.py
@@ -13,6 +13,7 @@ if __name__ == '__main__':
try:
value = feature.value
+ range_ = feature.range
# alternatively the feature value can be read as an object attribute
# value = getattr(camera, feature_name)
@@ -21,7 +22,13 @@ if __name__ == '__main__':
except VimbaException as e:
value = e
-
- print(feature_name, '--', value)
+ range_ = None
+
+ print('\n\t'.join(
+ str(x) for x in (
+ feature_name,
+ f'value: {value}',
+ f'range: {range_}')
+ if x is not None))
camera.close()
diff --git a/examples/camera/opencv_capture_image.py b/examples/camera/opencv_capture_image.py
new file mode 100644
index 0000000..e8bf3d5
--- /dev/null
+++ b/examples/camera/opencv_capture_image.py
@@ -0,0 +1,34 @@
+import cv2
+from pymba import Vimba
+
+
+if __name__ == '__main__':
+
+ with Vimba() as vimba:
+ camera = vimba.camera(0)
+ camera.open()
+
+ # setup camera and frame and capture a single image
+ camera.AcquisitionMode = 'SingleFrame'
+ frame = camera.create_frame()
+ frame.announce()
+ camera.start_capture()
+ frame.queue_for_capture()
+ camera.run_feature_command('AcquisitionStart')
+ camera.run_feature_command('AcquisitionStop')
+ frame.wait_for_capture()
+
+ # get the image data as a numpy array
+ image = frame.image_numpy_array()
+
+ # display image
+ cv2.imshow(camera.camera_id, image)
+ # waits for user to close image
+ cv2.waitKey(0)
+
+ # stop capturing and clean up
+ camera.end_capture()
+ camera.flush_capture_queue()
+ camera.revoke_all_frames()
+
+ camera.close()
diff --git a/examples/camera/opencv_capture_image_with_callback.py b/examples/camera/opencv_capture_image_with_callback.py
new file mode 100644
index 0000000..4d5fa28
--- /dev/null
+++ b/examples/camera/opencv_capture_image_with_callback.py
@@ -0,0 +1,44 @@
+from time import sleep
+import cv2
+from pymba import Vimba
+from pymba.frame import Frame
+
+
+def on_callback(completed_frame: Frame):
+ print('Callback called!')
+
+ # get the image data as a numpy array
+ image = completed_frame.image_numpy_array()
+
+ # display image
+ cv2.imshow(camera.camera_id, image)
+ # waits for user to close image
+ cv2.waitKey(0)
+
+
+if __name__ == '__main__':
+
+ with Vimba() as vimba:
+ camera = vimba.camera(0)
+ camera.open()
+
+ # setup camera and frame and capture a single image
+ camera.AcquisitionMode = 'SingleFrame'
+ frame = camera.create_frame()
+ frame.announce()
+ camera.start_capture()
+ frame.queue_for_capture(on_callback)
+ camera.run_feature_command('AcquisitionStart')
+ camera.run_feature_command('AcquisitionStop')
+
+ # wait long enough for the frame callback to be called
+ for _ in range(100):
+ sleep(0.1)
+ print('.', end='')
+
+ # stop capturing and clean up
+ camera.end_capture()
+ camera.flush_capture_queue()
+ camera.revoke_all_frames()
+
+ camera.close()
diff --git a/examples/set_camera_feature_value.py b/examples/camera/write_feature_value.py
index 020f264..77f8ce5 100644
--- a/examples/set_camera_feature_value.py
+++ b/examples/camera/write_feature_value.py
@@ -7,10 +7,14 @@ if __name__ == '__main__':
camera = vimba.camera(0)
camera.open()
- # set a feature value by feature name
+ # read a feature value
feature = camera.feature('ExposureAuto')
- print(feature.value)
- feature.value = feature.value
+ value = feature.value
+
+ # set the feature value
+ feature.value = value
+
+ print(feature.name, '=', feature.value)
# alternatively the feature value can be set as an object attribute
camera.ExposureAuto = feature.value
diff --git a/examples/get_interface.py b/examples/interface/get_interface_object.py
index 0465223..0465223 100644
--- a/examples/get_interface.py
+++ b/examples/interface/get_interface_object.py
diff --git a/examples/get_interface_feature_infos.py b/examples/interface/list_feature_infos.py
index fefa079..fefa079 100644
--- a/examples/get_interface_feature_infos.py
+++ b/examples/interface/list_feature_infos.py
diff --git a/examples/get_interface_feature_names.py b/examples/interface/list_feature_names.py
index 6f0347d..6f0347d 100644
--- a/examples/get_interface_feature_names.py
+++ b/examples/interface/list_feature_names.py
diff --git a/examples/get_interface_feature_values.py b/examples/interface/list_feature_values_and_ranges.py
index fbb59b4..b33c76a 100644
--- a/examples/get_interface_feature_values.py
+++ b/examples/interface/list_feature_values_and_ranges.py
@@ -10,9 +10,9 @@ if __name__ == '__main__':
# get feature value via feature object
for feature_name in interface.feature_names():
feature = interface.feature(feature_name)
-
try:
value = feature.value
+ range_ = feature.range
# alternatively the feature value can be read as an object attribute
# value = getattr(interface, feature_name)
@@ -21,7 +21,13 @@ if __name__ == '__main__':
except VimbaException as e:
value = e
-
- print(feature_name, '--', value)
+ range_ = None
+
+ print('\n\t'.join(
+ str(x) for x in (
+ feature_name,
+ f'value: {value}',
+ f'range: {range_}')
+ if x is not None))
interface.close()
diff --git a/examples/get_interface_ids.py b/examples/interface/list_interface_ids.py
index 9a7cbec..9a7cbec 100644
--- a/examples/get_interface_ids.py
+++ b/examples/interface/list_interface_ids.py
diff --git a/examples/set_interface_feature_value.py b/examples/interface/write_feature_value.py
index f921c0c..0c71da2 100644
--- a/examples/set_interface_feature_value.py
+++ b/examples/interface/write_feature_value.py
@@ -9,9 +9,12 @@ if __name__ == '__main__':
# set a feature value by feature name
feature = interface.feature('InterfacePingPace')
- print(feature.value)
- feature.value = 3
- print(feature.value)
+ value = feature.value
+
+ # set the feature value
+ feature.value = value
+
+ print(feature.name, '=', feature.value)
# alternatively the feature value can be set as an object attribute
interface.InterfacePingPace = 3
diff --git a/examples/get_version.py b/examples/show_version.py
index 1542845..1542845 100644
--- a/examples/get_version.py
+++ b/examples/show_version.py
diff --git a/examples/get_system.py b/examples/system/get_system_object.py
index 2d59001..2d59001 100644
--- a/examples/get_system.py
+++ b/examples/system/get_system_object.py
diff --git a/examples/get_system_feature_values.py b/examples/system/list_feature_values_and_ranges.py
index dd0d178..ef4da34 100644
--- a/examples/get_system_feature_values.py
+++ b/examples/system/list_feature_values_and_ranges.py
@@ -9,9 +9,9 @@ if __name__ == '__main__':
# get feature value via feature object
for feature_name in system.feature_names():
feature = system.feature(feature_name)
-
try:
value = feature.value
+ range_ = feature.range
# alternatively the feature value can be read as an object attribute
# value = getattr(system, feature_name)
@@ -20,5 +20,11 @@ if __name__ == '__main__':
except VimbaException as e:
value = e
-
- print(feature_name, '--', value)
+ range_ = None
+
+ print('\n\t'.join(
+ str(x) for x in (
+ feature_name,
+ f'value: {value}',
+ f'range: {range_}')
+ if x is not None))