GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update VimbaPython to version 1.2.0 · alliedvision/VimbaPython@988d65b

This repository was archived by the owner on Apr 18, 2024. It is now read-only.

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Documentation
    • Vimba Python Manual.pdf
  • Examples
    • asynchronous_grab.py
  • Tests
    • basic_tests
      • c_binding_test.py
    • real_cam_tests
      • frame_test.py
  • vimba
    • __init__.py
    • c_binding
      • vimba_c.py
    • camera.py
    • frame.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Documentation/Vimba Python Manual.pdf‎

Copy file name to clipboard
51.2 KB
Binary file not shown.
Collapse file

‎Examples/asynchronous_grab.py‎

Copy file name to clipboardExpand all lines: Examples/asynchronous_grab.py
+14-7Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"""
2727

2828
import sys
29-
from typing import Optional
29+
from typing import Optional, Tuple
3030
from vimba import *
3131

3232

@@ -38,10 +38,11 @@ def print_preamble():
3838

3939
def print_usage():
4040
print('Usage:')
41-
print(' python asynchronous_grab.py [camera_id]')
41+
print(' python asynchronous_grab.py [/x] [-x] [camera_id]')
4242
print(' python asynchronous_grab.py [/h] [-h]')
4343
print()
4444
print('Parameters:')
45+
print(' /x, -x If set, use AllocAndAnnounce mode of buffer allocation')
4546
print(' camera_id ID of the camera to use (using first camera if not specified)')
4647
print()
4748

@@ -55,19 +56,25 @@ def abort(reason: str, return_code: int = 1, usage: bool = False):
5556
sys.exit(return_code)
5657

5758

58-
def parse_args() -> Optional[str]:
59+
def parse_args() -> Tuple[Optional[str], AllocationMode]:
5960
args = sys.argv[1:]
6061
argc = len(args)
6162

63+
allocation_mode = AllocationMode.AnnounceFrame
64+
cam_id = ""
6265
for arg in args:
6366
if arg in ('/h', '-h'):
6467
print_usage()
6568
sys.exit(0)
69+
elif arg in ('/x', '-x'):
70+
allocation_mode = AllocationMode.AllocAndAnnounceFrame
71+
elif not cam_id:
72+
cam_id = arg
6673

67-
if argc > 1:
74+
if argc > 2:
6875
abort(reason="Invalid number of arguments. Abort.", return_code=2, usage=True)
6976

70-
return None if argc == 0 else args[0]
77+
return (cam_id if cam_id else None, allocation_mode)
7178

7279

7380
def get_camera(camera_id: Optional[str]) -> Camera:
@@ -108,7 +115,7 @@ def frame_handler(cam: Camera, frame: Frame):
108115

109116
def main():
110117
print_preamble()
111-
cam_id = parse_args()
118+
cam_id, allocation_mode = parse_args()
112119

113120
with Vimba.get_instance():
114121
with get_camera(cam_id) as cam:
@@ -118,7 +125,7 @@ def main():
118125

119126
try:
120127
# Start Streaming with a custom a buffer of 10 Frames (defaults to 5)
121-
cam.start_streaming(handler=frame_handler, buffer_count=10)
128+
cam.start_streaming(handler=frame_handler, buffer_count=10, allocation_mode=allocation_mode)
122129
input()
123130

124131
finally:
Collapse file

‎Tests/basic_tests/c_binding_test.py‎

Copy file name to clipboardExpand all lines: Tests/basic_tests/c_binding_test.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def tearDown(self):
245245

246246
def test_call_vimba_c_valid(self):
247247
# Expectation for valid call: No exceptions, no errors
248-
expected_ver_info = (1, 8, 5)
248+
expected_ver_info = (1, 9, 0)
249249
ver_info = VmbVersionInfo()
250250

251251
call_vimba_c('VmbVersionQuery', byref(ver_info), sizeof(ver_info))
Collapse file

‎Tests/real_cam_tests/frame_test.py‎

Copy file name to clipboardExpand all lines: Tests/real_cam_tests/frame_test.py
+83-50Lines changed: 83 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -50,102 +50,135 @@ def tearDown(self):
5050

5151
def test_verify_buffer(self):
5252
# Expectation: A Frame buffer shall have exactly the specified size on construction.
53-
self.assertEqual(Frame(0).get_buffer_size(), 0)
54-
self.assertEqual(Frame(1024).get_buffer_size(), 1024)
55-
self.assertEqual(Frame(1024 * 1024).get_buffer_size(), 1024 * 1024)
53+
# Allocation is performed by VimbaPython
54+
self.assertEqual(Frame(0, AllocationMode.AnnounceFrame).get_buffer_size(), 0)
55+
self.assertEqual(Frame(1024, AllocationMode.AnnounceFrame).get_buffer_size(), 1024)
56+
self.assertEqual(Frame(1024 * 1024, AllocationMode.AnnounceFrame).get_buffer_size(),
57+
1024 * 1024)
5658

57-
def test_verify_no_copy_buffer_access(self):
59+
def test_verify_no_copy_empty_buffer_access(self):
5860
# Expectation: Accessing the internal buffer must not create a copy
59-
frame = Frame(10)
61+
# frame._buffer is only set on construction if buffer is allocated by VimbaPython
62+
frame = Frame(10, AllocationMode.AnnounceFrame)
6063
self.assertEqual(id(frame._buffer), id(frame.get_buffer()))
6164

65+
def test_verify_no_copy_filled_buffer_access(self):
66+
# Expectation: Accessing the internal buffer must not create a copy
67+
for allocation_mode in AllocationMode:
68+
with self.subTest(f'allocation_mode={str(allocation_mode)}'):
69+
with self.cam:
70+
frame = self.cam.get_frame(allocation_mode=allocation_mode)
71+
self.assertEqual(id(frame._buffer), id(frame.get_buffer()))
72+
6273
def test_get_id(self):
6374
# Expectation: get_id() must return None if Its locally constructed
6475
# else it must return the frame id.
65-
self.assertIsNone(Frame(0).get_id())
76+
for allocation_mode in AllocationMode:
77+
with self.subTest(f'allocation_mode={str(allocation_mode)}'):
78+
self.assertIsNone(Frame(0, allocation_mode).get_id())
6679

67-
with self.cam:
68-
self.assertIsNotNone(self.cam.get_frame().get_id())
80+
with self.cam:
81+
self.assertIsNotNone(
82+
self.cam.get_frame(allocation_mode=allocation_mode).get_id())
6983

7084
def test_get_timestamp(self):
7185
# Expectation: get_timestamp() must return None if Its locally constructed
7286
# else it must return the timestamp.
73-
self.assertIsNone(Frame(0).get_timestamp())
87+
for allocation_mode in AllocationMode:
88+
with self.subTest(f'allocation_mode={str(allocation_mode)}'):
89+
self.assertIsNone(Frame(0, allocation_mode).get_timestamp())
7490

75-
with self.cam:
76-
self.assertIsNotNone(self.cam.get_frame().get_timestamp())
91+
with self.cam:
92+
self.assertIsNotNone(
93+
self.cam.get_frame(allocation_mode=allocation_mode).get_timestamp())
7794

7895
def test_get_offset(self):
7996
# Expectation: get_offset_x() must return None if Its locally constructed
8097
# else it must return the offset as int. Same goes for get_offset_y()
98+
for allocation_mode in AllocationMode:
99+
with self.subTest(f'allocation_mode={str(allocation_mode)}'):
100+
self.assertIsNone(Frame(0, allocation_mode).get_offset_x())
101+
self.assertIsNone(Frame(0, allocation_mode).get_offset_y())
81102

82-
self.assertIsNone(Frame(0).get_offset_x())
83-
self.assertIsNone(Frame(0).get_offset_y())
103+
with self.cam:
104+
frame = self.cam.get_frame(allocation_mode=allocation_mode)
105+
self.assertIsNotNone(frame.get_offset_x())
106+
self.assertIsNotNone(frame.get_offset_y())
84107

85108
def test_get_dimension(self):
86109
# Expectation: get_width() must return None if Its locally constructed
87110
# else it must return the offset as int. Same goes for get_height()
111+
for allocation_mode in AllocationMode:
112+
with self.subTest(f'allocation_mode={str(allocation_mode)}'):
113+
self.assertIsNone(Frame(0, allocation_mode).get_width())
114+
self.assertIsNone(Frame(0, allocation_mode).get_height())
88115

89-
self.assertIsNone(Frame(0).get_width())
90-
self.assertIsNone(Frame(0).get_height())
91-
92-
with self.cam:
93-
frame = self.cam.get_frame()
94-
self.assertIsNotNone(frame.get_width())
95-
self.assertIsNotNone(frame.get_height())
116+
with self.cam:
117+
frame = self.cam.get_frame(allocation_mode=allocation_mode)
118+
self.assertIsNotNone(frame.get_width())
119+
self.assertIsNotNone(frame.get_height())
96120

97121
def test_get_image_size(self):
98122
# Expectation: get_image_size() must return 0 if locally constructed
99123
# else it must return the image_size as int.
124+
for allocation_mode in AllocationMode:
125+
with self.subTest(f'allocation_mode={str(allocation_mode)}'):
126+
self.assertEquals(Frame(0, allocation_mode).get_image_size(), 0)
100127

101-
self.assertEquals(Frame(0).get_image_size(), 0)
102-
103-
with self.cam:
104-
self.assertNotEquals(self.cam.get_frame().get_image_size(), 0)
128+
with self.cam:
129+
self.assertNotEquals(
130+
self.cam.get_frame(allocation_mode=allocation_mode).get_image_size(), 0)
105131

106132
def test_deepcopy(self):
107133
# Expectation: a deepcopy must clone the frame buffer with its contents an
108134
# update the internally store pointer in VmbFrame struct.
135+
for allocation_mode in AllocationMode:
136+
with self.subTest(f'allocation_mode={str(allocation_mode)}'):
137+
with self.cam:
138+
frame = self.cam.get_frame(allocation_mode=allocation_mode)
109139

110-
with self.cam:
111-
frame = self.cam.get_frame()
112-
113-
frame_cpy = copy.deepcopy(frame)
140+
frame_cpy = copy.deepcopy(frame)
114141

115-
# Ensure frames and their members are not the same object
116-
self.assertNotEquals(id(frame), id(frame_cpy))
117-
self.assertNotEquals(id(frame._buffer), id(frame_cpy._buffer))
118-
self.assertNotEquals(id(frame._frame), id(frame_cpy._frame))
142+
# Ensure frames and their members are not the same object
143+
self.assertNotEquals(id(frame), id(frame_cpy))
144+
self.assertNotEquals(id(frame._buffer), id(frame_cpy._buffer))
145+
self.assertNotEquals(id(frame._frame), id(frame_cpy._frame))
119146

120-
# Ensure that both buffers have the same size and contain the same data.
121-
self.assertEquals(frame.get_buffer_size(), frame_cpy.get_buffer_size())
122-
self.assertEquals(frame.get_buffer().raw, frame_cpy.get_buffer().raw)
147+
# Ensure that both buffers have the same size and contain the same data.
148+
self.assertEquals(frame.get_buffer_size(), frame_cpy.get_buffer_size())
149+
self.assertTrue(all(a == b for a, b in zip(frame.get_buffer(),
150+
frame_cpy.get_buffer())))
123151

124-
# Ensure that internal Frame Pointer points to correct buffer.
125-
self.assertEquals(frame._frame.buffer,
126-
ctypes.cast(frame._buffer, ctypes.c_void_p).value)
152+
# Ensure that internal Frame Pointer points to correct buffer.
153+
self.assertEquals(frame._frame.buffer,
154+
ctypes.cast(frame._buffer, ctypes.c_void_p).value)
127155

128-
self.assertEquals(frame_cpy._frame.buffer,
129-
ctypes.cast(frame_cpy._buffer, ctypes.c_void_p).value)
156+
self.assertEquals(frame_cpy._frame.buffer,
157+
ctypes.cast(frame_cpy._buffer, ctypes.c_void_p).value)
130158

131-
self.assertEquals(frame._frame.bufferSize, frame_cpy._frame.bufferSize)
159+
self.assertEquals(frame._frame.bufferSize, frame_cpy._frame.bufferSize)
132160

133161
def test_get_pixel_format(self):
134162
# Expectation: Frames have an image format set after acquisition
135-
with self.cam:
136-
self.assertNotEquals(self.cam.get_frame().get_pixel_format(), 0)
163+
for allocation_mode in AllocationMode:
164+
with self.subTest(f'allocation_mode={str(allocation_mode)}'):
165+
with self.cam:
166+
self.assertNotEquals(
167+
self.cam.get_frame(allocation_mode=allocation_mode).get_pixel_format(), 0)
137168

138169
def test_incompatible_formats_value_error(self):
139170
# Expectation: Conversion into incompatible formats must lead to an value error
140-
with self.cam:
141-
frame = self.cam.get_frame()
171+
for allocation_mode in AllocationMode:
172+
with self.subTest(f'allocation_mode={str(allocation_mode)}'):
173+
with self.cam:
174+
frame = self.cam.get_frame(allocation_mode=allocation_mode)
142175

143-
current_fmt = frame.get_pixel_format()
144-
convertable_fmt = current_fmt.get_convertible_formats()
176+
current_fmt = frame.get_pixel_format()
177+
convertable_fmt = current_fmt.get_convertible_formats()
145178

146-
for fmt in PixelFormat.__members__.values():
147-
if (fmt != current_fmt) and (fmt not in convertable_fmt):
148-
self.assertRaises(ValueError, frame.convert_pixel_format, fmt)
179+
for fmt in PixelFormat.__members__.values():
180+
if (fmt != current_fmt) and (fmt not in convertable_fmt):
181+
self.assertRaises(ValueError, frame.convert_pixel_format, fmt)
149182

150183
def test_convert_to_all_given_formats(self):
151184
# Expectation: A Series of Frame, each acquired with a different Pixel format
Collapse file

‎vimba/__init__.py‎

Copy file name to clipboardExpand all lines: vimba/__init__.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# Suppress 'imported but unused' - Error from static style checker.
2929
# flake8: noqa: F401
3030

31-
__version__ = '1.1.0'
31+
__version__ = '1.2.0'
3232

3333
__all__ = [
3434
'Vimba',
@@ -46,6 +46,7 @@
4646
'FeatureTypes',
4747
'FrameHandler',
4848
'FrameStatus',
49+
'AllocationMode',
4950
'Debayer',
5051
'intersect_pixel_formats',
5152
'MONO_PIXEL_FORMATS',
@@ -109,7 +110,8 @@
109110
from .frame import PixelFormat, Frame, Debayer, intersect_pixel_formats, MONO_PIXEL_FORMATS, \
110111
BAYER_PIXEL_FORMATS, RGB_PIXEL_FORMATS, RGBA_PIXEL_FORMATS, BGR_PIXEL_FORMATS, \
111112
BGRA_PIXEL_FORMATS, YUV_PIXEL_FORMATS, YCBCR_PIXEL_FORMATS, \
112-
COLOR_PIXEL_FORMATS, OPENCV_PIXEL_FORMATS, FrameStatus, FeatureTypes
113+
COLOR_PIXEL_FORMATS, OPENCV_PIXEL_FORMATS, FrameStatus, FeatureTypes, \
114+
AllocationMode
113115

114116
from .error import VimbaSystemError, VimbaCameraError, VimbaInterfaceError, VimbaFeatureError, \
115117
VimbaFrameError, VimbaTimeout
Collapse file

‎vimba/c_binding/vimba_c.py‎

Copy file name to clipboardExpand all lines: vimba/c_binding/vimba_c.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ def __repr__(self):
572572
G_VIMBA_C_HANDLE = VmbHandle(1)
573573

574574
VIMBA_C_VERSION = None
575-
EXPECTED_VIMBA_C_VERSION = '1.8.5'
575+
EXPECTED_VIMBA_C_VERSION = '1.9.0'
576576

577577
# For detailed information on the signatures see "VimbaC.h"
578578
# To improve readability, suppress 'E501 line too long (> 100 characters)'

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.