Published January 23, 2020
| Version 1.0.2
Software
Open
Harvester: Pythonic Image Acquisition Library for Machine Vision People
Creators
Description
Harvester is a powerful sandbox for machine vision researchers. Harvester boosts productivity on your research utilizing the following advantages:
- Quick prototyping
- Cross-platform
- Performance on image acquisition
Harvester can be installed just executing the following pip command:
$ pip install harvesters
The following code demonstrates how Harvester eases you to get images that you will work on for your research:
# Import Harvester:
from harvesters.core import Harvester
# Create a Harvester object:
h = Harvester()
# Load a GenTL Producer; you can load many more if you want to:
h.add_cti_file('path/to/gentl_producer_abc.cti')
# Enumerate the available devices that GenTL Producers can handle:
h.update_device_info_list()
# Select a target device and create an ImageAcquire object that
# controls the device:
ia = h.create_image_acquirer(0)
# Configure the target device; it looks very small but this is just
# for demonstration:
ia.remote_device.node_map.Width.value = 8
ia.remote_device.node_map.Height.value = 8
ia.remote_device.node_map.PixelFormat.value = 'Mono8'
# Allow the ImageAcquire object to start image acquisition:
ia.start_image_acquisition()
# We are going to fetch a buffer filled up with an image:
# Note that you'll have to queue the buffer back to the
# ImageAcquire object once you consumed the buffer; the
# with statement takes care of it on behalf of you:
with ia.fetch_buffer() as buffer:
# Let's create an alias of the 2D image component; it can be
# lengthy which is not good for typing. In addition, note that
# a 3D camera can give you 2 or more components:
component = buffer.payload.components[0]
# Let's see the acquired data in 1D:
_1d = component.data
print('1D: {0}'.format(_1d))
# Reshape the NumPy array into a 2D array:
_2d = component.data.reshape(
component.height, component.width
)
print('2D: {0}'.format(_2d))
# Here are some trivial calculations:
print(
'AVE: {0}, MIN: {1}, MAX: {2}'.format(
np.average(_2d), _2d.min(), _2d.max()
)
)
# Stop the ImageAcquier object acquiring images:
ia.stop_image_acquisition()
# We're going to leave here shortly:
ia.destroy()
h.reset()
And then you will get the following output:
1D: [123 124 125 126 127 128 129 130 124 125 126 127 128 129 130 131 125 126
127 128 129 130 131 132 126 127 128 129 130 131 132 133 127 128 129 130
131 132 133 134 128 129 130 131 132 133 134 135 129 130 131 132 133 134
135 136 130 131 132 133 134 135 136 137]
2D: [[123 124 125 126 127 128 129 130]
[124 125 126 127 128 129 130 131]
[125 126 127 128 129 130 131 132]
[126 127 128 129 130 131 132 133]
[127 128 129 130 131 132 133 134]
[128 129 130 131 132 133 134 135]
[129 130 131 132 133 134 135 136]
[130 131 132 133 134 135 136 137]]
AVE: 130.0, MIN: 123, MAX: 137
Files
genicam/harvesters-1.0.2.zip
Files
(113.4 kB)
Name | Size | Download all |
---|---|---|
md5:e2bb758c6e66d93abee9030b612a55ba
|
113.4 kB | Preview Download |
Additional details
Related works
- Is supplement to
- https://github.com/genicam/harvesters/tree/1.0.2 (URL)