StudentCV / PyPylon

pylon wrapper for Python
Other
5 stars 3 forks source link

documentation #1

Open tiggersternchen opened 8 years ago

tiggersternchen commented 8 years ago

I'm very insterested in your Pylon wrapper. Good work ! Unfortunately it is nearly undocuented. Could you give some basic examples showing the configuration of the camera and the usage (setting the frame rate, exposure time, retrieving available camera modes ...). The sample files inside the other repositiories also don't show the configuration part.

I would appreciate your help !

Thanks in advance Sven verpoort@fh-muenster.de

StudentCV commented 8 years ago

Hi Sven,

this file of the Table Soccer project may help you already, at least a bit. Generally, you can use the C++ documentation mostly. The commands are named identically just in typical python syntax.

There will be more information on http://imaginghub.com/. If you have further question please attach them to the project in imaginghub as soon as it goes live in a few days.

tiggersternchen commented 8 years ago

Thanks for your fast response. By now I was able to configure the most important properties of my connected camera. But I still have trouble to list all connected devices. I've tried the following:

factory = py.TlFactory.GetInstance()
device_info_list = factory.EnumerateDevices()
max_cam = 2
attached_cameras = py.InstantCameraArray(max_cam)
if len(device_info_list) == 0:
    raise Exception('no camera connected')
else:
    for run in range(len(device_info_list):
        **attached_cameras[run].Attach(fact.CreateDevice(device_info_list[run]))**

My problem is the highlighted line, the InstantCameraArray has no method "Attach" and item assignment is also unsupported. How can I add the found cameras to the array instance ?

Thanks in advance Sven

tiggersternchen commented 8 years ago

Sorry to bother you again.

Thanks to your help, I was able to configure the most important properties of my connected camera. But I still have trouble to list all connected devices. I've tried the following:

|factory = py.TlFactory.GetInstance() device_info_list =
factory.EnumerateDevices() max_cam = 2 attached_cameras =
py.InstantCameraArray(max_cam) if len(device_info_list) == 0: raise
Exception('no camera connected') else: for run in
range(len(device_info_list): attached_cameras[run] =
(fact.CreateDevice(device_info_list[run])) |

My problem is the last line, the InstantCameraArray has no method to "Attach" the device and item assignment is also unsupported. How can I add the found cameras to the array instance ? The method call

|dev = fact.CreateDevice(device_info_list[run])| |||returns an <Swig Object of type 'IPylonDevice *' at 0x000000F66EC0EC00> How can I use this object ? The command "print(dev.GetDeviceInfo().GetModelName())" does not work. |

Thanks in advance Sven

Am 19.08.2016 um 11:49 schrieb StudentCV:

Hi Sven,

this file of the Table Soccer project may help you already, at least a bit. Generally, you can use the C++ documentation mostly. The commands are named identically just in typical python syntax.

There will be more information on http://imaginghub.com/. If you have further question please attach them to the project in imaginghub as soon as it goes live in a few days.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/StudentCV/PyPylon/issues/1#issuecomment-240976248, or mute the thread https://github.com/notifications/unsubscribe-auth/ATaRxYB2kPWuuSZAvYuIQlxDWnssalhpks5qhXwMgaJpZM4JnpOj.

aspecovius commented 7 years ago

Using the PyPylon adapter in Python is like using PylonSDK in C++. You can use the examples provided in the SDK to brute-force like build a python program.

The following example searches for a camera and then asks the user to grab a single image or to grab multiple images (somehow rewritable for video capturing).

load modules

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

set up

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

search devices

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

exit if no devices found

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

create camera device

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

query user what to do

input = int(raw_input('Grab single [0] continuous [1]: '))

grab single image

if(input==0): print('Grab single image') grab = cam.GrabOne(3000) print('Grab %s' % ('succeeded' if grab.GrabSucceeded() else 'failed'))

data  = np.array(grab.GetBuffer()).astype(np.uint8)
image = data.reshape(grab.GetHeight(), grab.GetWidth())

plt.imshow(image)
plt.show()

grab image stream

if(input==1): counter = 0 cam.StartGrabbing(1) while(cam.IsGrabbing()): grab = cam.RetrieveResult(3000) print('Grab %i %s' % (counter, 'succeeded' if grab.GrabSucceeded() else 'failed'))

    counter += 1
    if(counter>50):
        cam.StopGrabbing()
        break

pypylon_swig_test.zip

madhusudangr commented 7 years ago

@StudentCV @aspecovius I seem to have a problem, my python does not recognize any of the methods which @aspecovius mentioned. Am I missing something here ? Or I am using a different version - Its just been 7 months since the post, I havnt seen any recent activity or new releases though.

aspecovius commented 7 years ago

@madhusudangr Have you installed pypylon module? For my example you also need matplotlib and numpy, have you installed both? You may also need the Pylon SDK on your machine for the libraries. The time I ran the script I had Pylon5 SDK installed. I ran the script with python2.7 - for python3 you may have to adjust some of the code lines, especially raw_input() function..

satputeamit commented 6 years ago

Hello, How to set exposure time ? Can you give me example. Thank you