Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
morefigs committed May 28, 2019
2 parents 7b4013d + f76de43 commit a479486
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 44 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,4 @@ nosetests.xml
.cache/

venv*
scrap/

notes.txt
Pipfile.lock
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Pymba change log

## [0.3.4] - 2019/04/13
### Added
- Timeout error checking to single frame acquisition example.
### Changed
- Removed f-strings for backwards compatibility.

## [0.3.3] - 2019/03/28
### Added
- Timeout parameter to acquire frame function.
Expand Down
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
opencv-python = "*"
pytest = "*"

[packages]
numpy = "*"
2 changes: 1 addition & 1 deletion examples/camera/display_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def display_frame(frame: Frame, delay: Optional[int] = 1) -> None:
:param frame: The frame object to display.
:param delay: Display delay in milliseconds, use 0 for indefinite.
"""
print(f'frame {frame.data.frameID}')
print('frame {}'.format(frame.data.frameID))

# get a copy of the frame data
image = frame.buffer_data_numpy()
Expand Down
4 changes: 2 additions & 2 deletions examples/camera/list_feature_values_and_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
print('\n\t'.join(
str(x) for x in (
feature_name,
f'value: {value}',
f'range: {range_}')
'value: {}'.format(value),
'range: {}'.format(range_))
if x is not None))

camera.close()
10 changes: 7 additions & 3 deletions examples/camera/set_feature_value.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
from pymba import Vimba


FEATURE_NAME = 'PixelFormat'


if __name__ == '__main__':

with Vimba() as vimba:
camera = vimba.camera(0)
camera.open()

# read a feature value
feature = camera.feature('ExposureAuto')
feature = camera.feature(FEATURE_NAME)
value = feature.value

# set the feature value
# set the feature value (with the same value)
feature.value = value

print(feature.name, '=', feature.value)
print('"{}" was set to "{}"'.format(feature.name, feature.value))

# alternatively the feature value can be set as an object attribute
# note that this doesn't raise an error if the feature name doesn't exist
camera.ExposureAuto = feature.value

camera.close()
4 changes: 2 additions & 2 deletions examples/interface/list_feature_values_and_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
print('\n\t'.join(
str(x) for x in (
feature_name,
f'value: {value}',
f'range: {range_}')
'value: {}'.format(value),
'range: {}'.format(range_))
if x is not None))

interface.close()
12 changes: 8 additions & 4 deletions examples/interface/set_feature_value.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
from pymba import Vimba


FEATURE_NAME = 'InterfacePingPace'


if __name__ == '__main__':

with Vimba() as vimba:
interface = vimba.interface(0)
interface.open()

# set a feature value by feature name
feature = interface.feature('InterfacePingPace')
# read a feature value
feature = interface.feature(FEATURE_NAME)
value = feature.value

# set the feature value
# set the feature value (with the same value)
feature.value = value

print(feature.name, '=', feature.value)
print('"{}" was set to "{}"'.format(feature.name, feature.value))

# alternatively the feature value can be set as an object attribute
# note that this doesn't raise an error if the feature name doesn't exist
interface.InterfacePingPace = 3

interface.close()
6 changes: 3 additions & 3 deletions examples/show_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pymba import Vimba, PYMBA_VERSION
from pymba import Vimba, __version__


if __name__ == '__main__':
print(f'Pymba version: {PYMBA_VERSION}')
print(f'Vimba C API version: {Vimba.version()}')
print('Pymba version: {}'.format(__version__))
print('Vimba C API version: {}'.format(Vimba.version()))
4 changes: 2 additions & 2 deletions examples/system/list_feature_values_and_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
print('\n\t'.join(
str(x) for x in (
feature_name,
f'value: {value}',
f'range: {range_}')
'value: {}'.format(value),
'range: {}'.format(range_))
if x is not None))
3 changes: 0 additions & 3 deletions pymba/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from .vimba import Vimba, VimbaException
from .frame import Frame


PYMBA_VERSION = '0.3.3'
7 changes: 5 additions & 2 deletions pymba/vimba_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ def find_so(platform, genicam_path):
class NiceStructure(Structure):
def __repr__(self):
field_names = (field[0] for field in self._fields_)
return f'{type(self).__name__}(' \
f'{", ".join("=".join((field, str(getattr(self, field)))) for field in field_names)})'
return '{}({})'.format(
type(self).__name__,
", ".join("=".join((field, str(getattr(self, field))))
for field in field_names)
)


class VmbVersionInfo(NiceStructure):
Expand Down
2 changes: 1 addition & 1 deletion pymba/vimba_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __getattr__(self, item: str):
# otherwise attempt to get their value
return feature.value

raise AttributeError(f'{self.__class__.__name__} object has no attribute {item}')
raise AttributeError('{} object has no attribute {}'.format(self.__class__.__name__, item))

# allow direct access to feature values as an attribute
def __setattr__(self, item: str, value):
Expand Down
19 changes: 9 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from setuptools import setup

from pymba import PYMBA_VERSION


setup(name='pymba',
version=PYMBA_VERSION,
version='0.3.4',
description="Pymba is a Python wrapper for Allied Vision's Vimba C API.",
long_description="Pymba is a Python wrapper for Allied Vision's Vimba C API. It wraps the Vimba C library file "
"included in the Vimba installation to provide a simple Python interface for Allied Vision "
"cameras. It currently supports most of the functionality provided by Vimba.",
long_description=(
"Pymba is a Python wrapper for Allied Vision's Vimba C API. It wraps the Vimba C library "
"file included in the Vimba installation to provide a simple Python interface for Allied "
"Vision cameras. It currently supports most of the functionality provided by Vimba."
),
# https://pypi.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 5 - Production/Stable',
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Healthcare Industry',
'Intended Audience :: Manufacturing',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
Expand All @@ -26,13 +26,12 @@
'Topic :: Multimedia :: Video :: Capture',
'Topic :: Scientific/Engineering :: Image Recognition',
'Topic :: Scientific/Engineering :: Visualization',
'Topic :: Software Development :: Libraries :: Python Modules'
],
keywords='python, python3, opencv, cv, machine vision, computer vision, image recognition, vimba, allied vision',
author='morefigs',
author_email='[email protected]',
url='https://github.com/morefigs/pymba',
license='GPL-3.0',
license='MIT',
packages=[
'pymba',
],
Expand Down
8 changes: 0 additions & 8 deletions tests/test_vimba.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import pytest

from pymba import Vimba, VimbaException


def test_version():
version = Vimba.version().split('.')
assert int(version[0]) >= 1
assert int(version[1]) >= 7
assert int(version[2]) >= 0


def test_startup_shutdown():
with pytest.raises(VimbaException) as e:
Vimba().system().feature_names()
Expand Down

0 comments on commit a479486

Please sign in to comment.