├── .gitignore ├── AUTHORS ├── MANIFEST.in ├── README.rst ├── convert.py ├── debian ├── changelog ├── compat ├── control ├── copyright └── rules ├── setup.py ├── src ├── _FlyCapture2Defs_C.pxd ├── _FlyCapture2_C.pxd ├── flycapture2.pyx ├── flycapture2.pyxdep └── flycapture2_enums.pxi └── test_flycapture2.py /.gitignore: -------------------------------------------------------------------------------- 1 | /src/flycapture2.c 2 | /src/flycapture2.html 3 | /build 4 | /dist 5 | *.egg-info 6 | /debian/files 7 | /debian/*.debhelper 8 | /debian/*.substvars 9 | /debian/*-stampdir 10 | /debian/*.log 11 | /debian/python-flycapture2 12 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Robert Jordens 2 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS 2 | include README.rst 3 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | pyflycapture2 2 | ============= 3 | 4 | *Cython/Cwrap based python bindings for the FlyCapture v2 C API from PointGrey.* 5 | 6 | License: GPLv3+ 7 | 8 | NOTE 9 | ==== 10 | 11 | **There is "Python support for FlyCapture2 SDK" available from PointGrey now. You may want to try and use those instead of these bindings.** 12 | 13 | 14 | Install PointGrey FlyCapture2 Library 15 | ------------------------------------- 16 | 17 | Links and instructions for downloading and installing the latest 18 | FlyCapture 2.x library from Point Grey for Linux can be found here: 19 | 20 | http://www.ptgrey.com/support/downloads 21 | 22 | Download Linux (64-bit, 32-bit, or ARM, whichever is appropriate). 23 | This requires registration. Follow the instructions in those packages to 24 | install the libraries. 25 | 26 | It will also be necessary to copy or link the contents of flycapture.2x/lib/C to /usr/lib. 27 | 28 | Install pyflycapture2 29 | --------------------- 30 | 31 | Ensure that you have installed ``cython`` and ``numpy``. 32 | Use ``virtualenv`` to your advantage.:: 33 | 34 | pip install git+https://github.com/jordens/pyflycapture2.git 35 | 36 | 37 | Test pyflycapture2 38 | ------------------ 39 | 40 | Adapt ``test_flycapture2.py`` to your camera and liking.:: 41 | 42 | python test_flycapture2.py 43 | -------------------------------------------------------------------------------- /convert.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # pyflycapture2 - python bindings for libflycapture2_c 4 | # Copyright (C) 2012 Robert Jordens 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | from cwrap.config import Config, File 20 | 21 | if __name__ == '__main__': 22 | config = Config('gccxml', files=[ 23 | File('FlyCapture2Defs_C.h'), 24 | File('FlyCapture2_C.h'), 25 | ]) 26 | config.generate() 27 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | python-flycapture2 (0.1+dev) unstable; urgency=low 2 | 3 | * Initial packaging 4 | 5 | -- Robert Jordens Sat, 03 Mar 2012 15:22:46 -0700 6 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: python-flycapture2 2 | Section: python 3 | Priority: optional 4 | Maintainer: Robert Jordens 5 | Build-Depends: cdbs (>= 0.4.90~), 6 | python (>= 2.6.6-3~), 7 | python-setuptools, 8 | debhelper (>= 5), 9 | cython, 10 | libflycapture-c2-dev (>= 2.2.3), 11 | libusb-1.0-0-dev, 12 | python-numpy 13 | XS-Python-Version: >=2.5 14 | Standards-Version: 3.9.3 15 | 16 | Package: python-flycapture2 17 | Architecture: all 18 | XB-Python-Version: ${python:Versions} 19 | Depends: ${misc:Depends}, ${python:Depends}, 20 | python-numpy, libflycapture-c2 (>= 2.2.3), 21 | libusb-1.0-0 22 | Provides: ${python:Provides} 23 | Description: Python wrapper for libflycapture-c2 24 | Cython based python bindings for the FlyCapture2 C API from PointGrey. 25 | . 26 | The library itself is available from PointGrey: 27 | http://www.ptgrey.com/support/downloads/download.asp (login required) 28 | . 29 | API docs: 30 | http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/C/html/index.html 31 | (C API) 32 | http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/html/index.html 33 | (C++ API) 34 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by Robert Jordens on 2 | Sun Feb 26 05:38:54 MST 2012. 3 | 4 | Copyright: 5 | 6 | Copyright (C) 2012 Robert Jordens 7 | 8 | License: 9 | 10 | Upstream Author: Robert Jordens 11 | Project Homepage: https://launchpad.net/pyflycapture2 12 | Released under the GPL 13 | 14 | Copyright (C) 2011 Robert Jordens 15 | 16 | This program is free software: you can redistribute it and/or modify 17 | it under the terms of the GNU General Public License as published by 18 | the Free Software Foundation, either version 3 of the License, or 19 | (at your option) any later version. 20 | 21 | This program is distributed in the hope that it will be useful, 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | GNU General Public License for more details. 25 | 26 | You should have received a copy of the GNU General Public License 27 | along with this program. If not, see . 28 | 29 | On Debian systems, the complete text of the GNU General 30 | Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'. 31 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | include /usr/share/cdbs/1/rules/debhelper.mk 4 | include /usr/share/cdbs/1/class/python-distutils.mk 5 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # pyflycapture2 - python bindings for libflycapture2_c 5 | # Copyright (C) 2012 Robert Jordens 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | 20 | try: 21 | from setuptools import setup, Extension 22 | except ImportError: 23 | from distutils import setup 24 | from distutils.extension import Extension 25 | 26 | from Cython.Distutils import build_ext 27 | import numpy 28 | import os 29 | 30 | if os.name == "posix": 31 | libname = "flycapture-c" 32 | else: 33 | libname = "flycapture2_c" 34 | 35 | if os.path.exists("C:/Program Files (x86)/Point Grey Research/FlyCapture2"): 36 | pointgrey_win = "C:/Program Files (x86)/Point Grey Research/FlyCapture2" 37 | else: 38 | pointgrey_win = "C:/Program Files/Point Grey Research/FlyCapture2" 39 | 40 | if os.path.exists(pointgrey_win+"/lib/C"): 41 | libfolder = "/lib/C" 42 | else: 43 | libfolder = "/lib64/C" 44 | 45 | setup( 46 | name="pyflycapture2", 47 | description="python wrapper for libflycapture2 (C-API)", 48 | long_description= 49 | """The library itself is available from PointGrey: 50 | http://www.ptgrey.com/support/downloads/download.asp (login required) 51 | API docs: 52 | http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/C/html/index.html 53 | (C API) 54 | http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/html/index.html 55 | (C++ API)""", 56 | version="0.1+dev", 57 | author="Robert Jordens", 58 | author_email="robert@joerdens.org", 59 | url="http://launchpad.net/pyflycapture2", 60 | license="GPLv3+", 61 | install_requires=["numpy"], 62 | #packages=["flycapture2"], 63 | cmdclass = {'build_ext': build_ext}, 64 | #"test_flycapture2.py", "convert.py" 65 | ext_modules = [Extension("flycapture2", 66 | sources = ["src/flycapture2.pyx", "src/flycapture2_enums.pxi", 67 | "src/_FlyCapture2Defs_C.pxd", "src/_FlyCapture2_C.pxd",], 68 | libraries = [libname], 69 | library_dirs = ["%s%s" % (pointgrey_win, libfolder)], 70 | include_dirs = ["/usr/include/flycapture/C", 71 | "%s/include/C" % pointgrey_win, 72 | numpy.get_include(), ], 73 | ),] 74 | ) 75 | -------------------------------------------------------------------------------- /src/_FlyCapture2Defs_C.pxd: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # pyflycapture2 - python bindings for libflycapture2_c 4 | # Copyright (C) 2012 Robert Jordens 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | # This code was automatically generated by CWrap version 0.0.0 20 | 21 | cdef extern from "FlyCapture2Defs_C.h": 22 | 23 | ctypedef int BOOL 24 | 25 | ctypedef void *fc2Context 26 | 27 | ctypedef void *fc2GuiContext 28 | 29 | ctypedef void *fc2ImageImpl 30 | 31 | ctypedef void *fc2AVIContext 32 | 33 | ctypedef void *fc2ImageStatisticsContext 34 | 35 | cdef struct _fc2PGRGuid: 36 | unsigned int value[4] 37 | 38 | ctypedef _fc2PGRGuid fc2PGRGuid 39 | 40 | cdef enum _fc2Error: 41 | FC2_ERROR_UNDEFINED 42 | FC2_ERROR_OK 43 | FC2_ERROR_FAILED 44 | FC2_ERROR_NOT_IMPLEMENTED 45 | FC2_ERROR_FAILED_BUS_MASTER_CONNECTION 46 | FC2_ERROR_NOT_CONNECTED 47 | FC2_ERROR_INIT_FAILED 48 | FC2_ERROR_NOT_INTITIALIZED 49 | FC2_ERROR_INVALID_PARAMETER 50 | FC2_ERROR_INVALID_SETTINGS 51 | FC2_ERROR_INVALID_BUS_MANAGER 52 | FC2_ERROR_MEMORY_ALLOCATION_FAILED 53 | FC2_ERROR_LOW_LEVEL_FAILURE 54 | FC2_ERROR_NOT_FOUND 55 | FC2_ERROR_FAILED_GUID 56 | FC2_ERROR_INVALID_PACKET_SIZE 57 | FC2_ERROR_INVALID_MODE 58 | FC2_ERROR_NOT_IN_FORMAT7 59 | FC2_ERROR_NOT_SUPPORTED 60 | FC2_ERROR_TIMEOUT 61 | FC2_ERROR_BUS_MASTER_FAILED 62 | FC2_ERROR_INVALID_GENERATION 63 | FC2_ERROR_LUT_FAILED 64 | FC2_ERROR_IIDC_FAILED 65 | FC2_ERROR_STROBE_FAILED 66 | FC2_ERROR_TRIGGER_FAILED 67 | FC2_ERROR_PROPERTY_FAILED 68 | FC2_ERROR_PROPERTY_NOT_PRESENT 69 | FC2_ERROR_REGISTER_FAILED 70 | FC2_ERROR_READ_REGISTER_FAILED 71 | FC2_ERROR_WRITE_REGISTER_FAILED 72 | FC2_ERROR_ISOCH_FAILED 73 | FC2_ERROR_ISOCH_ALREADY_STARTED 74 | FC2_ERROR_ISOCH_NOT_STARTED 75 | FC2_ERROR_ISOCH_START_FAILED 76 | FC2_ERROR_ISOCH_RETRIEVE_BUFFER_FAILED 77 | FC2_ERROR_ISOCH_STOP_FAILED 78 | FC2_ERROR_ISOCH_SYNC_FAILED 79 | FC2_ERROR_ISOCH_BANDWIDTH_EXCEEDED 80 | FC2_ERROR_IMAGE_CONVERSION_FAILED 81 | FC2_ERROR_IMAGE_LIBRARY_FAILURE 82 | FC2_ERROR_BUFFER_TOO_SMALL 83 | FC2_ERROR_IMAGE_CONSISTENCY_ERROR 84 | FC2_ERROR_FORCE_32BITS 85 | 86 | ctypedef _fc2Error fc2Error 87 | 88 | cdef enum _fc2BusCallbackType: 89 | FC2_BUS_RESET 90 | FC2_ARRIVAL 91 | FC2_REMOVAL 92 | FC2_CALLBACK_TYPE_FORCE_32BITS 93 | 94 | ctypedef _fc2BusCallbackType fc2BusCallbackType 95 | 96 | cdef enum _fc2GrabMode: 97 | FC2_DROP_FRAMES 98 | FC2_BUFFER_FRAMES 99 | FC2_UNSPECIFIED_GRAB_MODE 100 | FC2_GRAB_MODE_FORCE_32BITS 101 | 102 | ctypedef _fc2GrabMode fc2GrabMode 103 | 104 | cdef enum _fc2GrabTimeout: 105 | FC2_TIMEOUT_NONE 106 | FC2_TIMEOUT_INFINITE 107 | FC2_TIMEOUT_UNSPECIFIED 108 | FC2_GRAB_TIMEOUT_FORCE_32BITS 109 | 110 | ctypedef _fc2GrabTimeout fc2GrabTimeout 111 | 112 | cdef enum _fc2BandwidthAllocation: 113 | FC2_BANDWIDTH_ALLOCATION_OFF 114 | FC2_BANDWIDTH_ALLOCATION_ON 115 | FC2_BANDWIDTH_ALLOCATION_UNSUPPORTED 116 | FC2_BANDWIDTH_ALLOCATION_UNSPECIFIED 117 | FC2_BANDWIDTH_ALLOCATION_FORCE_32BITS 118 | 119 | ctypedef _fc2BandwidthAllocation fc2BandwidthAllocation 120 | 121 | cdef enum _fc2InterfaceType: 122 | FC2_INTERFACE_IEEE1394 123 | FC2_INTERFACE_USB_2 124 | FC2_INTERFACE_USB_3 125 | FC2_INTERFACE_GIGE 126 | FC2_INTERFACE_UNKNOWN 127 | FC2_INTERFACE_TYPE_FORCE_32BITS 128 | 129 | ctypedef _fc2InterfaceType fc2InterfaceType 130 | 131 | cdef enum _fc2DriverType: 132 | FC2_DRIVER_1394_CAM 133 | FC2_DRIVER_1394_PRO 134 | FC2_DRIVER_1394_JUJU 135 | FC2_DRIVER_1394_VIDEO1394 136 | FC2_DRIVER_1394_RAW1394 137 | FC2_DRIVER_USB_NONE 138 | FC2_DRIVER_USB_CAM 139 | FC2_DRIVER_USB3_PRO 140 | FC2_DRIVER_GIGE_NONE 141 | FC2_DRIVER_GIGE_FILTER 142 | FC2_DRIVER_GIGE_PRO 143 | FC2_DRIVER_UNKNOWN 144 | FC2_DRIVER_FORCE_32BITS 145 | 146 | ctypedef _fc2DriverType fc2DriverType 147 | 148 | cdef enum _fc2PropertyType: 149 | FC2_BRIGHTNESS 150 | FC2_AUTO_EXPOSURE 151 | FC2_SHARPNESS 152 | FC2_WHITE_BALANCE 153 | FC2_HUE 154 | FC2_SATURATION 155 | FC2_GAMMA 156 | FC2_IRIS 157 | FC2_FOCUS 158 | FC2_ZOOM 159 | FC2_PAN 160 | FC2_TILT 161 | FC2_SHUTTER 162 | FC2_GAIN 163 | FC2_TRIGGER_MODE 164 | FC2_TRIGGER_DELAY 165 | FC2_FRAME_RATE 166 | FC2_TEMPERATURE 167 | FC2_UNSPECIFIED_PROPERTY_TYPE 168 | FC2_PROPERTY_TYPE_FORCE_32BITS 169 | 170 | ctypedef _fc2PropertyType fc2PropertyType 171 | 172 | cdef enum _fc2FrameRate: 173 | FC2_FRAMERATE_1_875 174 | FC2_FRAMERATE_3_75 175 | FC2_FRAMERATE_7_5 176 | FC2_FRAMERATE_15 177 | FC2_FRAMERATE_30 178 | FC2_FRAMERATE_60 179 | FC2_FRAMERATE_120 180 | FC2_FRAMERATE_240 181 | FC2_FRAMERATE_FORMAT7 182 | FC2_NUM_FRAMERATES 183 | FC2_FRAMERATE_FORCE_32BITS 184 | 185 | ctypedef _fc2FrameRate fc2FrameRate 186 | 187 | cdef enum _fc2VideoMode: 188 | FC2_VIDEOMODE_160x120YUV444 189 | FC2_VIDEOMODE_320x240YUV422 190 | FC2_VIDEOMODE_640x480YUV411 191 | FC2_VIDEOMODE_640x480YUV422 192 | FC2_VIDEOMODE_640x480RGB 193 | FC2_VIDEOMODE_640x480Y8 194 | FC2_VIDEOMODE_640x480Y16 195 | FC2_VIDEOMODE_800x600YUV422 196 | FC2_VIDEOMODE_800x600RGB 197 | FC2_VIDEOMODE_800x600Y8 198 | FC2_VIDEOMODE_800x600Y16 199 | FC2_VIDEOMODE_1024x768YUV422 200 | FC2_VIDEOMODE_1024x768RGB 201 | FC2_VIDEOMODE_1024x768Y8 202 | FC2_VIDEOMODE_1024x768Y16 203 | FC2_VIDEOMODE_1280x960YUV422 204 | FC2_VIDEOMODE_1280x960RGB 205 | FC2_VIDEOMODE_1280x960Y8 206 | FC2_VIDEOMODE_1280x960Y16 207 | FC2_VIDEOMODE_1600x1200YUV422 208 | FC2_VIDEOMODE_1600x1200RGB 209 | FC2_VIDEOMODE_1600x1200Y8 210 | FC2_VIDEOMODE_1600x1200Y16 211 | FC2_VIDEOMODE_FORMAT7 212 | FC2_NUM_VIDEOMODES 213 | FC2_VIDEOMODE_FORCE_32BITS 214 | 215 | ctypedef _fc2VideoMode fc2VideoMode 216 | 217 | cdef enum _fc2Mode: 218 | FC2_MODE_0 219 | FC2_MODE_1 220 | FC2_MODE_2 221 | FC2_MODE_3 222 | FC2_MODE_4 223 | FC2_MODE_5 224 | FC2_MODE_6 225 | FC2_MODE_7 226 | FC2_MODE_8 227 | FC2_MODE_9 228 | FC2_MODE_10 229 | FC2_MODE_11 230 | FC2_MODE_12 231 | FC2_MODE_13 232 | FC2_MODE_14 233 | FC2_MODE_15 234 | FC2_MODE_16 235 | FC2_MODE_17 236 | FC2_MODE_18 237 | FC2_MODE_19 238 | FC2_MODE_20 239 | FC2_MODE_21 240 | FC2_MODE_22 241 | FC2_MODE_23 242 | FC2_MODE_24 243 | FC2_MODE_25 244 | FC2_MODE_26 245 | FC2_MODE_27 246 | FC2_MODE_28 247 | FC2_MODE_29 248 | FC2_MODE_30 249 | FC2_MODE_31 250 | FC2_NUM_MODES 251 | FC2_MODE_FORCE_32BITS 252 | 253 | ctypedef _fc2Mode fc2Mode 254 | 255 | cdef enum _fc2PixelFormat: 256 | FC2_PIXEL_FORMAT_MONO8 257 | FC2_PIXEL_FORMAT_411YUV8 258 | FC2_PIXEL_FORMAT_422YUV8 259 | FC2_PIXEL_FORMAT_444YUV8 260 | FC2_PIXEL_FORMAT_RGB8 261 | FC2_PIXEL_FORMAT_MONO16 262 | FC2_PIXEL_FORMAT_RGB16 263 | FC2_PIXEL_FORMAT_S_MONO16 264 | FC2_PIXEL_FORMAT_S_RGB16 265 | FC2_PIXEL_FORMAT_RAW8 266 | FC2_PIXEL_FORMAT_RAW16 267 | FC2_PIXEL_FORMAT_MONO12 268 | FC2_PIXEL_FORMAT_RAW12 269 | FC2_PIXEL_FORMAT_BGR 270 | FC2_PIXEL_FORMAT_BGRU 271 | FC2_PIXEL_FORMAT_RGB 272 | FC2_PIXEL_FORMAT_RGBU 273 | FC2_PIXEL_FORMAT_BGR16 274 | FC2_PIXEL_FORMAT_422YUV8_JPEG 275 | FC2_NUM_PIXEL_FORMATS 276 | FC2_UNSPECIFIED_PIXEL_FORMAT 277 | 278 | ctypedef _fc2PixelFormat fc2PixelFormat 279 | 280 | cdef enum _fc2BusSpeed: 281 | FC2_BUSSPEED_S100 282 | FC2_BUSSPEED_S200 283 | FC2_BUSSPEED_S400 284 | FC2_BUSSPEED_S480 285 | FC2_BUSSPEED_S800 286 | FC2_BUSSPEED_S1600 287 | FC2_BUSSPEED_S3200 288 | FC2_BUSSPEED_S5000 289 | FC2_BUSSPEED_10BASE_T 290 | FC2_BUSSPEED_100BASE_T 291 | FC2_BUSSPEED_1000BASE_T 292 | FC2_BUSSPEED_10000BASE_T 293 | FC2_BUSSPEED_S_FASTEST 294 | FC2_BUSSPEED_ANY 295 | FC2_BUSSPEED_SPEED_UNKNOWN 296 | FC2_BUSSPEED_FORCE_32BITS 297 | 298 | ctypedef _fc2BusSpeed fc2BusSpeed 299 | 300 | cdef enum _fc2PCIeBusSpeed: 301 | FC2_PCIE_BUSSPEED_2_5 302 | FC2_PCIE_BUSSPEED_5_0 303 | FC2_PCIE_BUSSPEED_UNKNOWN 304 | FC2_PCIE_BUSSPEED_FORCE_32BITS 305 | 306 | ctypedef _fc2PCIeBusSpeed fc2PCIeBusSpeed 307 | 308 | cdef enum _fc2ColorProcessingAlgorithm: 309 | FC2_DEFAULT 310 | FC2_NO_COLOR_PROCESSING 311 | FC2_NEAREST_NEIGHBOR_FAST 312 | FC2_EDGE_SENSING 313 | FC2_HQ_LINEAR 314 | FC2_RIGOROUS 315 | FC2_IPP 316 | FC2_DIRECTIONAL 317 | FC2_COLOR_PROCESSING_ALGORITHM_FORCE_32BITS 318 | 319 | ctypedef _fc2ColorProcessingAlgorithm fc2ColorProcessingAlgorithm 320 | 321 | cdef enum _fc2BayerTileFormat: 322 | FC2_BT_NONE 323 | FC2_BT_RGGB 324 | FC2_BT_GRBG 325 | FC2_BT_GBRG 326 | FC2_BT_BGGR 327 | FC2_BT_FORCE_32BITS 328 | 329 | ctypedef _fc2BayerTileFormat fc2BayerTileFormat 330 | 331 | cdef enum _fc2ImageFileFormat: 332 | FC2_FROM_FILE_EXT 333 | FC2_PGM 334 | FC2_PPM 335 | FC2_BMP 336 | FC2_JPEG 337 | FC2_JPEG2000 338 | FC2_TIFF 339 | FC2_PNG 340 | FC2_RAW 341 | FC2_IMAGE_FILE_FORMAT_FORCE_32BITS 342 | 343 | ctypedef _fc2ImageFileFormat fc2ImageFileFormat 344 | 345 | cdef enum _fc2GigEPropertyType: 346 | FC2_HEARTBEAT 347 | FC2_HEARTBEAT_TIMEOUT 348 | 349 | ctypedef _fc2GigEPropertyType fc2GigEPropertyType 350 | 351 | cdef enum _fc2StatisticsChannel: 352 | FC2_STATISTICS_GREY 353 | FC2_STATISTICS_RED 354 | FC2_STATISTICS_GREEN 355 | FC2_STATISTICS_BLUE 356 | FC2_STATISTICS_HUE 357 | FC2_STATISTICS_SATURATION 358 | FC2_STATISTICS_LIGHTNESS 359 | FC2_STATISTICS_FORCE_32BITS 360 | 361 | ctypedef _fc2StatisticsChannel fc2StatisticsChannel 362 | 363 | cdef enum _fc2OSType: 364 | FC2_WINDOWS_X86 365 | FC2_WINDOWS_X64 366 | FC2_LINUX_X86 367 | FC2_LINUX_X64 368 | FC2_MAC 369 | FC2_UNKNOWN_OS 370 | FC2_OSTYPE_FORCE_32BITS 371 | 372 | ctypedef _fc2OSType fc2OSType 373 | 374 | cdef enum _fc2ByteOrder: 375 | FC2_BYTE_ORDER_LITTLE_ENDIAN 376 | FC2_BYTE_ORDER_BIG_ENDIAN 377 | FC2_BYTE_ORDER_FORCE_32BITS 378 | 379 | ctypedef _fc2ByteOrder fc2ByteOrder 380 | 381 | cdef struct _fc2Image: 382 | unsigned int rows 383 | unsigned int cols 384 | unsigned int stride 385 | unsigned char *pData 386 | unsigned int dataSize 387 | unsigned int receivedDataSize 388 | fc2PixelFormat format 389 | fc2BayerTileFormat bayerFormat 390 | fc2ImageImpl imageImpl 391 | 392 | ctypedef _fc2Image fc2Image 393 | 394 | cdef struct _fc2SystemInfo: 395 | fc2OSType osType 396 | char osDescription[512] 397 | fc2ByteOrder byteOrder 398 | size_t sysMemSize 399 | char cpuDescription[512] 400 | size_t numCpuCores 401 | char driverList[512] 402 | char libraryList[512] 403 | char gpuDescription[512] 404 | size_t screenWidth 405 | size_t screenHeight 406 | unsigned int reserved[16] 407 | 408 | ctypedef _fc2SystemInfo fc2SystemInfo 409 | 410 | cdef struct _fc2Version: 411 | unsigned int major 412 | unsigned int minor 413 | unsigned int type 414 | unsigned int build 415 | 416 | ctypedef _fc2Version fc2Version 417 | 418 | cdef struct _fc2Config: 419 | unsigned int numBuffers 420 | unsigned int numImageNotifications 421 | unsigned int minNumImageNotifications 422 | int grabTimeout 423 | fc2GrabMode grabMode 424 | BOOL highPerformanceRetrieveBuffer 425 | fc2BusSpeed isochBusSpeed 426 | fc2BusSpeed asyncBusSpeed 427 | fc2BandwidthAllocation bandwidthAllocation 428 | unsigned int registerTimeoutRetries 429 | unsigned int registerTimeout 430 | unsigned int reserved[16] 431 | 432 | ctypedef _fc2Config fc2Config 433 | 434 | cdef struct _fc2PropertyInfo: 435 | fc2PropertyType type 436 | BOOL present 437 | BOOL autoSupported 438 | BOOL manualSupported 439 | BOOL onOffSupported 440 | BOOL onePushSupported 441 | BOOL absValSupported 442 | BOOL readOutSupported 443 | unsigned int min 444 | unsigned int max 445 | float absMin 446 | float absMax 447 | char pUnits[512] 448 | char pUnitAbbr[512] 449 | unsigned int reserved[8] 450 | 451 | ctypedef _fc2PropertyInfo fc2TriggerDelayInfo 452 | 453 | ctypedef _fc2PropertyInfo fc2PropertyInfo 454 | 455 | cdef struct _Property: 456 | fc2PropertyType type 457 | BOOL present 458 | BOOL absControl 459 | BOOL onePush 460 | BOOL onOff 461 | BOOL autoManualMode 462 | unsigned int valueA 463 | unsigned int valueB 464 | float absValue 465 | unsigned int reserved[8] 466 | 467 | ctypedef _Property fc2TriggerDelay 468 | 469 | ctypedef _Property fc2Property 470 | 471 | cdef struct _fc2TriggerModeInfo: 472 | BOOL present 473 | BOOL readOutSupported 474 | BOOL onOffSupported 475 | BOOL polaritySupported 476 | BOOL valueReadable 477 | unsigned int sourceMask 478 | BOOL softwareTriggerSupported 479 | unsigned int modeMask 480 | unsigned int reserved[8] 481 | 482 | ctypedef _fc2TriggerModeInfo fc2TriggerModeInfo 483 | 484 | cdef struct _fc2TriggerMode: 485 | BOOL onOff 486 | unsigned int polarity 487 | unsigned int source 488 | unsigned int mode 489 | unsigned int parameter 490 | unsigned int reserved[8] 491 | 492 | ctypedef _fc2TriggerMode fc2TriggerMode 493 | 494 | cdef struct _fc2StrobeInfo: 495 | unsigned int source 496 | BOOL present 497 | BOOL readOutSupported 498 | BOOL onOffSupported 499 | BOOL polaritySupported 500 | float minValue 501 | float maxValue 502 | unsigned int reserved[8] 503 | 504 | ctypedef _fc2StrobeInfo fc2StrobeInfo 505 | 506 | cdef struct _fc2StrobeControl: 507 | unsigned int source 508 | BOOL onOff 509 | unsigned int polarity 510 | float delay 511 | float duration 512 | unsigned int reserved[8] 513 | 514 | ctypedef _fc2StrobeControl fc2StrobeControl 515 | 516 | cdef struct _fc2Format7ImageSettings: 517 | fc2Mode mode 518 | unsigned int offsetX 519 | unsigned int offsetY 520 | unsigned int width 521 | unsigned int height 522 | fc2PixelFormat pixelFormat 523 | unsigned int reserved[8] 524 | 525 | ctypedef _fc2Format7ImageSettings fc2Format7ImageSettings 526 | 527 | cdef struct _fc2Format7Info: 528 | fc2Mode mode 529 | unsigned int maxWidth 530 | unsigned int maxHeight 531 | unsigned int offsetHStepSize 532 | unsigned int offsetVStepSize 533 | unsigned int imageHStepSize 534 | unsigned int imageVStepSize 535 | unsigned int pixelFormatBitField 536 | unsigned int vendorPixelFormatBitField 537 | unsigned int packetSize 538 | unsigned int minPacketSize 539 | unsigned int maxPacketSize 540 | float percentage 541 | unsigned int reserved[16] 542 | 543 | ctypedef _fc2Format7Info fc2Format7Info 544 | 545 | cdef struct _fc2Format7PacketInfo: 546 | unsigned int recommendedBytesPerPacket 547 | unsigned int maxBytesPerPacket 548 | unsigned int unitBytesPerPacket 549 | unsigned int reserved[8] 550 | 551 | ctypedef _fc2Format7PacketInfo fc2Format7PacketInfo 552 | 553 | cdef struct _fc2IPAddress: 554 | unsigned char octets[4] 555 | 556 | ctypedef _fc2IPAddress fc2IPAddress 557 | 558 | cdef struct _fc2MACAddress: 559 | unsigned char octets[6] 560 | 561 | ctypedef _fc2MACAddress fc2MACAddress 562 | 563 | cdef struct _fc2GigEProperty: 564 | fc2GigEPropertyType propType 565 | BOOL isReadable 566 | BOOL isWritable 567 | unsigned int min 568 | unsigned int max 569 | unsigned int value 570 | unsigned int reserved[8] 571 | 572 | ctypedef _fc2GigEProperty fc2GigEProperty 573 | 574 | cdef struct _fc2GigEStreamChannel: 575 | unsigned int networkInterfaceIndex 576 | unsigned int hostPost 577 | BOOL doNotFragment 578 | unsigned int packetSize 579 | unsigned int interPacketDelay 580 | fc2IPAddress destinationIpAddress 581 | unsigned int sourcePort 582 | unsigned int reserved[8] 583 | 584 | ctypedef _fc2GigEStreamChannel fc2GigEStreamChannel 585 | 586 | cdef struct _fc2GigEConfig: 587 | BOOL enablePacketResend 588 | unsigned int timeoutForPacketResend 589 | unsigned int maxPacketsToResend 590 | unsigned int reserved[8] 591 | 592 | ctypedef _fc2GigEConfig fc2GigEConfig 593 | 594 | cdef struct _fc2GigEImageSettingsInfo: 595 | unsigned int maxWidth 596 | unsigned int maxHeight 597 | unsigned int offsetHStepSize 598 | unsigned int offsetVStepSize 599 | unsigned int imageHStepSize 600 | unsigned int imageVStepSize 601 | unsigned int pixelFormatBitField 602 | unsigned int vendorPixelFormatBitField 603 | unsigned int reserved[16] 604 | 605 | ctypedef _fc2GigEImageSettingsInfo fc2GigEImageSettingsInfo 606 | 607 | cdef struct _fc2GigEImageSettings: 608 | unsigned int offsetX 609 | unsigned int offsetY 610 | unsigned int width 611 | unsigned int height 612 | fc2PixelFormat pixelFormat 613 | unsigned int reserved[8] 614 | 615 | ctypedef _fc2GigEImageSettings fc2GigEImageSettings 616 | 617 | cdef struct _fc2TimeStamp: 618 | long long int seconds 619 | unsigned int microSeconds 620 | unsigned int cycleSeconds 621 | unsigned int cycleCount 622 | unsigned int cycleOffset 623 | unsigned int reserved[8] 624 | 625 | ctypedef _fc2TimeStamp fc2TimeStamp 626 | 627 | cdef struct _fc2ConfigROM: 628 | unsigned int nodeVendorId 629 | unsigned int chipIdHi 630 | unsigned int chipIdLo 631 | unsigned int unitSpecId 632 | unsigned int unitSWVer 633 | unsigned int unitSubSWVer 634 | unsigned int vendorUniqueInfo_0 635 | unsigned int vendorUniqueInfo_1 636 | unsigned int vendorUniqueInfo_2 637 | unsigned int vendorUniqueInfo_3 638 | char pszKeyword[512] 639 | unsigned int reserved[16] 640 | 641 | ctypedef _fc2ConfigROM fc2ConfigROM 642 | 643 | cdef struct _fc2CameraInfo: 644 | unsigned int serialNumber 645 | fc2InterfaceType interfaceType 646 | fc2DriverType driverType 647 | BOOL isColorCamera 648 | char modelName[512] 649 | char vendorName[512] 650 | char sensorInfo[512] 651 | char sensorResolution[512] 652 | char driverName[512] 653 | char firmwareVersion[512] 654 | char firmwareBuildTime[512] 655 | fc2BusSpeed maximumBusSpeed 656 | fc2PCIeBusSpeed pcieBusSpeed 657 | fc2BayerTileFormat bayerTileFormat 658 | short unsigned int busNumber 659 | short unsigned int nodeNumber 660 | unsigned int iidcVer 661 | fc2ConfigROM configROM 662 | unsigned int gigEMajorVersion 663 | unsigned int gigEMinorVersion 664 | char userDefinedName[512] 665 | char xmlURL1[512] 666 | char xmlURL2[512] 667 | fc2MACAddress macAddress 668 | fc2IPAddress ipAddress 669 | fc2IPAddress subnetMask 670 | fc2IPAddress defaultGateway 671 | unsigned int reserved[16] 672 | 673 | ctypedef _fc2CameraInfo fc2CameraInfo 674 | 675 | cdef struct _fc2EmbeddedImageInfoProperty: 676 | BOOL available 677 | BOOL onOff 678 | 679 | ctypedef _fc2EmbeddedImageInfoProperty fc2EmbeddedImageInfoProperty 680 | 681 | cdef struct _fc2EmbeddedImageInfo: 682 | fc2EmbeddedImageInfoProperty timestamp 683 | fc2EmbeddedImageInfoProperty gain 684 | fc2EmbeddedImageInfoProperty shutter 685 | fc2EmbeddedImageInfoProperty brightness 686 | fc2EmbeddedImageInfoProperty exposure 687 | fc2EmbeddedImageInfoProperty whiteBalance 688 | fc2EmbeddedImageInfoProperty frameCounter 689 | fc2EmbeddedImageInfoProperty strobePattern 690 | fc2EmbeddedImageInfoProperty GPIOPinState 691 | fc2EmbeddedImageInfoProperty ROIPosition 692 | 693 | ctypedef _fc2EmbeddedImageInfo fc2EmbeddedImageInfo 694 | 695 | cdef struct _fc2ImageMetadata: 696 | unsigned int embeddedTimeStamp 697 | unsigned int embeddedGain 698 | unsigned int embeddedShutter 699 | unsigned int embeddedBrightness 700 | unsigned int embeddedExposure 701 | unsigned int embeddedWhiteBalance 702 | unsigned int embeddedFrameCounter 703 | unsigned int embeddedStrobePattern 704 | unsigned int embeddedGPIOPinState 705 | unsigned int embeddedROIPosition 706 | unsigned int reserved[31] 707 | 708 | ctypedef _fc2ImageMetadata fc2ImageMetadata 709 | 710 | cdef struct _fc2LUTData: 711 | BOOL supported 712 | BOOL enabled 713 | unsigned int numBanks 714 | unsigned int numChannels 715 | unsigned int inputBitDepth 716 | unsigned int outputBitDepth 717 | unsigned int numEntries 718 | unsigned int reserved[8] 719 | 720 | ctypedef _fc2LUTData fc2LUTData 721 | 722 | cdef struct _fc2PNGOption: 723 | BOOL interlaced 724 | unsigned int compressionLevel 725 | unsigned int reserved[16] 726 | 727 | ctypedef _fc2PNGOption fc2PNGOption 728 | 729 | cdef struct _fc2PPMOption: 730 | BOOL binaryFile 731 | unsigned int reserved[16] 732 | 733 | ctypedef _fc2PPMOption fc2PPMOption 734 | 735 | cdef struct _fc2PGMOption: 736 | BOOL binaryFile 737 | unsigned int reserved[16] 738 | 739 | ctypedef _fc2PGMOption fc2PGMOption 740 | 741 | cdef enum _fc2TIFFCompressionMethod: 742 | FC2_TIFF_NONE 743 | FC2_TIFF_PACKBITS 744 | FC2_TIFF_DEFLATE 745 | FC2_TIFF_ADOBE_DEFLATE 746 | FC2_TIFF_CCITTFAX3 747 | FC2_TIFF_CCITTFAX4 748 | FC2_TIFF_LZW 749 | FC2_TIFF_JPEG 750 | 751 | ctypedef _fc2TIFFCompressionMethod fc2TIFFCompressionMethod 752 | 753 | cdef struct _fc2TIFFOption: 754 | fc2TIFFCompressionMethod compression 755 | unsigned int reserved[16] 756 | 757 | ctypedef _fc2TIFFOption fc2TIFFOption 758 | 759 | cdef struct _fc2JPEGOption: 760 | BOOL progressive 761 | unsigned int quality 762 | unsigned int reserved[16] 763 | 764 | ctypedef _fc2JPEGOption fc2JPEGOption 765 | 766 | cdef struct _fc2JPG2Option: 767 | unsigned int quality 768 | unsigned int reserved[16] 769 | 770 | ctypedef _fc2JPG2Option fc2JPG2Option 771 | 772 | cdef struct _fc2AVIOption: 773 | float frameRate 774 | unsigned int reserved[256] 775 | 776 | ctypedef _fc2AVIOption fc2AVIOption 777 | 778 | cdef struct _fc2MJPGOption: 779 | float frameRate 780 | unsigned int quality 781 | unsigned int reserved[256] 782 | 783 | ctypedef _fc2MJPGOption fc2MJPGOption 784 | 785 | cdef struct _fc2H264Option: 786 | float frameRate 787 | unsigned int width 788 | unsigned int height 789 | unsigned int bitrate 790 | unsigned int reserved[256] 791 | 792 | ctypedef _fc2H264Option fc2H264Option 793 | 794 | ctypedef void *fc2CallbackHandle 795 | 796 | ctypedef void (*fc2BusEventCallback)(void *, unsigned int) 797 | 798 | ctypedef void (*fc2ImageEventCallback)(fc2Image *, void *) 799 | 800 | ctypedef void (*fc2AsyncCommandCallback)(fc2Error, void *) 801 | 802 | 803 | -------------------------------------------------------------------------------- /src/_FlyCapture2_C.pxd: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # pyflycapture2 - python bindings for libflycapture2_c 4 | # Copyright (C) 2012 Robert Jordens 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | from _FlyCapture2Defs_C cimport * 20 | 21 | # This code was automatically generated by CWrap version 0.0.0 22 | 23 | cdef extern from "FlyCapture2_C.h": 24 | 25 | fc2Error fc2CreateContext(fc2Context *pContext) nogil 26 | 27 | fc2Error fc2CreateGigEContext(fc2Context *pContext) nogil 28 | 29 | fc2Error fc2DestroyContext(fc2Context context) nogil 30 | 31 | fc2Error fc2FireBusReset(fc2Context context, fc2PGRGuid *pGuid) nogil 32 | 33 | fc2Error fc2GetNumOfCameras(fc2Context context, unsigned int *pNumCameras) nogil 34 | 35 | fc2Error fc2GetCameraFromIndex(fc2Context context, unsigned int index, fc2PGRGuid *pGuid) nogil 36 | 37 | fc2Error fc2GetCameraFromSerialNumber(fc2Context context, unsigned int serialNumber, fc2PGRGuid *pGuid) nogil 38 | 39 | fc2Error fc2GetCameraSerialNumberFromIndex(fc2Context context, unsigned int index, unsigned int *pSerialNumber) nogil 40 | 41 | fc2Error fc2GetInterfaceTypeFromGuid(fc2Context context, fc2PGRGuid *pGuid, fc2InterfaceType *pInterfaceType) nogil 42 | 43 | fc2Error fc2GetNumOfDevices(fc2Context context, unsigned int *pNumDevices) nogil 44 | 45 | fc2Error fc2GetDeviceFromIndex(fc2Context context, unsigned int index, fc2PGRGuid *pGuid) nogil 46 | 47 | fc2Error fc2RegisterCallback(fc2Context context, fc2BusEventCallback enumCallback, fc2BusCallbackType callbackType, void *pParameter, fc2CallbackHandle *pCallbackHandle) nogil 48 | 49 | fc2Error fc2UnregisterCallback(fc2Context context, fc2CallbackHandle callbackHandle) nogil 50 | 51 | fc2Error fc2RescanBus(fc2Context context) nogil 52 | 53 | fc2Error fc2ForceIPAddressToCamera(fc2Context context, fc2MACAddress macAddress, fc2IPAddress ipAddress, fc2IPAddress subnetMask, fc2IPAddress defaultGateway) nogil 54 | 55 | fc2Error fc2DiscoverGigECameras(fc2Context context, fc2CameraInfo *gigECameras, unsigned int *arraySize) nogil 56 | 57 | fc2Error fc2WriteRegister(fc2Context context, unsigned int address, unsigned int value) nogil 58 | 59 | fc2Error fc2WriteRegisterBroadcast(fc2Context context, unsigned int address, unsigned int value) nogil 60 | 61 | fc2Error fc2ReadRegister(fc2Context context, unsigned int address, unsigned int *pValue) nogil 62 | 63 | fc2Error fc2WriteRegisterBlock(fc2Context context, short unsigned int addressHigh, unsigned int addressLow, unsigned int *pBuffer, unsigned int length) nogil 64 | 65 | fc2Error fc2ReadRegisterBlock(fc2Context context, short unsigned int addressHigh, unsigned int addressLow, unsigned int *pBuffer, unsigned int length) nogil 66 | 67 | fc2Error fc2Connect(fc2Context context, fc2PGRGuid *guid) nogil 68 | 69 | fc2Error fc2Disconnect(fc2Context context) nogil 70 | 71 | fc2Error fc2SetCallback(fc2Context context, fc2ImageEventCallback pCallbackFn, void *pCallbackData) nogil 72 | 73 | fc2Error fc2StartCapture(fc2Context context) nogil 74 | 75 | fc2Error fc2StartCaptureCallback(fc2Context context, fc2ImageEventCallback pCallbackFn, void *pCallbackData) nogil 76 | 77 | fc2Error fc2StartSyncCapture(unsigned int numCameras, fc2Context *pContexts) nogil 78 | 79 | fc2Error fc2StartSyncCaptureCallback(unsigned int numCameras, fc2Context *pContexts, fc2ImageEventCallback *pCallbackFns, void **pCallbackDataArray) nogil 80 | 81 | fc2Error fc2RetrieveBuffer(fc2Context context, fc2Image *pImage) nogil 82 | 83 | fc2Error fc2StopCapture(fc2Context context) nogil 84 | 85 | fc2Error fc2SetUserBuffers(fc2Context context, unsigned char *ppMemBuffers, int size, int nNumBuffers) nogil 86 | 87 | fc2Error fc2GetConfiguration(fc2Context context, fc2Config *config) nogil 88 | 89 | fc2Error fc2SetConfiguration(fc2Context context, fc2Config *config) nogil 90 | 91 | fc2Error fc2GetCameraInfo(fc2Context context, fc2CameraInfo *pCameraInfo) nogil 92 | 93 | fc2Error fc2GetPropertyInfo(fc2Context context, fc2PropertyInfo *propInfo) nogil 94 | 95 | fc2Error fc2GetProperty(fc2Context context, fc2Property *prop) nogil 96 | 97 | fc2Error fc2SetProperty(fc2Context context, fc2Property *prop) nogil 98 | 99 | fc2Error fc2SetPropertyBroadcast(fc2Context context, fc2Property *prop) nogil 100 | 101 | fc2Error fc2GetGPIOPinDirection(fc2Context context, unsigned int pin, unsigned int *pDirection) nogil 102 | 103 | fc2Error fc2SetGPIOPinDirection(fc2Context context, unsigned int pin, unsigned int direction) nogil 104 | 105 | fc2Error fc2SetGPIOPinDirectionBroadcast(fc2Context context, unsigned int pin, unsigned int direction) nogil 106 | 107 | fc2Error fc2GetTriggerModeInfo(fc2Context context, fc2TriggerModeInfo *triggerModeInfo) nogil 108 | 109 | fc2Error fc2GetTriggerMode(fc2Context context, fc2TriggerMode *triggerMode) nogil 110 | 111 | fc2Error fc2SetTriggerMode(fc2Context context, fc2TriggerMode *triggerMode) nogil 112 | 113 | fc2Error fc2SetTriggerModeBroadcast(fc2Context context, fc2TriggerMode *triggerMode) nogil 114 | 115 | fc2Error fc2FireSoftwareTrigger(fc2Context context) nogil 116 | 117 | fc2Error fc2FireSoftwareTriggerBroadcast(fc2Context context) nogil 118 | 119 | fc2Error fc2GetTriggerDelayInfo(fc2Context context, fc2TriggerDelayInfo *triggerDelayInfo) nogil 120 | 121 | fc2Error fc2GetTriggerDelay(fc2Context context, fc2TriggerDelay *triggerDelay) nogil 122 | 123 | fc2Error fc2SetTriggerDelay(fc2Context context, fc2TriggerDelay *triggerDelay) nogil 124 | 125 | fc2Error fc2SetTriggerDelayBroadcast(fc2Context context, fc2TriggerDelay *triggerDelay) nogil 126 | 127 | fc2Error fc2GetStrobeInfo(fc2Context context, fc2StrobeInfo *strobeInfo) nogil 128 | 129 | fc2Error fc2GetStrobe(fc2Context context, fc2StrobeControl *strobeControl) nogil 130 | 131 | fc2Error fc2SetStrobe(fc2Context context, fc2StrobeControl *strobeControl) nogil 132 | 133 | fc2Error fc2SetStrobeBroadcast(fc2Context context, fc2StrobeControl *strobeControl) nogil 134 | 135 | fc2Error fc2GetVideoModeAndFrameRateInfo(fc2Context context, fc2VideoMode videoMode, fc2FrameRate frameRate, BOOL *pSupported) nogil 136 | 137 | fc2Error fc2GetVideoModeAndFrameRate(fc2Context context, fc2VideoMode *videoMode, fc2FrameRate *frameRate) nogil 138 | 139 | fc2Error fc2SetVideoModeAndFrameRate(fc2Context context, fc2VideoMode videoMode, fc2FrameRate frameRate) nogil 140 | 141 | fc2Error fc2GetFormat7Info(fc2Context context, fc2Format7Info *info, BOOL *pSupported) nogil 142 | 143 | fc2Error fc2ValidateFormat7Settings(fc2Context context, fc2Format7ImageSettings *imageSettings, BOOL *settingsAreValid, fc2Format7PacketInfo *packetInfo) nogil 144 | 145 | fc2Error fc2GetFormat7Configuration(fc2Context context, fc2Format7ImageSettings *imageSettings, unsigned int *packetSize, float *percentage) nogil 146 | 147 | fc2Error fc2SetFormat7ConfigurationPacket(fc2Context context, fc2Format7ImageSettings *imageSettings, unsigned int packetSize) nogil 148 | 149 | fc2Error fc2SetFormat7Configuration(fc2Context context, fc2Format7ImageSettings *imageSettings, float percentSpeed) nogil 150 | 151 | fc2Error fc2WriteGVCPRegister(fc2Context context, unsigned int address, unsigned int value) nogil 152 | 153 | fc2Error fc2WriteGVCPRegisterBroadcast(fc2Context context, unsigned int address, unsigned int value) nogil 154 | 155 | fc2Error fc2ReadGVCPRegister(fc2Context context, unsigned int address, unsigned int *pValue) nogil 156 | 157 | fc2Error fc2WriteGVCPRegisterBlock(fc2Context context, unsigned int address, unsigned int *pBuffer, unsigned int length) nogil 158 | 159 | fc2Error fc2ReadGVCPRegisterBlock(fc2Context context, unsigned int address, unsigned int *pBuffer, unsigned int length) nogil 160 | 161 | fc2Error fc2WriteGVCPMemory(fc2Context context, unsigned int address, unsigned char *pBuffer, unsigned int length) nogil 162 | 163 | fc2Error fc2ReadGVCPMemory(fc2Context context, unsigned int address, unsigned char *pBuffer, unsigned int length) nogil 164 | 165 | fc2Error fc2GetGigEProperty(fc2Context context, fc2GigEProperty *pGigEProp) nogil 166 | 167 | fc2Error fc2SetGigEProperty(fc2Context context, fc2GigEProperty *pGigEProp) nogil 168 | 169 | fc2Error fc2QueryGigEImagingMode(fc2Context context, fc2Mode mode, BOOL *isSupported) nogil 170 | 171 | fc2Error fc2GetGigEImagingMode(fc2Context context, fc2Mode *mode) nogil 172 | 173 | fc2Error fc2SetGigEImagingMode(fc2Context context, fc2Mode mode) nogil 174 | 175 | fc2Error fc2GetGigEImageSettingsInfo(fc2Context context, fc2GigEImageSettingsInfo *pInfo) nogil 176 | 177 | fc2Error fc2GetGigEImageSettings(fc2Context context, fc2GigEImageSettings *pImageSettings) nogil 178 | 179 | fc2Error fc2SetGigEImageSettings(fc2Context context, fc2GigEImageSettings *pImageSettings) nogil 180 | 181 | fc2Error fc2GetGigEImageBinningSettings(fc2Context context, unsigned int *horzBinnningValue, unsigned int *vertBinnningValue) nogil 182 | 183 | fc2Error fc2SetGigEImageBinningSettings(fc2Context context, unsigned int horzBinnningValue, unsigned int vertBinnningValue) nogil 184 | 185 | fc2Error fc2GetNumStreamChannels(fc2Context context, unsigned int *numChannels) nogil 186 | 187 | fc2Error fc2GetGigEStreamChannelInfo(fc2Context context, unsigned int channel, fc2GigEStreamChannel *pChannel) nogil 188 | 189 | fc2Error fc2SetGigEStreamChannelInfo(fc2Context context, unsigned int channel, fc2GigEStreamChannel *pChannel) nogil 190 | 191 | fc2Error fc2GetLUTInfo(fc2Context context, fc2LUTData *pData) nogil 192 | 193 | fc2Error fc2GetLUTBankInfo(fc2Context context, unsigned int bank, BOOL *pReadSupported, BOOL *pWriteSupported) nogil 194 | 195 | fc2Error fc2GetActiveLUTBank(fc2Context context, unsigned int *pActiveBank) nogil 196 | 197 | fc2Error fc2SetActiveLUTBank(fc2Context context, unsigned int activeBank) nogil 198 | 199 | fc2Error fc2EnableLUT(fc2Context context, BOOL on) nogil 200 | 201 | fc2Error fc2GetLUTChannel(fc2Context context, unsigned int bank, unsigned int channel, unsigned int sizeEntries, unsigned int *pEntries) nogil 202 | 203 | fc2Error fc2SetLUTChannel(fc2Context context, unsigned int bank, unsigned int channel, unsigned int sizeEntries, unsigned int *pEntries) nogil 204 | 205 | fc2Error fc2GetMemoryChannel(fc2Context context, unsigned int *pCurrentChannel) nogil 206 | 207 | fc2Error fc2SaveToMemoryChannel(fc2Context context, unsigned int channel) nogil 208 | 209 | fc2Error fc2RestoreFromMemoryChannel(fc2Context context, unsigned int channel) nogil 210 | 211 | fc2Error fc2GetMemoryChannelInfo(fc2Context context, unsigned int *pNumChannels) nogil 212 | 213 | fc2Error fc2GetEmbeddedImageInfo(fc2Context context, fc2EmbeddedImageInfo *pInfo) nogil 214 | 215 | fc2Error fc2SetEmbeddedImageInfo(fc2Context context, fc2EmbeddedImageInfo *pInfo) nogil 216 | 217 | char *fc2GetRegisterString(unsigned int registerVal) nogil 218 | 219 | fc2Error fc2CreateImage(fc2Image *pImage) nogil 220 | 221 | fc2Error fc2DestroyImage(fc2Image *image) nogil 222 | 223 | fc2Error fc2SetDefaultColorProcessing(fc2ColorProcessingAlgorithm defaultMethod) nogil 224 | 225 | fc2Error fc2GetDefaultColorProcessing(fc2ColorProcessingAlgorithm *pDefaultMethod) nogil 226 | 227 | fc2Error fc2SetDefaultOutputFormat(fc2PixelFormat format) nogil 228 | 229 | fc2Error fc2GetDefaultOutputFormat(fc2PixelFormat *pFormat) nogil 230 | 231 | fc2Error fc2DetermineBitsPerPixel(fc2PixelFormat format, unsigned int *pBitsPerPixel) nogil 232 | 233 | fc2Error fc2SaveImage(fc2Image *pImage, char *pFilename, fc2ImageFileFormat format) nogil 234 | 235 | fc2Error fc2SaveImageWithOption(fc2Image *pImage, char *pFilename, fc2ImageFileFormat format, void *pOption) nogil 236 | 237 | fc2Error fc2ConvertImage(fc2Image *pImageIn, fc2Image *pImageOut) nogil 238 | 239 | fc2Error fc2ConvertImageTo(fc2PixelFormat format, fc2Image *pImageIn, fc2Image *pImageOut) nogil 240 | 241 | fc2Error fc2GetImageData(fc2Image *pImage, unsigned char **ppData) nogil 242 | 243 | fc2Error fc2SetImageData(fc2Image *pImage, unsigned char *pData, unsigned int dataSize) nogil 244 | 245 | fc2Error fc2SetImageDimensions(fc2Image *pImage, unsigned int rows, unsigned int cols, unsigned int stride, fc2PixelFormat pixelFormat, fc2BayerTileFormat bayerFormat) nogil 246 | 247 | fc2TimeStamp fc2GetImageTimeStamp(fc2Image *pImage) nogil 248 | 249 | fc2Error fc2CalculateImageStatistics(fc2Image *pImage, fc2ImageStatisticsContext *pImageStatisticsContext) nogil 250 | 251 | fc2Error fc2CreateImageStatistics(fc2ImageStatisticsContext *pImageStatisticsContext) nogil 252 | 253 | fc2Error fc2DestroyImageStatistics(fc2ImageStatisticsContext imageStatisticsContext) nogil 254 | 255 | fc2Error fc2GetImageStatistics(fc2ImageStatisticsContext imageStatisticsContext, fc2StatisticsChannel channel, unsigned int *pRangeMin, unsigned int *pRangeMax, unsigned int *pPixelValueMin, unsigned int *pPixelValueMax, unsigned int *pNumPixelValues, float *pPixelValueMean, int **ppHistogram) nogil 256 | 257 | fc2Error fc2CreateAVI(fc2AVIContext *pAVIContext) nogil 258 | 259 | fc2Error fc2AVIOpen(fc2AVIContext AVIContext, char *pFileName, fc2AVIOption *pOption) nogil 260 | 261 | fc2Error fc2AVIAppend(fc2AVIContext AVIContext, fc2Image *pImage) nogil 262 | 263 | fc2Error fc2AVIClose(fc2AVIContext AVIContext) nogil 264 | 265 | fc2Error fc2DestroyAVI(fc2AVIContext AVIContext) nogil 266 | 267 | fc2Error fc2GetSystemInfo(fc2SystemInfo *pSystemInfo) nogil 268 | 269 | fc2Error fc2GetLibraryVersion(fc2Version *pVersion) nogil 270 | 271 | fc2Error fc2LaunchBrowser(char *pAddress) nogil 272 | 273 | fc2Error fc2LaunchHelp(char *pFileName) nogil 274 | 275 | fc2Error fc2LaunchCommand(char *pCommand) nogil 276 | 277 | fc2Error fc2LaunchCommandAsync(char *pCommand, fc2AsyncCommandCallback pCallback, void *pUserData) nogil 278 | 279 | char *fc2ErrorToDescription(fc2Error error) nogil 280 | -------------------------------------------------------------------------------- /src/flycapture2.pyx: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # pyflycapture2 - python bindings for libflycapture2_c 4 | # Copyright (C) 2012 Robert Jordens 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | from _FlyCapture2_C cimport * 20 | include "flycapture2_enums.pxi" 21 | 22 | import numpy as np 23 | cimport numpy as np 24 | 25 | from cpython cimport PyObject, Py_INCREF 26 | from libc.stdlib cimport malloc, free 27 | 28 | cdef extern from "numpy/arrayobject.h": 29 | object PyArray_NewFromDescr(object subtype, np.dtype descr, 30 | int nd, np.npy_intp* dims, 31 | np.npy_intp* strides, 32 | void* data, int flags, object obj) 33 | 34 | np.import_array() 35 | 36 | cdef dict pixel_fmts = { 37 | 'mono8': FC2_PIXEL_FORMAT_MONO8, 38 | 'yuv411': FC2_PIXEL_FORMAT_411YUV8, 39 | 'yuv422': FC2_PIXEL_FORMAT_422YUV8, 40 | 'yuv444': FC2_PIXEL_FORMAT_444YUV8, 41 | 'rgb8': FC2_PIXEL_FORMAT_RGB8, 42 | 'mono16': FC2_PIXEL_FORMAT_MONO16, 43 | 'rgb16': FC2_PIXEL_FORMAT_RGB16, 44 | 's_mono16': FC2_PIXEL_FORMAT_S_MONO16, 45 | 's_rgb16': FC2_PIXEL_FORMAT_S_RGB16, 46 | 'raw8': FC2_PIXEL_FORMAT_RAW8, 47 | 'raw16': FC2_PIXEL_FORMAT_RAW16, 48 | 'mono12': FC2_PIXEL_FORMAT_MONO12, 49 | 'raw12': FC2_PIXEL_FORMAT_RAW12, 50 | 'bgr': FC2_PIXEL_FORMAT_BGR, 51 | 'bgru': FC2_PIXEL_FORMAT_BGRU, 52 | 'rgb': FC2_PIXEL_FORMAT_RGB, 53 | 'rgbu': FC2_PIXEL_FORMAT_RGBU, 54 | 'bgr16': FC2_PIXEL_FORMAT_BGR16, 55 | 'yuv422_jpeg': FC2_PIXEL_FORMAT_422YUV8_JPEG, 56 | } 57 | 58 | cdef dict pixel_fmts_inv = {v: k for k, v in pixel_fmts.items()} 59 | 60 | class ApiError(Exception): 61 | pass 62 | 63 | cdef raise_error(fc2Error e): 64 | if e != FC2_ERROR_OK: 65 | raise ApiError(e, fc2ErrorToDescription(e)) 66 | 67 | def get_library_version(): 68 | cdef fc2Version v 69 | cdef fc2Error r 70 | with nogil: 71 | r = fc2GetLibraryVersion(&v) 72 | raise_error(r) 73 | return {"major": v.major, "minor": v.minor, 74 | "type": v.type, "build": v.build} 75 | 76 | cdef class Context: 77 | cdef fc2Context ctx 78 | def __cinit__(self, gige_context=False): 79 | cdef fc2Error r 80 | if gige_context: 81 | with nogil: 82 | r = fc2CreateGigEContext(&self.ctx) 83 | raise_error(r) 84 | else: 85 | with nogil: 86 | r = fc2CreateContext(&self.ctx) 87 | raise_error(r) 88 | 89 | def __dealloc__(self): 90 | cdef fc2Error r 91 | with nogil: 92 | r = fc2DestroyContext(self.ctx) 93 | raise_error(r) 94 | 95 | def get_num_of_cameras(self): 96 | cdef unsigned int n 97 | cdef fc2Error r 98 | with nogil: 99 | r = fc2GetNumOfCameras(self.ctx, &n) 100 | raise_error(r) 101 | return n 102 | 103 | def get_num_of_devices(self): 104 | cdef unsigned int n 105 | cdef fc2Error r 106 | with nogil: 107 | r = fc2GetNumOfDevices(self.ctx, &n) 108 | raise_error(r) 109 | return n 110 | 111 | def get_camera_from_index(self, unsigned int index): 112 | cdef fc2PGRGuid g 113 | cdef fc2Error r 114 | with nogil: 115 | r = fc2GetCameraFromIndex(self.ctx, index, &g) 116 | raise_error(r) 117 | return g.value[0], g.value[1], g.value[2], g.value[3] 118 | 119 | def get_camera_from_serial_number(self, unsigned int serial_number): 120 | cdef fc2PGRGuid g 121 | cdef fc2Error r 122 | with nogil: 123 | r = fc2GetCameraFromSerialNumber(self.ctx, serial_number, &g) 124 | raise_error(r) 125 | return g.value[0], g.value[1], g.value[2], g.value[3] 126 | 127 | def get_camera_info(self): 128 | interface_dict = {0: "IEEE1394", 1: "USB2", 2: "USB3", 3: "GIGE", 4: "UNKNOWN"} 129 | cdef fc2CameraInfo i 130 | cdef fc2Error r 131 | with nogil: 132 | r = fc2GetCameraInfo(self.ctx, &i) 133 | raise_error(r) 134 | ret = {"serial_number": i.serialNumber, 135 | "model_name": i.modelName, 136 | "vendor_name": i.vendorName, 137 | "sensor_info": i.sensorInfo, 138 | "sensor_resolution": i.sensorResolution, 139 | "driver_name" : i.driverName, 140 | "interface" : interface_dict[i.interfaceType], 141 | "firmware_version": i.firmwareVersion, 142 | "firmware_build_time": i.firmwareBuildTime,} 143 | return ret 144 | 145 | def connect(self, unsigned int a, unsigned int b, 146 | unsigned int c, unsigned int d): 147 | cdef fc2PGRGuid g 148 | cdef fc2Error r 149 | g.value[0], g.value[1], g.value[2], g.value[3] = a, b, c, d 150 | with nogil: 151 | r = fc2Connect(self.ctx, &g) 152 | raise_error(r) 153 | 154 | def disconnect(self): 155 | cdef fc2Error r 156 | with nogil: 157 | r = fc2Disconnect(self.ctx) 158 | raise_error(r) 159 | 160 | def get_video_mode_and_frame_rate_info(self, 161 | fc2VideoMode mode, fc2FrameRate framerate): 162 | cdef fc2Error r 163 | cdef BOOL supp 164 | with nogil: 165 | r = fc2GetVideoModeAndFrameRateInfo(self.ctx, mode, 166 | framerate, &supp) 167 | raise_error(r) 168 | return bool(supp) 169 | 170 | def get_video_mode_and_frame_rate(self): 171 | cdef fc2Error r 172 | cdef fc2VideoMode mode 173 | cdef fc2FrameRate framerate 174 | with nogil: 175 | r = fc2GetVideoModeAndFrameRate(self.ctx, &mode, &framerate) 176 | raise_error(r) 177 | return mode, framerate 178 | 179 | def set_video_mode_and_frame_rate(self, fc2VideoMode mode, 180 | fc2FrameRate framerate): 181 | cdef fc2Error r 182 | with nogil: 183 | r = fc2SetVideoModeAndFrameRate(self.ctx, mode, framerate) 184 | raise_error(r) 185 | 186 | def set_user_buffers(self, 187 | np.ndarray[np.uint8_t, ndim=2] buff not None): 188 | cdef fc2Error r 189 | r = fc2SetUserBuffers(self.ctx, buff.data, 190 | buff.shape[1], buff.shape[0]) 191 | raise_error(r) 192 | # TODO: INCREF buff 193 | 194 | def start_capture(self): 195 | cdef fc2Error r 196 | with nogil: 197 | r = fc2StartCapture(self.ctx) 198 | raise_error(r) 199 | 200 | def stop_capture(self): 201 | cdef fc2Error r 202 | with nogil: 203 | r = fc2StopCapture(self.ctx) 204 | raise_error(r) 205 | 206 | def retrieve_buffer(self, Image img=None): 207 | cdef fc2Error r 208 | if img is None: 209 | img = Image() 210 | with nogil: 211 | r = fc2RetrieveBuffer(self.ctx, &img.img) 212 | raise_error(r) 213 | return img 214 | 215 | def get_property_info(self, fc2PropertyType prop): 216 | cdef fc2PropertyInfo pi 217 | pi.type = prop 218 | cdef fc2Error r 219 | with nogil: 220 | r = fc2GetPropertyInfo(self.ctx, &pi) 221 | raise_error(r) 222 | return {"type": pi.type, 223 | "present": bool(pi.present), 224 | "auto_supported": bool(pi.autoSupported), 225 | "manual_supported": bool(pi.manualSupported), 226 | "on_off_supported": bool(pi.onOffSupported), 227 | "one_push_supported": bool(pi.onePushSupported), 228 | "abs_val_supported": bool(pi.absValSupported), 229 | "read_out_supported": bool(pi.readOutSupported), 230 | "min": pi.min, 231 | "max": pi.max, 232 | "abs_min": pi.absMin, 233 | "abs_max": pi.absMax, 234 | "units": pi.pUnits, 235 | "unit_abbr": pi.pUnitAbbr,} 236 | 237 | def get_property(self, fc2PropertyType type): 238 | cdef fc2Error r 239 | cdef fc2Property p 240 | p.type = type 241 | with nogil: 242 | r = fc2GetProperty(self.ctx, &p) 243 | raise_error(r) 244 | return {"type": p.type, 245 | "present": bool(p.present), 246 | "auto_manual_mode": bool(p.autoManualMode), 247 | "abs_control": bool(p.absControl), 248 | "on_off": bool(p.onOff), 249 | "one_push": bool(p.onePush), 250 | "abs_value": p.absValue, 251 | "value_a": p.valueA, 252 | "value_b": p.valueB,} 253 | 254 | def set_property(self, type, present, on_off, auto_manual_mode, 255 | abs_control, one_push, abs_value, value_a, value_b): 256 | cdef fc2Error r 257 | cdef fc2Property p 258 | p.type = type 259 | p.present = present 260 | p.autoManualMode = auto_manual_mode 261 | p.absControl = abs_control 262 | p.onOff = on_off 263 | p.onePush = one_push 264 | p.absValue = abs_value 265 | p.valueA = value_a 266 | p.valueB = value_b 267 | with nogil: 268 | r = fc2SetProperty(self.ctx, &p) 269 | raise_error(r) 270 | 271 | def get_trigger_mode(self): 272 | cdef fc2Error r 273 | cdef fc2TriggerMode tm 274 | with nogil: 275 | r = fc2GetTriggerMode(self.ctx, &tm) 276 | return {"on_off": bool(tm.onOff), 277 | "polarity": tm.polarity, 278 | "source": tm.source, 279 | "mode": tm.mode, 280 | "parameter": tm.parameter,} 281 | 282 | def set_trigger_mode(self, on_off, polarity, source, 283 | mode, parameter): 284 | cdef fc2Error r 285 | cdef fc2TriggerMode tm 286 | tm.onOff = on_off 287 | tm.polarity = polarity 288 | tm.source = source 289 | tm.mode = mode 290 | tm.parameter = parameter 291 | with nogil: 292 | r = fc2SetTriggerMode(self.ctx, &tm) 293 | raise_error(r) 294 | 295 | def get_strobe_mode(self): 296 | cdef fc2Error r 297 | cdef fc2StrobeControl ctl 298 | with nogil: 299 | r = fc2GetStrobe(self.ctx, &ctl) 300 | raise_error(r) 301 | return { 302 | 'source': ctl.source, 303 | 'on_off': bool(ctl.onOff), 304 | 'polarity': ctl.polarity, 305 | 'delay': ctl.delay, 306 | 'duration': ctl.duration, 307 | } 308 | 309 | def set_strobe_mode(self, source, on_off, polarity, delay, duration): 310 | cdef fc2Error r 311 | cdef fc2StrobeControl ctl 312 | ctl.source = source 313 | ctl.onOff = on_off 314 | ctl.polarity = polarity 315 | ctl.delay = delay 316 | ctl.duration = duration 317 | with nogil: 318 | r = fc2SetStrobe(self.ctx, &ctl) 319 | raise_error(r) 320 | 321 | def get_format7_info(self, mode): 322 | cdef fc2Error r 323 | cdef fc2Format7Info info 324 | cdef BOOL supported 325 | info.mode = mode 326 | with nogil: 327 | r = fc2GetFormat7Info(self.ctx, &info, &supported) 328 | raise_error(r) 329 | return {"mode": info.mode, 330 | "max_width": info.maxWidth, 331 | "max_height": info.maxHeight, 332 | "offset_h_step_size": info.offsetHStepSize, 333 | "offset_v_step_size": info.offsetVStepSize, 334 | "image_h_step_size": info.imageHStepSize, 335 | "image_v_step_size": info.imageVStepSize, 336 | "pixel_format_bit_field": info.pixelFormatBitField, 337 | "vendor_pixel_format_bit_field": info.vendorPixelFormatBitField, 338 | "packet_size": info.packetSize, 339 | "min_packet_size": info.minPacketSize, 340 | "max_packet_size": info.maxPacketSize, 341 | "percentage": info.percentage,}, supported 342 | 343 | def fire_software_trigger(self): 344 | cdef fc2Error r 345 | with nogil: 346 | r = fc2FireSoftwareTrigger(self.ctx) 347 | raise_error(r) 348 | 349 | def get_format7_configuration(self): 350 | cdef fc2Error r 351 | cdef fc2Format7ImageSettings s 352 | cdef unsigned packetSize 353 | cdef float percentage 354 | with nogil: 355 | r = fc2GetFormat7Configuration(self.ctx, &s, &packetSize, &percentage) 356 | raise_error(r) 357 | return {"mode": s.mode, 358 | "offset_x": s.offsetX, 359 | "offset_y": s.offsetY, 360 | "width": s.width, 361 | "height": s.height, 362 | "pixel_format": s.pixelFormat,} 363 | 364 | def set_format7_configuration(self, mode, offset_x, offset_y, width, height, pixel_format): 365 | cdef fc2Error r 366 | cdef fc2Format7ImageSettings s 367 | cdef float f = 100.0 368 | s.mode = mode 369 | s.offsetX = offset_x 370 | s.offsetY = offset_y 371 | s.width = width 372 | s.height = height 373 | s.pixelFormat = pixel_format 374 | with nogil: 375 | r = fc2SetFormat7Configuration(self.ctx, &s, f) 376 | raise_error(r) 377 | 378 | def get_configuration(self): 379 | cdef fc2Error r 380 | cdef fc2Config config 381 | with nogil: 382 | r = fc2GetConfiguration(self.ctx, &config) 383 | raise_error(r) 384 | return { 385 | "num_buffers": config.numBuffers, 386 | "num_image_notifications": config.numImageNotifications, 387 | "min_num_image_notifications": config.minNumImageNotifications, 388 | "grab_timeout": config.grabTimeout, 389 | "grab_mode": config.grabMode, 390 | "isoch_bus_speed": config.isochBusSpeed, 391 | "async_bus_speed": config.asyncBusSpeed, 392 | "bandwidth_allocation": config.bandwidthAllocation, 393 | "register_timeout_retries": config.registerTimeoutRetries, 394 | "register_timeout": config.registerTimeout, 395 | } 396 | 397 | def set_configuration(self, num_buffers, 398 | num_image_notifications, min_num_image_notifications, 399 | grab_timeout, grab_mode, 400 | isoch_bus_speed, async_bus_speed, 401 | bandwidth_allocation, 402 | register_timeout_retries, register_timeout): 403 | cdef fc2Error r 404 | cdef fc2Config config 405 | config.numBuffers = num_buffers 406 | config.numImageNotifications = num_image_notifications 407 | config.minNumImageNotifications = min_num_image_notifications 408 | config.grabTimeout = grab_timeout 409 | config.grabMode = grab_mode 410 | config.isochBusSpeed = isoch_bus_speed 411 | config.asyncBusSpeed = async_bus_speed 412 | config.bandwidthAllocation = bandwidth_allocation 413 | config.registerTimeoutRetries = register_timeout_retries 414 | config.registerTimeout = register_timeout 415 | with nogil: 416 | r = fc2SetConfiguration(self.ctx, &config) 417 | raise_error(r) 418 | 419 | def read_register(self, address): 420 | cdef fc2Error r 421 | cdef unsigned int func_address = address 422 | cdef unsigned int func_value 423 | 424 | with nogil: 425 | r = fc2ReadRegister(self.ctx, func_address, &func_value) 426 | raise_error(r) 427 | return func_value 428 | 429 | def write_register(self, address, value): 430 | cdef fc2Error r 431 | cdef unsigned int func_address = address 432 | cdef unsigned int func_value = value 433 | 434 | with nogil: 435 | r = fc2WriteRegister(self.ctx, func_address, func_value) 436 | raise_error(r) 437 | 438 | def rescan_bus(self): 439 | cdef fc2Error r 440 | with nogil: 441 | r = fc2RescanBus(self.ctx) 442 | raise_error(r) 443 | 444 | def discover_gige_cameras(self): 445 | cdef fc2Error error 446 | cdef fc2Error r 447 | cdef fc2CameraInfo cams[8] 448 | cdef fc2CameraInfo *pcams = NULL 449 | cdef unsigned int count = sizeof(cams) 450 | cdef int i 451 | 452 | with nogil: 453 | error = fc2DiscoverGigECameras(self.ctx, cams, &count) 454 | if error == FC2_ERROR_BUFFER_TOO_SMALL: 455 | pcams = malloc(count * sizeof(fc2CameraInfo)) 456 | if pcams == NULL: 457 | raise MemoryError() 458 | 459 | try: 460 | with nogil: 461 | r = fc2DiscoverGigECameras(self.ctx, pcams, &count) 462 | raise_error(r) 463 | return [pcams[i] for i in range(count)] 464 | finally: 465 | free(pcams) 466 | elif error != FC2_ERROR_OK: 467 | raise_error(error) 468 | else: 469 | return [cams[i] for i in range(count)] 470 | 471 | def query_gige_imaging_mode(self, mode): 472 | cdef fc2Error r 473 | cdef fc2Mode fcmode 474 | cdef BOOL supported = 0 475 | if mode >= FC2_NUM_MODES or mode < FC2_MODE_0: 476 | raise Exception('Unrecognized mode {}'.format(mode)) 477 | 478 | fcmode = mode 479 | with nogil: 480 | r = fc2QueryGigEImagingMode(self.ctx, fcmode, &supported) 481 | raise_error(r) 482 | return bool(supported) 483 | 484 | def get_gige_config(self): 485 | cdef fc2Error r 486 | cdef fc2GigEImageSettings settings 487 | 488 | with nogil: 489 | r = fc2GetGigEImageSettings(self.ctx, &settings) 490 | raise_error(r) 491 | return {'offset_x': settings.offsetX, 'offset_y': settings.offsetY, 492 | 'width': settings.width, 'height': settings.height, 493 | 'fmt': pixel_fmts_inv.get(settings.pixelFormat, 'unknown')} 494 | 495 | def set_gige_config(self, offset_x, offset_y, width, height, fmt): 496 | cdef fc2Error r 497 | cdef fc2GigEImageSettings settings 498 | if fmt not in pixel_fmts: 499 | raise Exception('{} not found in {}'.format(fmt, ', '.join(pixel_fmts.keys()))) 500 | 501 | settings.offsetX = offset_x 502 | settings.offsetY = offset_y 503 | settings.width = width 504 | settings.height = height 505 | settings.pixelFormat = pixel_fmts[fmt] 506 | with nogil: 507 | r = fc2SetGigEImageSettings(self.ctx, &settings) 508 | raise_error(r) 509 | 510 | def get_gige_num_streams(self): 511 | cdef fc2Error r 512 | cdef unsigned int value 513 | with nogil: 514 | r = fc2GetNumStreamChannels(self.ctx, &value) 515 | raise_error(r) 516 | return value 517 | 518 | def get_gige_stream_config(self, unsigned int chan): 519 | cdef fc2Error r 520 | cdef fc2GigEStreamChannel config 521 | cdef int i 522 | with nogil: 523 | r = fc2GetGigEStreamChannelInfo(self.ctx, chan, &config) 524 | raise_error(r) 525 | return { 526 | 'net_index': config.networkInterfaceIndex, 527 | 'frag': bool(config.doNotFragment), 528 | 'packet_size': config.packetSize, 529 | 'delay': config.interPacketDelay, 530 | 'dest_ip': [config.destinationIpAddress.octets[i] for i in range(4)], 531 | 'src_port': config.sourcePort} 532 | 533 | def set_gige_stream_config( self, unsigned int chan, net_index, frag, packet_size, delay, 534 | dest_ip, src_port): 535 | cdef fc2Error r 536 | cdef int i 537 | cdef fc2GigEStreamChannel config 538 | 539 | config.networkInterfaceIndex = net_index 540 | config.doNotFragment = frag 541 | config.packetSize = packet_size 542 | config.interPacketDelay = delay 543 | 544 | for i in range(4): 545 | config.destinationIpAddress.octets[i] = dest_ip[i] 546 | config.sourcePort = src_port 547 | 548 | with nogil: 549 | r = fc2SetGigEStreamChannelInfo(self.ctx, chan, &config) 550 | raise_error(r) 551 | 552 | 553 | cdef class Image: 554 | cdef fc2Image img 555 | cdef object fmt 556 | 557 | def __cinit__(self): 558 | cdef fc2Error r 559 | with nogil: 560 | r = fc2CreateImage(&self.img) 561 | raise_error(r) 562 | 563 | def __init__(self): 564 | self.fmt = None 565 | 566 | def __dealloc__(self): 567 | cdef fc2Error r 568 | with nogil: 569 | r = fc2DestroyImage(&self.img) 570 | raise_error(r) 571 | 572 | @staticmethod 573 | def get_default_color_processing(): 574 | cdef fc2ColorProcessingAlgorithm alg 575 | with nogil: 576 | r = fc2GetDefaultColorProcessing(&alg) 577 | raise_error(r) 578 | return alg 579 | 580 | @staticmethod 581 | def set_default_color_processing(fc2ColorProcessingAlgorithm alg): 582 | with nogil: 583 | r = fc2SetDefaultColorProcessing(alg) 584 | raise_error(r) 585 | 586 | def convert_to(self, fmt, Image dst=None): 587 | cdef fc2Error r 588 | cdef fc2PixelFormat _fmt 589 | _fmt = fmt 590 | if dst == None: 591 | dst = Image() 592 | with nogil: 593 | r = fc2ConvertImageTo(_fmt, &self.img, &dst.img) 594 | raise_error(r) 595 | return dst 596 | 597 | def __array__(self): 598 | cdef np.ndarray r 599 | cdef np.npy_intp shape[3] 600 | cdef np.npy_intp stride[3] 601 | cdef np.dtype dtype 602 | fmt = self.fmt or self.img.format 603 | ndim = 2 604 | if fmt == PIXEL_FORMAT_MONO8 or fmt == PIXEL_FORMAT_RAW8: 605 | dtype = np.dtype("uint8") 606 | stride[1] = 1 607 | elif fmt == PIXEL_FORMAT_MONO16 or fmt == PIXEL_FORMAT_RAW16: 608 | dtype = np.dtype("uint16") 609 | stride[1] = 2 610 | elif fmt == PIXEL_FORMAT_RGB8 or fmt == PIXEL_FORMAT_444YUV8: 611 | dtype = np.dtype("uint8") 612 | ndim = 3 613 | stride[1] = 3 614 | stride[2] = 1 615 | shape[2] = 3 616 | elif fmt == PIXEL_FORMAT_422YUV8: 617 | dtype = np.dtype("uint8") 618 | ndim = 3 619 | stride[1] = 2 620 | stride[2] = 1 621 | shape[2] = 2 622 | else: 623 | dtype = np.dtype("uint8") 624 | stride[1] = self.img.stride/self.img.cols 625 | Py_INCREF(dtype) 626 | shape[0] = self.img.rows 627 | shape[1] = self.img.cols 628 | stride[0] = self.img.stride 629 | #assert stride[0] == stride[1]*shape[1] 630 | #assert shape[0]*shape[1]*stride[1] == self.img.dataSize 631 | r = PyArray_NewFromDescr(np.ndarray, dtype, 632 | ndim, shape, stride, 633 | self.img.pData, np.NPY_DEFAULT, None) 634 | r.base = self 635 | Py_INCREF(self) 636 | return r 637 | 638 | def set_format(self, fmt): 639 | self.fmt = fmt 640 | 641 | def get_format(self): 642 | return self.fmt or self.img.format 643 | -------------------------------------------------------------------------------- /src/flycapture2.pyxdep: -------------------------------------------------------------------------------- 1 | FlyCapture2*C.h 2 | _FlyCapture2*C.pxd 3 | flycapture2*.pxd 4 | -------------------------------------------------------------------------------- /src/flycapture2_enums.pxi: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # pyflycapture2 - python bindings for libflycapture2_c 4 | # Copyright (C) 2012 Robert Jordens 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | 20 | # grep "^ FC2_" _FlyCapture2Defs_C.pxd | grep -v "FORCE_32BITS" | 21 | # perl -pe 's/^ *FC2_(.*)$/$1 = FC2_$1/' > flycapture2_enums.pxi 22 | 23 | from _FlyCapture2Defs_C cimport * 24 | 25 | ERROR_UNDEFINED = FC2_ERROR_UNDEFINED 26 | ERROR_OK = FC2_ERROR_OK 27 | ERROR_FAILED = FC2_ERROR_FAILED 28 | ERROR_NOT_IMPLEMENTED = FC2_ERROR_NOT_IMPLEMENTED 29 | ERROR_FAILED_BUS_MASTER_CONNECTION = FC2_ERROR_FAILED_BUS_MASTER_CONNECTION 30 | ERROR_NOT_CONNECTED = FC2_ERROR_NOT_CONNECTED 31 | ERROR_INIT_FAILED = FC2_ERROR_INIT_FAILED 32 | ERROR_NOT_INTITIALIZED = FC2_ERROR_NOT_INTITIALIZED 33 | ERROR_INVALID_PARAMETER = FC2_ERROR_INVALID_PARAMETER 34 | ERROR_INVALID_SETTINGS = FC2_ERROR_INVALID_SETTINGS 35 | ERROR_INVALID_BUS_MANAGER = FC2_ERROR_INVALID_BUS_MANAGER 36 | ERROR_MEMORY_ALLOCATION_FAILED = FC2_ERROR_MEMORY_ALLOCATION_FAILED 37 | ERROR_LOW_LEVEL_FAILURE = FC2_ERROR_LOW_LEVEL_FAILURE 38 | ERROR_NOT_FOUND = FC2_ERROR_NOT_FOUND 39 | ERROR_FAILED_GUID = FC2_ERROR_FAILED_GUID 40 | ERROR_INVALID_PACKET_SIZE = FC2_ERROR_INVALID_PACKET_SIZE 41 | ERROR_INVALID_MODE = FC2_ERROR_INVALID_MODE 42 | ERROR_NOT_IN_FORMAT7 = FC2_ERROR_NOT_IN_FORMAT7 43 | ERROR_NOT_SUPPORTED = FC2_ERROR_NOT_SUPPORTED 44 | ERROR_TIMEOUT = FC2_ERROR_TIMEOUT 45 | ERROR_BUS_MASTER_FAILED = FC2_ERROR_BUS_MASTER_FAILED 46 | ERROR_INVALID_GENERATION = FC2_ERROR_INVALID_GENERATION 47 | ERROR_LUT_FAILED = FC2_ERROR_LUT_FAILED 48 | ERROR_IIDC_FAILED = FC2_ERROR_IIDC_FAILED 49 | ERROR_STROBE_FAILED = FC2_ERROR_STROBE_FAILED 50 | ERROR_TRIGGER_FAILED = FC2_ERROR_TRIGGER_FAILED 51 | ERROR_PROPERTY_FAILED = FC2_ERROR_PROPERTY_FAILED 52 | ERROR_PROPERTY_NOT_PRESENT = FC2_ERROR_PROPERTY_NOT_PRESENT 53 | ERROR_REGISTER_FAILED = FC2_ERROR_REGISTER_FAILED 54 | ERROR_READ_REGISTER_FAILED = FC2_ERROR_READ_REGISTER_FAILED 55 | ERROR_WRITE_REGISTER_FAILED = FC2_ERROR_WRITE_REGISTER_FAILED 56 | ERROR_ISOCH_FAILED = FC2_ERROR_ISOCH_FAILED 57 | ERROR_ISOCH_ALREADY_STARTED = FC2_ERROR_ISOCH_ALREADY_STARTED 58 | ERROR_ISOCH_NOT_STARTED = FC2_ERROR_ISOCH_NOT_STARTED 59 | ERROR_ISOCH_START_FAILED = FC2_ERROR_ISOCH_START_FAILED 60 | ERROR_ISOCH_RETRIEVE_BUFFER_FAILED = FC2_ERROR_ISOCH_RETRIEVE_BUFFER_FAILED 61 | ERROR_ISOCH_STOP_FAILED = FC2_ERROR_ISOCH_STOP_FAILED 62 | ERROR_ISOCH_SYNC_FAILED = FC2_ERROR_ISOCH_SYNC_FAILED 63 | ERROR_ISOCH_BANDWIDTH_EXCEEDED = FC2_ERROR_ISOCH_BANDWIDTH_EXCEEDED 64 | ERROR_IMAGE_CONVERSION_FAILED = FC2_ERROR_IMAGE_CONVERSION_FAILED 65 | ERROR_IMAGE_LIBRARY_FAILURE = FC2_ERROR_IMAGE_LIBRARY_FAILURE 66 | ERROR_BUFFER_TOO_SMALL = FC2_ERROR_BUFFER_TOO_SMALL 67 | ERROR_IMAGE_CONSISTENCY_ERROR = FC2_ERROR_IMAGE_CONSISTENCY_ERROR 68 | BUS_RESET = FC2_BUS_RESET 69 | ARRIVAL = FC2_ARRIVAL 70 | REMOVAL = FC2_REMOVAL 71 | DROP_FRAMES = FC2_DROP_FRAMES 72 | BUFFER_FRAMES = FC2_BUFFER_FRAMES 73 | UNSPECIFIED_GRAB_MODE = FC2_UNSPECIFIED_GRAB_MODE 74 | TIMEOUT_NONE = FC2_TIMEOUT_NONE 75 | TIMEOUT_INFINITE = FC2_TIMEOUT_INFINITE 76 | TIMEOUT_UNSPECIFIED = FC2_TIMEOUT_UNSPECIFIED 77 | BANDWIDTH_ALLOCATION_OFF = FC2_BANDWIDTH_ALLOCATION_OFF 78 | BANDWIDTH_ALLOCATION_ON = FC2_BANDWIDTH_ALLOCATION_ON 79 | BANDWIDTH_ALLOCATION_UNSUPPORTED = FC2_BANDWIDTH_ALLOCATION_UNSUPPORTED 80 | BANDWIDTH_ALLOCATION_UNSPECIFIED = FC2_BANDWIDTH_ALLOCATION_UNSPECIFIED 81 | INTERFACE_IEEE1394 = FC2_INTERFACE_IEEE1394 82 | INTERFACE_USB_2 = FC2_INTERFACE_USB_2 83 | INTERFACE_USB_3 = FC2_INTERFACE_USB_3 84 | INTERFACE_GIGE = FC2_INTERFACE_GIGE 85 | INTERFACE_UNKNOWN = FC2_INTERFACE_UNKNOWN 86 | DRIVER_1394_CAM = FC2_DRIVER_1394_CAM 87 | DRIVER_1394_PRO = FC2_DRIVER_1394_PRO 88 | DRIVER_1394_JUJU = FC2_DRIVER_1394_JUJU 89 | DRIVER_1394_VIDEO1394 = FC2_DRIVER_1394_VIDEO1394 90 | DRIVER_1394_RAW1394 = FC2_DRIVER_1394_RAW1394 91 | DRIVER_USB_NONE = FC2_DRIVER_USB_NONE 92 | DRIVER_USB_CAM = FC2_DRIVER_USB_CAM 93 | DRIVER_USB3_PRO = FC2_DRIVER_USB3_PRO 94 | DRIVER_GIGE_NONE = FC2_DRIVER_GIGE_NONE 95 | DRIVER_GIGE_FILTER = FC2_DRIVER_GIGE_FILTER 96 | DRIVER_GIGE_PRO = FC2_DRIVER_GIGE_PRO 97 | DRIVER_UNKNOWN = FC2_DRIVER_UNKNOWN 98 | BRIGHTNESS = FC2_BRIGHTNESS 99 | AUTO_EXPOSURE = FC2_AUTO_EXPOSURE 100 | SHARPNESS = FC2_SHARPNESS 101 | WHITE_BALANCE = FC2_WHITE_BALANCE 102 | HUE = FC2_HUE 103 | SATURATION = FC2_SATURATION 104 | GAMMA = FC2_GAMMA 105 | IRIS = FC2_IRIS 106 | FOCUS = FC2_FOCUS 107 | ZOOM = FC2_ZOOM 108 | PAN = FC2_PAN 109 | TILT = FC2_TILT 110 | SHUTTER = FC2_SHUTTER 111 | GAIN = FC2_GAIN 112 | TRIGGER_MODE = FC2_TRIGGER_MODE 113 | TRIGGER_DELAY = FC2_TRIGGER_DELAY 114 | FRAME_RATE = FC2_FRAME_RATE 115 | TEMPERATURE = FC2_TEMPERATURE 116 | UNSPECIFIED_PROPERTY_TYPE = FC2_UNSPECIFIED_PROPERTY_TYPE 117 | FRAMERATE_1_875 = FC2_FRAMERATE_1_875 118 | FRAMERATE_3_75 = FC2_FRAMERATE_3_75 119 | FRAMERATE_7_5 = FC2_FRAMERATE_7_5 120 | FRAMERATE_15 = FC2_FRAMERATE_15 121 | FRAMERATE_30 = FC2_FRAMERATE_30 122 | FRAMERATE_60 = FC2_FRAMERATE_60 123 | FRAMERATE_120 = FC2_FRAMERATE_120 124 | FRAMERATE_240 = FC2_FRAMERATE_240 125 | FRAMERATE_FORMAT7 = FC2_FRAMERATE_FORMAT7 126 | NUM_FRAMERATES = FC2_NUM_FRAMERATES 127 | VIDEOMODE_160x120YUV444 = FC2_VIDEOMODE_160x120YUV444 128 | VIDEOMODE_320x240YUV422 = FC2_VIDEOMODE_320x240YUV422 129 | VIDEOMODE_640x480YUV411 = FC2_VIDEOMODE_640x480YUV411 130 | VIDEOMODE_640x480YUV422 = FC2_VIDEOMODE_640x480YUV422 131 | VIDEOMODE_640x480RGB = FC2_VIDEOMODE_640x480RGB 132 | VIDEOMODE_640x480Y8 = FC2_VIDEOMODE_640x480Y8 133 | VIDEOMODE_640x480Y16 = FC2_VIDEOMODE_640x480Y16 134 | VIDEOMODE_800x600YUV422 = FC2_VIDEOMODE_800x600YUV422 135 | VIDEOMODE_800x600RGB = FC2_VIDEOMODE_800x600RGB 136 | VIDEOMODE_800x600Y8 = FC2_VIDEOMODE_800x600Y8 137 | VIDEOMODE_800x600Y16 = FC2_VIDEOMODE_800x600Y16 138 | VIDEOMODE_1024x768YUV422 = FC2_VIDEOMODE_1024x768YUV422 139 | VIDEOMODE_1024x768RGB = FC2_VIDEOMODE_1024x768RGB 140 | VIDEOMODE_1024x768Y8 = FC2_VIDEOMODE_1024x768Y8 141 | VIDEOMODE_1024x768Y16 = FC2_VIDEOMODE_1024x768Y16 142 | VIDEOMODE_1280x960YUV422 = FC2_VIDEOMODE_1280x960YUV422 143 | VIDEOMODE_1280x960RGB = FC2_VIDEOMODE_1280x960RGB 144 | VIDEOMODE_1280x960Y8 = FC2_VIDEOMODE_1280x960Y8 145 | VIDEOMODE_1280x960Y16 = FC2_VIDEOMODE_1280x960Y16 146 | VIDEOMODE_1600x1200YUV422 = FC2_VIDEOMODE_1600x1200YUV422 147 | VIDEOMODE_1600x1200RGB = FC2_VIDEOMODE_1600x1200RGB 148 | VIDEOMODE_1600x1200Y8 = FC2_VIDEOMODE_1600x1200Y8 149 | VIDEOMODE_1600x1200Y16 = FC2_VIDEOMODE_1600x1200Y16 150 | VIDEOMODE_FORMAT7 = FC2_VIDEOMODE_FORMAT7 151 | NUM_VIDEOMODES = FC2_NUM_VIDEOMODES 152 | MODE_0 = FC2_MODE_0 153 | MODE_1 = FC2_MODE_1 154 | MODE_2 = FC2_MODE_2 155 | MODE_3 = FC2_MODE_3 156 | MODE_4 = FC2_MODE_4 157 | MODE_5 = FC2_MODE_5 158 | MODE_6 = FC2_MODE_6 159 | MODE_7 = FC2_MODE_7 160 | MODE_8 = FC2_MODE_8 161 | MODE_9 = FC2_MODE_9 162 | MODE_10 = FC2_MODE_10 163 | MODE_11 = FC2_MODE_11 164 | MODE_12 = FC2_MODE_12 165 | MODE_13 = FC2_MODE_13 166 | MODE_14 = FC2_MODE_14 167 | MODE_15 = FC2_MODE_15 168 | MODE_16 = FC2_MODE_16 169 | MODE_17 = FC2_MODE_17 170 | MODE_18 = FC2_MODE_18 171 | MODE_19 = FC2_MODE_19 172 | MODE_20 = FC2_MODE_20 173 | MODE_21 = FC2_MODE_21 174 | MODE_22 = FC2_MODE_22 175 | MODE_23 = FC2_MODE_23 176 | MODE_24 = FC2_MODE_24 177 | MODE_25 = FC2_MODE_25 178 | MODE_26 = FC2_MODE_26 179 | MODE_27 = FC2_MODE_27 180 | MODE_28 = FC2_MODE_28 181 | MODE_29 = FC2_MODE_29 182 | MODE_30 = FC2_MODE_30 183 | MODE_31 = FC2_MODE_31 184 | NUM_MODES = FC2_NUM_MODES 185 | PIXEL_FORMAT_MONO8 = FC2_PIXEL_FORMAT_MONO8 186 | PIXEL_FORMAT_411YUV8 = FC2_PIXEL_FORMAT_411YUV8 187 | PIXEL_FORMAT_422YUV8 = FC2_PIXEL_FORMAT_422YUV8 188 | PIXEL_FORMAT_444YUV8 = FC2_PIXEL_FORMAT_444YUV8 189 | PIXEL_FORMAT_RGB8 = FC2_PIXEL_FORMAT_RGB8 190 | PIXEL_FORMAT_MONO16 = FC2_PIXEL_FORMAT_MONO16 191 | PIXEL_FORMAT_RGB16 = FC2_PIXEL_FORMAT_RGB16 192 | PIXEL_FORMAT_S_MONO16 = FC2_PIXEL_FORMAT_S_MONO16 193 | PIXEL_FORMAT_S_RGB16 = FC2_PIXEL_FORMAT_S_RGB16 194 | PIXEL_FORMAT_RAW8 = FC2_PIXEL_FORMAT_RAW8 195 | PIXEL_FORMAT_RAW16 = FC2_PIXEL_FORMAT_RAW16 196 | PIXEL_FORMAT_MONO12 = FC2_PIXEL_FORMAT_MONO12 197 | PIXEL_FORMAT_RAW12 = FC2_PIXEL_FORMAT_RAW12 198 | PIXEL_FORMAT_BGR = FC2_PIXEL_FORMAT_BGR 199 | PIXEL_FORMAT_BGRU = FC2_PIXEL_FORMAT_BGRU 200 | PIXEL_FORMAT_RGB = FC2_PIXEL_FORMAT_RGB 201 | PIXEL_FORMAT_RGBU = FC2_PIXEL_FORMAT_RGBU 202 | PIXEL_FORMAT_BGR16 = FC2_PIXEL_FORMAT_BGR16 203 | PIXEL_FORMAT_422YUV8_JPEG = FC2_PIXEL_FORMAT_422YUV8_JPEG 204 | NUM_PIXEL_FORMATS = FC2_NUM_PIXEL_FORMATS 205 | UNSPECIFIED_PIXEL_FORMAT = FC2_UNSPECIFIED_PIXEL_FORMAT 206 | BUSSPEED_S100 = FC2_BUSSPEED_S100 207 | BUSSPEED_S200 = FC2_BUSSPEED_S200 208 | BUSSPEED_S400 = FC2_BUSSPEED_S400 209 | BUSSPEED_S480 = FC2_BUSSPEED_S480 210 | BUSSPEED_S800 = FC2_BUSSPEED_S800 211 | BUSSPEED_S1600 = FC2_BUSSPEED_S1600 212 | BUSSPEED_S3200 = FC2_BUSSPEED_S3200 213 | BUSSPEED_S5000 = FC2_BUSSPEED_S5000 214 | BUSSPEED_10BASE_T = FC2_BUSSPEED_10BASE_T 215 | BUSSPEED_100BASE_T = FC2_BUSSPEED_100BASE_T 216 | BUSSPEED_1000BASE_T = FC2_BUSSPEED_1000BASE_T 217 | BUSSPEED_10000BASE_T = FC2_BUSSPEED_10000BASE_T 218 | BUSSPEED_S_FASTEST = FC2_BUSSPEED_S_FASTEST 219 | BUSSPEED_ANY = FC2_BUSSPEED_ANY 220 | BUSSPEED_SPEED_UNKNOWN = FC2_BUSSPEED_SPEED_UNKNOWN 221 | PCIE_BUSSPEED_2_5 = FC2_PCIE_BUSSPEED_2_5 222 | PCIE_BUSSPEED_5_0 = FC2_PCIE_BUSSPEED_5_0 223 | PCIE_BUSSPEED_UNKNOWN = FC2_PCIE_BUSSPEED_UNKNOWN 224 | DEFAULT = FC2_DEFAULT 225 | NO_COLOR_PROCESSING = FC2_NO_COLOR_PROCESSING 226 | NEAREST_NEIGHBOR_FAST = FC2_NEAREST_NEIGHBOR_FAST 227 | EDGE_SENSING = FC2_EDGE_SENSING 228 | HQ_LINEAR = FC2_HQ_LINEAR 229 | RIGOROUS = FC2_RIGOROUS 230 | IPP = FC2_IPP 231 | DIRECTIONAL = FC2_DIRECTIONAL 232 | BT_NONE = FC2_BT_NONE 233 | BT_RGGB = FC2_BT_RGGB 234 | BT_GRBG = FC2_BT_GRBG 235 | BT_GBRG = FC2_BT_GBRG 236 | BT_BGGR = FC2_BT_BGGR 237 | FROM_FILE_EXT = FC2_FROM_FILE_EXT 238 | PGM = FC2_PGM 239 | PPM = FC2_PPM 240 | BMP = FC2_BMP 241 | JPEG = FC2_JPEG 242 | JPEG2000 = FC2_JPEG2000 243 | TIFF = FC2_TIFF 244 | PNG = FC2_PNG 245 | RAW = FC2_RAW 246 | HEARTBEAT = FC2_HEARTBEAT 247 | HEARTBEAT_TIMEOUT = FC2_HEARTBEAT_TIMEOUT 248 | STATISTICS_GREY = FC2_STATISTICS_GREY 249 | STATISTICS_RED = FC2_STATISTICS_RED 250 | STATISTICS_GREEN = FC2_STATISTICS_GREEN 251 | STATISTICS_BLUE = FC2_STATISTICS_BLUE 252 | STATISTICS_HUE = FC2_STATISTICS_HUE 253 | STATISTICS_SATURATION = FC2_STATISTICS_SATURATION 254 | STATISTICS_LIGHTNESS = FC2_STATISTICS_LIGHTNESS 255 | WINDOWS_X86 = FC2_WINDOWS_X86 256 | WINDOWS_X64 = FC2_WINDOWS_X64 257 | LINUX_X86 = FC2_LINUX_X86 258 | LINUX_X64 = FC2_LINUX_X64 259 | MAC = FC2_MAC 260 | UNKNOWN_OS = FC2_UNKNOWN_OS 261 | BYTE_ORDER_LITTLE_ENDIAN = FC2_BYTE_ORDER_LITTLE_ENDIAN 262 | BYTE_ORDER_BIG_ENDIAN = FC2_BYTE_ORDER_BIG_ENDIAN 263 | TIFF_NONE = FC2_TIFF_NONE 264 | TIFF_PACKBITS = FC2_TIFF_PACKBITS 265 | TIFF_DEFLATE = FC2_TIFF_DEFLATE 266 | TIFF_ADOBE_DEFLATE = FC2_TIFF_ADOBE_DEFLATE 267 | TIFF_CCITTFAX3 = FC2_TIFF_CCITTFAX3 268 | TIFF_CCITTFAX4 = FC2_TIFF_CCITTFAX4 269 | TIFF_LZW = FC2_TIFF_LZW 270 | TIFF_JPEG = FC2_TIFF_JPEG 271 | -------------------------------------------------------------------------------- /test_flycapture2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # pyflycapture2 - python bindings for libflycapture2_c 5 | # Copyright (C) 2012 Robert Jordens 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | 20 | import flycapture2 as fc2 21 | import numpy as np 22 | 23 | def test(): 24 | print fc2.get_library_version() 25 | c = fc2.Context() 26 | print c.get_num_of_cameras() 27 | c.connect(*c.get_camera_from_index(0)) 28 | print c.get_camera_info() 29 | c.set_video_mode_and_frame_rate(fc2.VIDEOMODE_1280x960Y16, 30 | fc2.FRAMERATE_7_5) 31 | m, f = c.get_video_mode_and_frame_rate() 32 | print m, f 33 | print c.get_video_mode_and_frame_rate_info(m, f) 34 | print c.get_property_info(fc2.FRAME_RATE) 35 | p = c.get_property(fc2.FRAME_RATE) 36 | print p 37 | c.set_property(**p) 38 | c.start_capture() 39 | im = fc2.Image() 40 | print [np.array(c.retrieve_buffer(im)).sum() for i in range(80)] 41 | a = np.array(im) 42 | print a.shape, a.base 43 | c.stop_capture() 44 | c.disconnect() 45 | 46 | if __name__ == "__main__": 47 | test() 48 | --------------------------------------------------------------------------------