Accesing Pictures From my Basler Camera

K.H report abuse

Hi all,

i am using pypylon  1.1.0 with Python 3.6 and a Basler acA2500-14gm. My Problem is that when i Try to "Grab" an Image The Code Ends Without an Error.


This is The Code I am Using

import pypylon.pylon as pylon
import matplotlib.pyplot as plt
import numpy as np
import cv2

tlfactory = pylon.TlFactory.GetInstance()
ptl = tlfactory.CreateTl('BaslerGigE')

detected_devices = ptl.EnumerateDevices()
print('%i devices detected:' % len(detected_devices))
print([d.GetFriendlyName() for d in detected_devices])
print(' ')

if(len(detected_devices) == 0):
    import sys; sys.exit()

print('Create camera device')
cam = pylon.InstantCamera(ptl.CreateDevice(detected_devices[0]))

counter = 0
grab_results = cam.GrabOne(40)

image = grab_results.Array


And This is The Output

=============================== RESTART: Shell ===============================

 RESTART: C:\Users\Kieran Hedges\Documents\python\Testing Cython\Basler Kamera\
1 devices detected:
['Basler acA2500-14gm (22576214)']
Create camera device

=============================== RESTART: Shell ===============================


Does Someone Have An Idea What The Problem Could Be?



So The Problem is solved it seems that my installation was Accesing other installations of similar packages (that were also called pypylon) and that was causing all of the trouble


pylonguy report abuse

Hi K.H

seems to be just a typo: array must use upper case A

image = grab_results.array -> image = grab_results.Array

best regards

K.H report abuse

Hi pylonguy
thanks for pointing out the typo however after correcting it the problem remains and im still rather certain that the problem lies with the grab because neither print(grab_results) or print("DONE") get displayed in the shell (i will fix the typo in the post)

pylonguy report abuse

This is odd, on my side when running your sample I just got an error caused by the mentioned typo. Could you debug your sample line by line (e.g. with Visual Studio Code) and find out where exactly you get the error?

K.H report abuse

[pylint] E0611:No name 'pylon' in module 'pypylon' (1,1)
[pylint] E0401:Unable to import 'pypylon.pylon' (1,1)

this is the problem output however i am rather confused seeing how several of the pypylon functions work such as pylon.InstantCamera(ptl.CreateDevice(detected_devices[0]))
they shouldnt work without the import as far as my knowledge goes

pylonguy report abuse

Yes that's odd. I still believe that there's a problem with your python environment settings. I would suggest to install the newer pypylon version from github and to try to run one of our sample programs.

K.H report abuse

I will do that as soon as the wheel file is back online again according to &thanks for the help so far

pylonguy report abuse

It might still take some time until we put the wheels back again. I would recommend to build your pypylon from source as explained in the readme.

K.H report abuse

I seem to have a problem when installing from source. I have Swig and git installed however they arent found am i forgetting something like adding something to PATH?

And Despite the printed Building version none of the example scripts work (import errors for all pypylon modules like genicam).

Processing c:\users\kieran hedges\pypylon
Complete output from command python egg_info:
ERROR:root:swig executable not found!
fatal: No tags can describe 'aea06fc6987bb89e9506b493cd417ee1645c4db6'.
Try --always, or create some tags.
WARNING:root:git not found or invalid tag found.
WARNING:root:-> Building version from date!
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\KIERAN~1\AppData\Local\Temp\pip-req-build-zl59zfzz\", line 639, in
File "C:\Users\KIERAN~1\AppData\Local\Temp\pip-req-build-zl59zfzz\", line 121, in call_swig
print("call", " ".join(call_args))
TypeError: sequence item 0: expected str instance, NoneType found
Building version: 2018.6.11.dev37359+pylon5.0.12.11830

Command "python egg_info" failed with error code 1 in C:\Users\KIERAN~1\AppData\Local\Temp\pip-req-build-zl59zfzz\

K.H report abuse

I have also Installed other packages from github so it seems my setup is ok. Could there be a problem with the

Add Answer

Need support?

Just drop us an email to ... Show more