ids_peak - A library for device communication
Project description
ids_peak provides python bindings for the IDS peak genericAPI. It exposes all the functionality of the peak genericAPI and requires at least the drivers and GenICam transport layers to be installed, which are included in the IDS peak SDK.
Benefit from many Python advantages, for example the interactive programming of your IDS camera. Write and test small code snippets without the complex setup of a programming IDE including a toolchain. This package is ideal for prototyping IDS camera applications for all supported peak genericAPI platforms (Windows, Linux, Linux Embedded).
Installation
$ pip install ids_peak
Quickstart
This example shows how to open a device, start image acquisition
and how to convert a buffer to an ids_peak_ipl.Image
.
NOTE: For the sake of simplicity, most of the error checking has been omitted in this example.
from ids_peak import ids_peak
from ids_peak import ids_peak_ipl_extension
def main():
# Initialize library
ids_peak.Library.Initialize()
# Create a DeviceManager object
device_manager = ids_peak.DeviceManager.Instance()
try:
# The returned callback object needs to be stored in a variable and
# needs to live as long as the class that would call it,
# so as long as the device manager in this case
# If the callback gets garbage collected it deregisters itself
device_found_callback = device_manager.DeviceFoundCallback(
lambda found_device: print(
"Found-Device-Callback: Key={}".format(
found_device.Key()), end="\n\n"))
device_found_callback_handle = device_manager.RegisterDeviceFoundCallback(
device_found_callback)
# Update the DeviceManager
device_manager.Update()
# The callback can also be unregistered explicitly using the returned
# handle
device_manager.UnregisterDeviceFoundCallback(
device_found_callback_handle)
# Exit program if no device was found
if device_manager.Devices().empty():
print("No device found. Exiting Program.")
return -1
# Open the first device
device = device_manager.Devices()[0].OpenDevice(
ids_peak.DeviceAccessType_Control)
# Nodemap for accessing GenICam nodes
remote_nodemap = device.RemoteDevice().NodeMaps()[0]
# Load default camera settings
remote_nodemap.FindNode("UserSetSelector").SetCurrentEntry("Default")
remote_nodemap.FindNode("UserSetLoad").Execute()
remote_nodemap.FindNode("UserSetLoad").WaitUntilDone()
# Open first data stream
data_stream = device.DataStreams()[0].OpenDataStream()
# Buffer size
payload_size = remote_nodemap.FindNode("PayloadSize").Value()
# Minimum number of required buffers
buffer_count_max = data_stream.NumBuffersAnnouncedMinRequired()
# Allocate buffers and add them to the pool
for buffer_count in range(buffer_count_max):
# Let the TL allocate the buffers
buffer = data_stream.AllocAndAnnounceBuffer(payload_size)
# Put the buffer in the pool
data_stream.QueueBuffer(buffer)
# Lock writeable nodes during acquisition
remote_nodemap.FindNode("TLParamsLocked").SetValue(1)
print("Starting acquisition...")
data_stream.StartAcquisition()
remote_nodemap.FindNode("AcquisitionStart").Execute()
remote_nodemap.FindNode("AcquisitionStart").WaitUntilDone()
print("Getting 100 images...")
# Process 100 images
for _ in range(100):
try:
# Wait for finished/filled buffer event
buffer = data_stream.WaitForFinishedBuffer(1000)
img = ids_peak_ipl_extension.BufferToImage(buffer)
# Do something with `img` here ...
# Put the buffer back in the pool, so it can be filled again
# NOTE: If you want to use `img` beyond this point, you have
# to make a copy, since `img` still uses the underlying
# buffer's memory.
data_stream.QueueBuffer(buffer)
except Exception as e:
print(f"Exception: {e}")
print("Stopping acquisition...")
remote_nodemap.FindNode("AcquisitionStop").Execute()
remote_nodemap.FindNode("AcquisitionStop").WaitUntilDone()
data_stream.StopAcquisition(ids_peak.AcquisitionStopMode_Default)
# In case another thread is waiting on WaitForFinishedBuffer
# you can interrupt it using:
# data_stream.KillWait()
# Remove buffers from any associated queue
data_stream.Flush(ids_peak.DataStreamFlushMode_DiscardAll)
for buffer in data_stream.AnnouncedBuffers():
# Remove buffer from the transport layer
data_stream.RevokeBuffer(buffer)
# Unlock writeable nodes again
remote_nodemap.FindNode("TLParamsLocked").SetValue(0)
except Exception as e:
print("EXCEPTION: " + str(e))
return -2
finally:
ids_peak.Library.Close()
if __name__ == '__main__':
main()
Documentation
Documentation is available here
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file ids_peak-1.8.0.0-cp37-abi3-win_amd64.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7911e186cf4e9717e8815cde1d2f8710a5bef0494972182f607cfc81036c85b |
|
MD5 | 4f837e1739948db92569938504a2ce01 |
|
BLAKE2b-256 | 2ce2c92bffe4b6837352bca94432cb1f903c0848e710d95c92f9b9ef1f903f36 |
File details
Details for the file ids_peak-1.8.0.0-cp37-abi3-win32.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0-cp37-abi3-win32.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.7+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14ad403bdb79ab32820b52ba2b0855d6acc03c21f8cc7d8b5ec65739d47b616f |
|
MD5 | 8864e7aea7abe875f36adc213c454fa3 |
|
BLAKE2b-256 | ff7f32dfb36718af0737cf6d9cfd2535ab92873be562fe38950e3613047ce7cb |
File details
Details for the file ids_peak-1.8.0.0-cp37-abi3-manylinux_2_27_x86_64.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0-cp37-abi3-manylinux_2_27_x86_64.whl
- Upload date:
- Size: 4.1 MB
- Tags: CPython 3.7+, manylinux: glibc 2.27+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d0d36fd416fd769bb8440c0d5eeaaf0c494f2e4f38927b19ba8d5a977e7a214 |
|
MD5 | 5613d735a33250840d10b1cd9b52cdcf |
|
BLAKE2b-256 | ea0b9ce754da40e3c65a109cd3e38046873a2a24c4adef937f4927c2b2981fff |
File details
Details for the file ids_peak-1.8.0.0-cp37-abi3-manylinux_2_27_i686.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0-cp37-abi3-manylinux_2_27_i686.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.7+, manylinux: glibc 2.27+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63b85895f06ce0bc760d7ba3b5933d6b39e92feb114fb0cc98e9fd5726d031d2 |
|
MD5 | 3cd9e42f0ad78944fa00a43c83d03381 |
|
BLAKE2b-256 | 89916682784a7ec59f30411f4331d7d8e3cbd1a4a9b8e75ade2910b85c2a1110 |
File details
Details for the file ids_peak-1.8.0.0-cp37-abi3-manylinux_2_27_armv7l.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0-cp37-abi3-manylinux_2_27_armv7l.whl
- Upload date:
- Size: 3.5 MB
- Tags: CPython 3.7+, manylinux: glibc 2.27+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a68d4caa13391149908404ce517126006378da55b9f07c53678960b1e96336e2 |
|
MD5 | 1ec31b6c9527f343a678a27ea60438cc |
|
BLAKE2b-256 | 7af2d765adf68b41098b41a6fa4a735da4926d4137d52453eae8668d3660fa5e |
File details
Details for the file ids_peak-1.8.0.0-cp37-abi3-manylinux_2_27_aarch64.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0-cp37-abi3-manylinux_2_27_aarch64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.7+, manylinux: glibc 2.27+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 967bd9add357f88d4318823b01e2c97b5ee670484ed668ef343ff57d7ccd93e7 |
|
MD5 | f76fa411d847dbacbc5a0495ddf653ca |
|
BLAKE2b-256 | 44b3ed7a65c9c667f5a05df364319830dd715cad1ff6939051697aac43595925 |