Package: pynivision
Author:Peter Johnson, FRC Team 294Copyright:Copyright © 2012 Peter JohnsonAboutNI Visionis aNational Instrumentsimage/vision processing library.
It is available for multiple platforms including Windows and the
CompactRIO.  This project makes the functionality of NI Vision available
in thePythonprogramming language.FeaturesFull wrapping of all structures, enumerations, and functions.All functions raise anivision.ImaqErrorexception if an error occurs,
rather than relying on nonzero or NULL return values.Output parameters are returned as a tuple (in parameter order).  If the
function additionally returns a value, this is returned as the first
element of the tuple, followed by the output parameters.Count/size/length parameters that specify the length of an array are
handled implicitly by using Python’slen()function.  This includes
return values (which are returned as a sized array).Additional Pythonic helper functions (seeDocumentation).Automatic memory management of Image and other data types (seeDocumentation).UsageRead a JPEG file and print its dimensions (width and height):import nivision
img = nivision.imaqCreateImage(nivision.IMAQ_IMAGE_RGB)
nivision.Priv_ReadJPEGString(img, open('example.jpg', 'rb').read())
print(nivision.imaqGetImageSize(img))RequirementsAn installed and licensed version ofNI Vision.  Only the 2011 version has
been tested.The wrappers currently require ctypes, so this library is currently not usable
on platforms that don’t have ctypes.  Unfortunately this includesRobotPyas
of this writing, but this is being worked on.The wrappers have only been tested on Python 3.x.InstallationOn the robot, this will be installed automatically as of RobotPy 2015.0.1. Otherwise,
you can install it via pip:pip install pynivisionRuninstall.batorpython setup.py install.DocumentationThe “NI Vision for LabWindows/CVI Function Reference” help file
(NIVisionCVI.chm) is currently the best “complete” reference.  However, the
Python wrappers deviate from the C library in several important ways (seeFeatures).A few helper functions are provided due to the use of in/out parameters.imaqGetCores(): Returns the number of cores available to NI Vision.imaqSetCores(customNumCores): Sets the number of cores available to NI
Vision.imaqUseMaxAvailableCores(): Configures NI Vision to use the maximum
number of available processor cores.imaqDispose()is automatically called when the corresponding Python object
is garbage collected forImageand all other structures/arrays returned
by imaq functions.  It is still ok to explicitly callimaqDispose()on
these objects (but be careful, as the underlying object will be immediately
freed even though the Python object is still accessible).ImplementationMost of the wrapper code is generated by thegen_wrap.pyscript.
Hand-written Python code inctypes_core_prefix.pyandctypes_core_suffix.pycomplements the automatically generated code.  Thegen_wrap.pyscript createsnivision/core.pywhich includes the contents
of the prefix and suffix Python files.Thegen_wrap.pyscript reads an.inifile for Pythonic customizations
to the wrappers such as automatic disposal and handling of sized values as
arrays.  The .ini file used is automatically determined by the nivision
version in use (or can alternatively be specified on the command line).AsPriv_ReadJPEGString_Cis not exported on current Windows distributions ofnivissvc.dll, a custom implementation that uses GDI+ has been written innivision/private.pyandnivision/gdiplus.py.LicenseCopyright © 2012 Peter Johnson.Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.