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.1-cp37-abi3-win_amd64.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0.1-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 | d5a48bad8276c213170dcef99e79253e570a1fd73027f0a47d4e925ab519a62b |
|
MD5 | d9a1c7bde89f1f47098b06e7d2450c30 |
|
BLAKE2b-256 | df477b6766662bcaffd719f569ad40925a2b44eb78113937ba4411f93e5916e2 |
File details
Details for the file ids_peak-1.8.0.0.1-cp37-abi3-win32.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0.1-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 | 28b4d2368d64a593915012da95c3934404579552afd6afafd3419ebc66612e0d |
|
MD5 | 21eee27e862b3fdd24bdf7a2d9df67ae |
|
BLAKE2b-256 | 4e1f4b766a68487987f60b30280249348c902a819719003d3cd3f1f479dacd03 |
File details
Details for the file ids_peak-1.8.0.0.1-cp37-abi3-manylinux_2_27_x86_64.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0.1-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 | b04e24d0c89a26b20f7acdbeca734568831642c196e8a335638dfa5361d86ead |
|
MD5 | b80f57d6854d31ee79c7bf49471e80f7 |
|
BLAKE2b-256 | f89ce6f93123dc09d745601682e7d6a81afc8f2cdf7c0205324cce2303e856c2 |
File details
Details for the file ids_peak-1.8.0.0.1-cp37-abi3-manylinux_2_27_i686.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0.1-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 | 851209919000037d5f29097f64134553fc256ec0c909c525a35c0169086c6b89 |
|
MD5 | f7ac4dacf212c1e2aadcacaf0e740236 |
|
BLAKE2b-256 | 7326b44bee10683d8b8824d4c1cda0e37454abc9a770e3b80909196dc28187d2 |
File details
Details for the file ids_peak-1.8.0.0.1-cp37-abi3-manylinux_2_27_armv7l.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0.1-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 | 218d04cad8ade3f5467429ff86708dd52a0f7f9257bb7bc7df0983fe8c34ba6f |
|
MD5 | 34cb42fddd5c4e8112a456c073074ed2 |
|
BLAKE2b-256 | 8c7f76c42f8b0e9f3b482ec170c714fc79f1cc995bee0f4e54307c8010465605 |
File details
Details for the file ids_peak-1.8.0.0.1-cp37-abi3-manylinux_2_27_aarch64.whl
.
File metadata
- Download URL: ids_peak-1.8.0.0.1-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 | 969c95b6f08282f40ff619164fefeba1d2ab46bdf1bb7969afa48dcb293481ac |
|
MD5 | fd7a8bda4ec66e64f7b6475fa787967c |
|
BLAKE2b-256 | 2ca4b44f7759ca847ea92ecd77e46d9757eb6ca1b787e882f6bd7fc7c5920078 |