GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — VimbaPython/Examples/list_ancillary_data.py at master · alliedvision/VimbaPython
This repository was archived by the owner on Apr 18, 2024. It is now read-only.
Expand file tree/ Copy pathlist_ancillary_data.pyMore file actions 139 lines (101 loc) · 4.56 KB / Copy pathlist_ancillary_data.pyFile metadata and controls139 lines (101 loc) · 4.56 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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 """BSD 2-Clause License Copyright (c) 2019, Allied Vision Technologies GmbH All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import sys from typing import Optional from vimba import * def print_preamble(): print('//////////////////////////////////////////////////////') print('/// Vimba API List Ancillary Data Features Example ///') print('//////////////////////////////////////////////////////\n') def print_usage(): print('Usage:') print(' python list_ancillary_data.py [camera_id]') print(' python list_ancillary_data.py [/h] [-h]') print() print('Parameters:') print(' camera_id ID of the camera to use (using first camera if not specified)') 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() -> Optional[str]: args = sys.argv[1:] argc = len(args) for arg in args: if arg in ('/h', '-h'): print_usage() sys.exit(0) if len(args) > 1: abort(reason="Invalid number of arguments. Abort.", return_code=2, usage=True) return args[0] if argc == 1 else None def get_camera(camera_id: Optional[str]) -> Camera: with Vimba.get_instance() as vimba: if camera_id: try: return vimba.get_camera_by_id(camera_id) except VimbaCameraError: abort('Failed to access Camera \'{}\'. Abort.'.format(camera_id)) else: cams = vimba.get_all_cameras() if not cams: abort('No Cameras accessible. Abort.') return cams[0] def setup_camera(cam: Camera): with cam: # Try to adjust GeV packet size. This Feature is only available for GigE - Cameras. try: cam.GVSPAdjustPacketSize.run() while not cam.GVSPAdjustPacketSize.is_done(): pass except (AttributeError, VimbaFeatureError): pass # Try to enable ChunkMode try: cam.ChunkModeActive.set(True) except (AttributeError, VimbaFeatureError): abort('Failed to enable ChunkMode on Camera \'{}\'. Abort.'.format(cam.get_id())) def main(): print_preamble() cam_id = parse_args() with Vimba.get_instance(): with get_camera(cam_id) as cam: setup_camera(cam) # Capture single Frame and print all contained ancillary data frame = cam.get_frame() anc_data = frame.get_ancillary_data() if anc_data: with anc_data: print('Print ancillary data contained in Frame:') for feat in anc_data.get_all_features(): print('Feature Name : {}'.format(feat.get_name())) print('Display Name : {}'.format(feat.get_display_name())) print('Tooltip : {}'.format(feat.get_tooltip())) print('Description : {}'.format(feat.get_description())) print('SFNC Namespace : {}'.format(feat.get_sfnc_namespace())) print('Value : {}'.format(feat.get())) print() else: abort('Frame {} does not contain AncillaryData. Abort'.format(frame.get_id())) if __name__ == '__main__': main() |
| 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. |