Why use pypylon? And why should you use it for Python?
Well, Python is a dynamic, object-oriented programming language with many uses. Pypylon is a wrapper interface that connects with the powerful Basler pylon Camera Software Suite that permits both new and experienced Python software engineers to effectively develop applications without thinking about setting up a development environment.
This accelerates the camera assessment process, expands the software engineer’s efficiency, and diminishes the all-out project costs.
How to install?
- Start by installing pylon
- Install pyplon with the following command:
pip3 install pypylon
After installation, you can use the following code to test the camera:
#Source: https://github.com/basler/pypylon
from pypylon import pylon
camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
camera.Open()
# demonstrate some feature access
new_width = camera.Width.GetValue() - camera.Width.GetInc()
if new_width >= camera.Width.GetMin():
camera.Width.SetValue(new_width)
numberOfImagesToGrab = 100
camera.StartGrabbingMax(numberOfImagesToGrab)
while camera.IsGrabbing():
grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)
if grabResult.GrabSucceeded():
# Access the image data.
print("SizeX: ", grabResult.Width)
print("SizeY: ", grabResult.Height)
img = grabResult.Array
print("Gray value of first pixel: ", img[0, 0])
grabResult.Release()
camera.Close()
Video on the way!
Leave a Reply