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]))

print("123")
counter = 0
print("123")
cam.Open
print("123")
grab_results = cam.GrabOne(40)
print(grab_results)

print("DONE")
image = grab_results.Array

plt.imshow(image)
plt.show()

And This is The Output


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

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

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

 

Does Someone Have An Idea What The Problem Could Be?

Thanks

 

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

Answers

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

Comments
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?

Comments
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.

Comments
K.H report abuse

I will do that as soon as the wheel file is back online again according to https://github.com/basler/pypylon/issues/5 &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.

Comments
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 setup.py 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\setup.py", line 639, in
version
File "C:\Users\KIERAN~1\AppData\Local\Temp\pip-req-build-zl59zfzz\setup.py", 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 setup.py 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 setup.py?

Add Answer

Need support?

Just drop us an email to ... Show more