-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged PR 26069: changes for pylon 7.5 and 3D
- Loading branch information
Showing
26 changed files
with
1,494 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# =============================================================================== | ||
# This sample shows how to access data containers. | ||
# This is needed when using 3D cameras, e.g., Basler blaze. | ||
# =============================================================================== | ||
import os | ||
from pypylon import pylon | ||
from pypylon import genicam | ||
|
||
import sys | ||
|
||
# This is used for visualization. | ||
import cv2 | ||
import time | ||
|
||
# The exit code of the sample application. | ||
exitCode = 0 | ||
|
||
try: | ||
# Create a pylon data container object. | ||
pylonDataContainer = pylon.PylonDataContainer() | ||
|
||
# Load the recipe file. | ||
thisdir = os.path.dirname(__file__) | ||
filename = os.path.join(thisdir, 'images/3D/little_boxes.gendc') | ||
pylonDataContainer.Load(filename) | ||
|
||
print("Component Count: ", pylonDataContainer.DataComponentCount); | ||
|
||
# Access data components if the component type indicates image data | ||
for componentIndex in range(pylonDataContainer.DataComponentCount): | ||
pylonDataComponent = pylonDataContainer.GetDataComponent(componentIndex); | ||
# Access the component data. | ||
print("ComponentType: ", pylonDataComponent.ComponentType) | ||
print("PixelType: ", pylonDataComponent.PixelType) | ||
print("SizeX: ", pylonDataComponent.Width) | ||
print("SizeY: ", pylonDataComponent.Height) | ||
print("OffsetX: ", pylonDataComponent.OffsetX) | ||
print("OffsetY: ", pylonDataComponent.OffsetY) | ||
print("PaddingX: ", pylonDataComponent.PaddingX) | ||
print("DataSize: ", pylonDataComponent.DataSize) | ||
print("TimeStamp: ", pylonDataComponent.TimeStamp) | ||
img = pylonDataComponent.Array | ||
print("Gray value of first pixel: ", img[0, 0]) | ||
if pylonDataComponent.PixelType == pylon.PixelType_Coord3D_ABC32f: | ||
None | ||
else: | ||
cv2.imshow('Image' + str(componentIndex), img) | ||
# Release the data, otherwise it will not be freed | ||
# The data is held by the container and the components until all of them are released. | ||
pylonDataComponent.Release() | ||
|
||
for i in range(60): | ||
time.sleep(1) | ||
# Break the endless loop by pressing ESC. | ||
k = cv2.waitKey(5) & 0xFF | ||
if k == 27: | ||
break | ||
|
||
# Free the data held by the container | ||
pylonDataContainer.Release() | ||
|
||
except genicam.GenericException as e: | ||
# Error handling. | ||
print("An exception occurred.") | ||
print(e) | ||
exitCode = 1 | ||
|
||
sys.exit(exitCode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# =============================================================================== | ||
# This sample illustrates how to grab and process data using the CInstantCamera class. | ||
# The data is grabbed and processed asynchronously, i.e., | ||
# while the application is processing a buffer, the acquisition of the next buffer is done | ||
# in parallel. | ||
# | ||
# Utilizes the API for accessing GenICam Generic Data Container (GenDC). | ||
# This will allow the use of, e.g., Basler blaze 3D cameras. | ||
# =============================================================================== | ||
from pypylon import pylon | ||
from pypylon import genicam | ||
|
||
import sys | ||
|
||
# Number of results to be grabbed. | ||
countOfResultsToGrab = 100 | ||
|
||
# The exit code of the sample application. | ||
exitCode = 0 | ||
|
||
try: | ||
# Create an instant camera object with the camera device found first. | ||
camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) | ||
camera.Open() | ||
|
||
# Print the model name of the camera. | ||
print("Using device ", camera.GetDeviceInfo().GetModelName()) | ||
|
||
# demonstrate some feature access | ||
new_width = camera.Width.Value - camera.Width.Inc | ||
if new_width >= camera.Width.Min: | ||
camera.Width.Value = new_width | ||
|
||
# The parameter MaxNumBuffer can be used to control the count of buffers | ||
# allocated for grabbing. The default value of this parameter is 10. | ||
camera.MaxNumBuffer.Value = 5 | ||
|
||
# Start the grabbing of c_countOfImagesToGrab grab results. | ||
# The camera device is parameterized with a default configuration which | ||
# sets up free-running continuous acquisition. | ||
camera.StartGrabbingMax(countOfResultsToGrab) | ||
|
||
# Camera.StopGrabbing() is called automatically by the RetrieveResult() method | ||
# when c_countOfImagesToGrab grab results have been retrieved. | ||
while camera.IsGrabbing(): | ||
# Wait for grabbed data and then retrieve it. A timeout of 5000 ms is used. | ||
grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException) | ||
|
||
# Data grabbed successfully? | ||
if grabResult.GrabSucceeded(): | ||
# Get the grab result as a PylonDataContainer, e.g. when working with 3D cameras. | ||
pylonDataContainer = grabResult.GetDataContainer(); | ||
print("Component Count: ", pylonDataContainer.DataComponentCount); | ||
# Access data components if the component type indicates image data | ||
for componentIndex in range(pylonDataContainer.DataComponentCount): | ||
pylonDataComponent = pylonDataContainer.GetDataComponent(componentIndex); | ||
if pylonDataComponent.ComponentType == pylon.ComponentType_Intensity: | ||
# Access the component data. | ||
print("PixelType: ", pylonDataComponent.PixelType) | ||
print("SizeX: ", pylonDataComponent.Width) | ||
print("SizeY: ", pylonDataComponent.Height) | ||
print("OffsetX: ", pylonDataComponent.OffsetX) | ||
print("OffsetY: ", pylonDataComponent.OffsetY) | ||
print("PaddingX: ", pylonDataComponent.PaddingX) | ||
print("DataSize: ", pylonDataComponent.DataSize) | ||
print("TimeStamp: ", pylonDataComponent.TimeStamp) | ||
img = pylonDataComponent.Array | ||
print("Gray value of first pixel: ", img[0, 0]) | ||
pylonDataComponent.Release() | ||
pylonDataContainer.Release() | ||
else: | ||
print("Error: ", grabResult.ErrorCode, grabResult.ErrorDescription) | ||
grabResult.Release() | ||
camera.Close() | ||
|
||
except genicam.GenericException as e: | ||
# Error handling. | ||
print("An exception occurred.") | ||
print(e) | ||
exitCode = 1 | ||
|
||
sys.exit(exitCode) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.