Code Monkey home page Code Monkey logo

pymba's People

Contributors

alex4243 avatar crocodiledandy avatar derricw avatar edmundchong avatar fmder avatar fstarr avatar gloweye avatar honkomonk avatar hvraven avatar jayich avatar jrast avatar lbusoni avatar morefigs avatar pierreraybaut avatar samm-ils avatar tribeiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymba's Issues

Black Lines on readings

I've been getting black lines on my pictures lately, and I haven't been able to find out why.

Script:
frame is...a frame. image is externally triggered, but I've also seen it happen in internal triggers. All of this is done in it's own dedicated thread.

#Here's a lot of setup code
a = frame.waitFrameCapture(timeout = self.timeout*1000)# convert to milliseconds
print("Errorcode:",a)
timer_abort_queue.put((timerID,)) #Logs the duration taken from the main thread
cameraref.endCapture()
try:
     b = np.ndarray(buffer = frame.getBufferByteData(),
                              dtype = np.uint8,
                              shape = (frame.width,frame.height))
     print(b.shape)
     print(b)
 except:
      raise
cameraref.revokeAllFrames()
if a == 0:
      self.queue.put((identifierstring,copy.deepcopy(b)))  #gives the array to the main thread so enable processing of the data

Example of a black lined result is like this:
black lines

What I considered:

  • Data corruption due to some pointer getting into a fight with python data management: Seems unlikely to me. However, it would explain why it's a solid line across multiple rows, stopping at apparently random intervals of rows.
  • Camera not reading out entire sensor: While the camera is capable, I haven't told it to, and it does seem to be able to only select rectangles, not these semi-random lines seen in the image.
  • Camera not sending entire sensor readout over the GigE: Appears weird to me. I'd have expected to see vimbaDLL complain about it, or the data to be misarranged instead of partially missing. Also, StatFrameDropped, StatPacketMissed, StatPacketResent and StatFrameRescued all return 0 after taking the above image.
  • Data corruption after taking the image(somewhere in the numpy array): it's printed right after and shows the values belonging to the lines there. Also, deepcopy should prevent any loss due to referencing issues.

Side note: Vimba Viewer itself doesn't seem to exhibit this problem. Or maybe it ignores to faulty frames someway.

I couldn't find any issues like this anywhere. If there's someone who has an idea, I'd love to hear it.

My apologies if it isn't a pymba issue. Right now it's a possibility, as I haven't been able to find other cases outside(or inside) pymba, but i don't have a clue as to what inside pymba could probably cause it either. To my limited knowledge, every line of pymba code looks fine.

Porting to python 3?

Could anyone make this compatible with python 3? I think it would be useful for most users, including myself.

ImportError with vimbastructure (and a solution proposal)

Hi,

I currently use Pymba within the following directory structure:

Instruments
      |------ some files we don't care about 
      |------ Cameras
                 |------ Camera_AVT.py
                 |------ pymba

where:

  • the pymba folder is the wrapper's package main folder,
  • I have not run pymba's setup.py because I did not want to install anything on the local Python distribution
  • Camera_AVT.py contains a camera class using the wrapper through a import pymba,
  • the parent folder of Instruments is in my PYTHONPATH (yes, Windows 10 here),
  • and I use a script located somewhere else that imports Camera_AVT.py through a from Instruments.Cameras.camera_AVT import Camera_AVT

Now when I do that, I get an error while importing vimbastructure.py in vimba.py (and elsewhere):

Traceback (most recent call last):
  File "path_to_my_script/my_script.py", line X, in <module>
    from Instruments.Cameras.camera_AVT import Camera_AVT
  File "some_path\Instruments\Cameras\camera_AVT.py", line 10, in <module>
    import pymba
  File "some_path\Instruments\Cameras\pymba\__init__.py", line 3, in <module>
    from .vimba import Vimba
  File "some_path\Instruments\Cameras\pymba\vimba.py", line 3, in <module>
    import pymba.vimbastructure as structs
ImportError: No module named pymba.vimbastructure

So I brushed up my understanding of Python's import logic and understood this is because Python fails a absolute/relative import due to the fact that the pymba parent folder is not in the PYTHONPATH (or the PATH) when I try to perform a import pymba.vimbastructure as structs.

I changed all occurrences of import pymba.vimbastructure as structs for from . import vimbastructure as structs in order to perform a proper relative import according to PEP238. It works.
So is there a smart reason the import was made with import pymba.vimbastructure as structs rather than from . import vimbastructure as structs and the way I use the package is just not proper ?
If not, I would like to ask permission to modify this.

FYI, import pymba.vimbastructure as structs occurs in:

vimba.py
vimbacamera.py
vimbadll.py
vimbafeature.py
vimbaframe.py
vimbainterface.py
vimbaobject.py

Looking for some Pymba documentation

Hi,

First, thanks a lot for Pymba, it makes my job easier. We need more wrappers like this.
I have some Goldeye P-008 and P-032 I try to automate and I find myself lacking documentation when using Pymba. I have the Vimba manual, a 2013 Vimba C API manual V1.2 along with its function reference and the GigE features reference. Still I find myself struggling to understand what Pymba feature does what and how to call it.

For instance, when I do vimba.getCameraIds() I would love to know which ones are busy and can't be accessed. In the absence of documentation I find myself digging in the wrapper:

  • There is a vimba feature for what I want: vimba.getCameraInfo('device_ID'). It picks an object in a list provided by vimba._getCameraInfos() when the ID matches the requested one. The permitted access mode can finally be retrieved by looking at the attribute of the info object: info.permittedAccess, which returns an long integer.

  • I see that in vimba._getCameraInfos(), the information is retrieved thanks to a call to VimbaDLL.camerasList(cameraInfoArray,numCameras,byref(numFound),sizeof(dummyCameraInfo)). So I look into vimbadll.py to see that VimbaDLL.camerasList() is eventually defined as _vimbaDLL.VmbCamerasList which is a C function of the API.

  • I open my Vimba C API function reference where the function definition lies but there is unfortunately nothing about the meaning of the long integer of info.permittedAccess.

Do you have any idea about where I can find this kind of information ?

I feel like I am doing a lot of retro-engineering for a feature that seems pretty necessary to anyone using at least one shared camera. I feel the wrapper would really benefit of some extended documentation.
I would love to help on my spare time but I am a total beginner at wrapper development. I can read some C and I know a bit of Python though my object oriented game is far from state of the art.
How can I help ? Write docstrings ? Pull-modify-commit-push ?

Much <3

simultaneous capturing with 2 cameras

Hey guys,

I'm trying to acquire simultaneous footage with two mantas using the precision time protocol supported by the cameras. I already got them to sync properly but am currently stuck getting the image data. Do you know a good way to handle the acquisition of two cameras? Would threading / dividing into two separate processes be a good idea? Any help is highly appreciated :). Thanks in advance.

Cheers

Use ExposureAuto and GainAuto

I would like to adapt the live display example to use AutoGain and AutoExposure in "Continuous" mode, but when I set those features to "Continuous" the live display doesn't adapt to lighting changes.
I would like to know if this is a limitation of Pymba or if I need to do extra modifications instead of only changing those two features values to "Continuous"?

How to load camera config file

Hi,
I just found your project and it works quite well. I'm just wondering if i can load a xml config file for a camera.
Sorry if it's a stupid question but i don't know much about this kind of programming.

Thanks !

python hang

Hey everybody,

I'm experiencing some strange python crashes by running the example code, although it works a couple of times now and then (opencv_liveview_example). This is the error message is get: error

It seems that the camera gets found but as soon as I want to get a frame, it crashes. Any ideas? I'm running Vimba 1.4 on a 32-bit Win7 system with Anaconda2. I set the jumbo packets to 9014. Let me know if you need more information. Any help is highly appreciated :)

Cheers

runFeatureCommand requires bytestrings

Note: I am using Vimba 1.4. It is possible that syntax was changed here.

On all examples found here, normal strings seem to be supplied. However, finally succeeding a call to system.getFeatureNames() gave me all responses in bytestrings. Why this difference exists I do not know, but it got a lot of stuff running.

An example is system.GeVTLIsPresent, which seems to require a bytestring as well. Replacing it with an explicit system.__getattr__(b"GeVTLIsPresent") seems to get it working without a hitch.

Since I didn't find any mention, I decided to make it a new issue. I don't know if making internal changes will be compatible with older versions of vimba, but wanted the knowledge out here.

MacOS version

Does anybody know how to have this library work on OS X?
It looks there is no Mac OS version for vimba that has been released yet.

I will appreciate any idea

Thanks

How to read 12 bit mono images to numpy array

Hi there,
I love the work that has been done to make the AVT cameras so much more accessible, thanks!

I would really like to use the api with a 12 bit images as well. The camera that we're using supports Mono12 and Mono12packed bit images as well as Mono8. How do I cast these to a 16 bit numpy array?

I tried (just copied from the example):

...
# set the value of a feature
camera0.AcquisitionMode = 'SingleFrame'
camera0.PixelFormat="Mono12"  
# do acquisition...

moreUsefulImgData = np.ndarray(buffer = frame0.getBufferByteData(),
                               dtype = np.uint16, # changed here
                               shape = (frame0.height,
                                        frame0.width,
                                        1))

But this fails as the data is 12 bit and not 16 bit, so the length is mismatched.

If someone can tell me how, I'd be happy to make a PR with a function that will cast the frame output to a numpy array for any mono datatype.

regards,
Dirk

opencv_liveview_example error handling

Hi,
I'm having problems with an example in tests/opencv_liveview_example.py:

After first caught exception in block:

try:
    frame.queueFrameCapture()
    success = True
except:
    droppedframes.append(framecount)
    success = False

every other call in the while loop to that code block ends with same exception.

What is a correct way to recover from queueFrameCapture error?

Camera object has no attribute GVSPAdjustPacketSize

Hey,

I really appreciate your work. When I tried to run my MAKO U-029B connected via USB using the opencv_acquire_image.py I get the attached error. Any ideas why my camera does not have this attribute?

'''

AttributeError Traceback (most recent call last)
in
23 with Vimba() as vimba:
24 camera = vimba.camera(0)
---> 25 camera.open()
26
27 camera.arm('SingleFrame')

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pymba\camera.py in open(self, camera_access_mode, adjust_packet_size)
134 # may experience issues with camera comms if not called
135 if adjust_packet_size:
--> 136 self.GVSPAdjustPacketSize()
137
138 def close(self):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pymba\vimba_object.py in getattr(self, item)
35 return feature.value
36
---> 37 raise AttributeError(f'{self.class.name} object has no attribute {item}')
38
39 # allow direct access to feature values as an attribute

AttributeError: Camera object has no attribute GVSPAdjustPacketSize
'''

License change question

I noticed that this (very useful!) project changed license to the more restrictive GPL3. Any particular reason to do so?

delay issues on USB AVT Cam mako U-130

Hello,
We are developing a software able to perform marker tracking on live images. we were previously using Giga Ethernet AVT Cam manta G917 without any problem.
In order to increase working frequency, we bought a USB AVT Mako U-130, we have been able to use our software with this new camera but we encountered a delay issue.
This delay between an event and its display seems to increase in time and can reach as high as 20 seconds.

Can we find documentation or code examples using pymba with USB camera ?
Are there important differences of coding between USB and Giha Ethernet cameras ?

For information :

  • Our OS is Windows 10
  • We don't have any problem with Vimba Viewer interface (no delay).
  • We use Qt interface to display images with our software.
  • We use python 2.7
  • We are using the last version of pymba and vimba 2.1.3.

Vimba._cameraInfos should not be cached.

Currently Vimba._cameraInfo is cached and therefore not updated if, for example system.runFeatureCommand('GeVDiscoveryAllOnce') is run.

Steps to reproduce:

from pymba import Vimba
print("Starting Vimba")
vimba = Vimba()
vimba.startup()

# After startup no cameras are present (if only network cameras are connected)
print(vimba.getCameraIds()) # --> []

system = vimba.getSystem()
system.runFeatureCommand('GeVDiscoveryAllOnce')

# Now the cameras should be present
print(vimba.getCameraIds()) 
# Expected: ['DEV_000F314D17E8', 'DEV_000F314D17E7']
# Actual: []

print("Vimba Shutdown")
vimba.shutdown()

If the first print(vimba.getCameraIds()) is commented out, the output is as expected.

Vimba other Error whilst capturing series of images

Hi,

I am capturing Images with a Mako G-503C in Series using Pymba 0.1. After a (seemingly random) amount of Images I get the following error:

pymba.vimbaexception.VimbaException: Other error.

whilst calling announceFrame() method.
I use the following source Code:

import pymba
import numpy
import cv2
import time
Camera = None
Vimba = None
ID = "DEV_000F315C80FF"
def GetCamera():
    global ID
    global Camera
    global Vimba
    if Camera is None:
        # Create vimba instance
        Vimba = pymba.Vimba()
        # Startup vimba
        Vimba.startup()
        # Get system object
        System = Vimba.getSystem()
        # Discover cameras
        if System.GeVTLIsPresent:
            System.runFeatureCommand("GeVDiscoveryAllOnce")
            time.sleep(0.200)
        # Assign camera
        Camera = Vimba.getCamera(ID)
        # Open camera
        Camera.openCamera()
        # Set acquisition modes
        Camera.AcquisitionMode = "Continuous"
    return Camera
def Shutdown():
    global Vimba
    if Vimba is not None:
        Vimba.shutdown()
def Snapshot():
    Camera = GetCamera()
    # Start capture
    Camera.startCapture()
    # Assign frames
    Frames = [Camera.getFrame() for _ in range(1)]
    # Iterate each frame
    for Frame in Frames:
        # Announce frame
        Frame.announceFrame()
        # Queue frame capture
        Frame.queueFrameCapture()
    # Acquisition
    Camera.runFeatureCommand("AcquisitionStart")
    time.sleep(0.500)
    Camera.runFeatureCommand("AcquisitionStop")
    # Wait for frame buffer
    Frame.waitFrameCapture()
    # Convert image
    Image = numpy.ndarray(buffer=Frame.getBufferByteData(),
                          dtype=numpy.uint8,
                          shape=(Frame.height, Frame.width, 1)
                          )
    Image = cv2.cvtColor(Image, cv2.COLOR_BAYER_GR2RGB)
    Image = cv2.cvtColor(Image, cv2.COLOR_BGR2GRAY)
    # Save image
    cv2.imwrite("C:\\Temp\\test.jpg", Image)
    # Cleanup
    Camera.endCapture()
    Camera.revokeAllFrames()
counter = 0
while True:
    counter = counter + 1
    Snapshot()
    print(counter)

If i use my other camera Mako G-125B and my Mako G-125C then this happens never. So It might be as well a Hardware issue, but you never know...

Package installation problems

Hi,

I'm a bit confused as to how to get started with pymba (I'm not super experienced with python yet). Here're the steps I followed:

  1. I downloaded the lastest pymba-master folder and navigated using command prompt to this folder
  2. I ran 'python setup.py install'

This created following folder: 'C:\Python27\Lib\site-packages\pymba-0.1-py2.7.egg'
within 'pymba-0.1-py2.7.egg' are now two folders: 'EGG-INFO' and 'pymba'.

  1. I opened a python shell and tried running the command 'import pymba'

This created following error: 'ImportError: No module named pymba'.

  1. I then moved the the location of the 'pymba' folder to be directly inside 'C:\Python27\Lib\site-packages'

This got rid of the error, however a new error arose: 'IOError: VimbaC.dll not found'

  1. I then changed the path where to find VimbaC.dll inside vimbadll.py to point to where I can find VimbaC.dll in my vimba folder: 'r'C:\Program Files\Allied Vision\Vimba_2.1\Tools\Viewer\Win64\VimbaC.dll'

Now I'm getting a new error to do with importing vimbastructure:

File "<pyshell#2>", line 1, in
import pymba
File "C:\Python27\lib\site-packages\pymba_init_.py", line 3, in
from .vimba import Vimba
File "C:\Python27\lib\site-packages\pymba\vimba.py", line 3, in
from . import vimbastructure as structs
ImportError: cannot import name vimbastructure

I'm stuck with this error since vimbastructure.py seems to be inside the pymba folder and I'm not sure why it's having trouble importing it.

Does anyone know how to fix this? Or am I doing something completely wrong when setting the package up? I've also tried 'pip pymba', however that gave me an error telling me that I'm missing Visual C++.

Thanks for your help!
Pfefferminza

working with class

I would like to create a class for my camera and cut the code into 3 parts.
1 - Initialization
2 - Acquisition of a frame
3 - Closing

The problem is that my self.cam is not recognized in the read() function.

I'm getting a :

pymba.vimbaexception.VimbaException: VmbStartup() was not called before the current command.

Here is the example :

from pymba import *
import numpy as np
import time

class GIGECamera():
    
    def __init__(self,id):
        with Vimba() as vimba:
            system = vimba.getSystem()
        
            system.runFeatureCommand("GeVDiscoveryAllOnce")
            time.sleep(0.2)
        
            camera_ids = vimba.getCameraIds()
        
            for cam_id in camera_ids:
                print("Camera found: ", cam_id)
                
            self.cam = vimba.getCamera(camera_ids[id])
            self.cam.openCamera()
        
            try:
                #gigE camera
                print(self.cam.GevSCPSPacketSize)
                print(self.cam.StreamBytesPerSecond)
                self.cam.StreamBytesPerSecond = 100000000
            except:
                #not a gigE camera
                pass
        
            #set pixel format
            self.cam.PixelFormat="Mono8"
            #c0.ExposureTimeAbs=60000
        
            self.frame = self.cam.getFrame()
            self.frame.announceFrame()
        
            self.cam.startCapture()
            
            
        
    def read(self):
        try:
            self.frame.queueFrameCapture()
            success = True
        except:
            success = False
        self.cam.runFeatureCommand("AcquisitionStart")
        self.cam.runFeatureCommand("AcquisitionStop")
        self.frame.waitFrameCapture(1000)
        frame_data = self.frame.getBufferByteData()
        if success:
            img = np.ndarray(buffer=frame_data,
                             dtype=np.uint8,
                             shape=(self.frame.height,self.frame.width,1))
            return img

        
    def close(self):
        self.cam.endCapture()
        self.cam.revokeAllFrames()
        self.cam.closeCamera()

error running system.GeVTLIsPresent

I am getting the following error when trying the following code. I am running python 2.7.11 and Vimba 1.4. In vimbaobject.py. I changed the VimbaDLL.featuresList parameter from 0 to 1000. Any thoughts?

from pymba import *
import time

with Vimba() as vimba:
# get system object
system = vimba.getSystem()

if system.GeVTLIsPresent:
system.runFeatureCommand("GeVDiscoveryAllOnce")
time.sleep(0.2)

This is the error:

Traceback (most recent call last):
File "<pyshell#6>", line 1, in
if system.GeVTLIsPresent:
File "C:\Python27\lib\pymba\vimbaobject.py", line 35, in getattr
if attr in self.getFeatureNames():
File "C:\Python27\lib\pymba\vimbaobject.py", line 109, in getFeatureNames
return list(featInfo.name for featInfo in self._getFeatureInfos())
File "C:\Python27\lib\pymba\vimbaobject.py", line 81, in _getFeatureInfos
raise VimbaException(errorCode)
VimbaException: VmbStartup() was not called before the current command.

aarch64 init uses 32-bit environment variable

The assert for GENICAM_GENTL64_PATH is correct, but then it goes on to use the GENICAM_GENTL32_PATH and fails because it does not exist.

    elif 'aarch64' in os.uname()[4]:
        assert os.environ.get(
            "GENICAM_GENTL64_PATH"), "you need your GENICAM_GENTL64_PATH environment set.  Make sure you have Vimba installed, and you have loaded the /etc/profile.d/ scripts"
        tlPath = [p for p in os.environ.get("GENICAM_GENTL32_PATH").split(":") if p][0]

calling getFeatureNames() raises an exception with the new drivers

Hello,

After the installation of Vimba v1.4 from v1.3 and re-installation of pymba from this git repository, I started getting an error to any call to a function using getFeatureNames():

import pymba
vimba = pymba.Vimba()
vimba.startup()
system = vimba.getSystem()
system.getFeatureNames()
ERROR:
  File "...\Anaconda\lib\site-packages\pymba-0.1-py2.7.egg\pymba\vimbaobject.py", line 109, in getFeatureNames
    return list(featInfo.name for featInfo in self._getFeatureInfos())
  File "...\Anaconda\lib\site-packages\pymba-0.1-py2.7.egg\pymba\vimbaobject.py", line 81, in _getFeatureInfos
    raise VimbaException(errorCode)
VimbaException: More data was returned in a string/list than space was provided.

Would anyone know how to fix it?
Thank you,
Max

Pymba doesn't work without Vimba

Hi all,

I have an issue using pymba with Prosilica GT1380 and GT3300 cameras: the example "Interacting with cameras" from README.md when executed (after cameras were power cycled) returns array which has correct dimensions depending on the camera resolution but all values are 0, to fix that I simply need to start Vimba viewer and click start button for the camera to get a single frame, then I close Vimba viewer and the example script gets a perfect picture every time when executed. Could you please help to solve the issue? I use the most recent pymba from here.

Thanks for any help.

[Mako U-130] delayed frame acquisition

Thank you for the work you put into pymba, it has been really helpful.

On the current version of pymba, trying the example opencv_acquire_streaming_images.py I noticed that the live view is delayed by roughly a second.

Using an older version of pymba the same thing happens. The code looks roughly as follows:

frame = camera.getFrame()
frame.announceFrame()
camera.startCapture()
camera.runFeatureCommand('AcquisitionStart')

while True: # this loop actually gets controlled by a hardware switch
    frame.queueFrameCapture()
    frame.waitFrameCapture()
    frame_data = frame.getBufferByteData()
    data_frame = np.ndarray(buffer=frame_data,
                            dtype=np.uint8,
                            shape=(frame.height, frame.width))
    queue.put(np.copy(data_frame)) # putting the data into a queue for further processing

camera.runFeatureCommand('AcquisitionStop')
camera.endCapture()
vimba.shutdown()

Pausing and resuming the loop it becomes clear that the obtained data lags behind.
For example:

  1. starting the capture loop
  2. pointing the camera at object A for a few hundred iterations (that's just a few seconds on the Mako),
  3. pausing the capture loop
  4. pointing the camera at object B
  5. resuming the capture loop
  6. the first 50-150 (edit: 102) images will still be of object A

This behaviour is the same as when running the live view from opencv_acquire_streaming_images.py.

I would be grateful for any pointers to fix this.

Thank you for your work and time,
Paul

EDIT: I did some additional testing, Using a different (GigE) AVT camera, both the above code and opencv_acquire_streaming_images.py work flawlessly. On the Mako, the delay seems to be exactly 102 frames, independently from the set exposure time.

EDIT2: It seems the number 102 is exactly the number of frames that the internal memory on the Mako U-130 holds. According to the Technical Manual, the memory operates FIFO, so that explains the unfortunate behavior.

Is there any way to handle events or external triggers ?

i am not a very good programmer to start with, ive been going over and over the files and documentatiton, but i cannot find a way to recieve events or external triggers. can anybody help me ?

also if anyone is interested i have a mako g030b camera that i can provide access to for development purposes while im not using it (~12h per day)

captureFrameQueue's callback argument not yet implemented

I was working on doing this myself, and actually managed to get the C API to accept and call my python function, but this leaves me inside a function with nothing but a pointer to the frame. I don't have enough experience with ctypes to know what to do from here. Is anyone working on this?

There's a note in the source about a callback example in pico (vimbaframe.py:96). What does that refer to?

Need camera for testing

I no longer have access to an AVT camera for code testing, which makes it harder to respond to issues, fix bugs, approve pull requests, etc. If anyone has a spare one lying around they could loan me please let me know.

failing to import pymba

Hi,

I encounter an error while running this very short code:

_#!/usr/bin/env python

import pymba
from pymba import *

with Vimba() as vimba:
print vimba.getVersion()_

File "test.py", line 3, in
import pymba
File "/home/dylan/Python/pymba/pymba/init.py", line 2, in
from vimba import Vimba
File "/home/dylan/Python/pymba/pymba/vimba.py", line 3, in
from vimbadll import VimbaDLL
File "/home/dylan/Python/pymba/pymba/vimbadll.py", line 44, in
with open(vimbaC_path) as thefile:
IOError: [Errno 2] No such file or directory: '/home/dylan/Vimba_2_0/VimbaGigETL/CTI/x86_64bit:/home/dylan/Vimba_2_0/VimbaC/DynamicLib/x86_64bit/libVimbaC.so'

When I first installed pymba, this code worked and output was the version number of Vimba, 1.5.0.
However, it now gives me the error above. I have installed the GigE and USB transport layers, and the path leading to the file is correct. I cannot fix this problem, I cannot think of any changes I made. The code was working and now it is not.

I have tried deleting pymba, uninstalling the transport layers, and deleting Vimba, then re-installing everything again, but no luck.

I'm using Linux Mint Debian Edition and Python version 2.7. Processor is 1.7 GHz.

hardware trigger

Hi, I have been having problems with Line 2 trigger.
Line 2 trigger is working well on Vimba Viewer 2.0, but it doesn't take the trigger when using pymba.
A code that is similar to this one was working before but it stopped working.
I've tried restarting the camera and reinstalling pymba and vimba, and tried another computer also....My camera is GS1380. The liveview examples that comes with pymba are all working well.

from pymba import *
import cv2
import numpy as np

vimba = Vimba()

vimba.startup()

system = vimba.getSystem()
system.runFeatureCommand("GeVDiscoveryAllOnce")

cameraIds = vimba.getCameraIds()

camera = vimba.getCamera(cameraIds[0])

camera.openCamera()

camera.TriggerMode = 'On'
camera.TriggerSource = 'Line2'
camera.TriggerActivation = 'RisingEdge'
camera.PixelFormat = 'Mono8'
camera.TriggerSelector = 'FrameStart'
camera.AcquisitionMode = 'Continuous'

print 'TriggerMode:', camera.TriggerMode
print 'TriggerSource:', camera.TriggerSource
print 'TriggerActivation:', camera.TriggerActivation
print 'TriggerSelector:', camera.TriggerSelector

frame = camera.getFrame()

frame.announceFrame()

camera.startCapture()

frame.queueFrameCapture()

frame.waitFrameCapture(3000)

print 'frame 1 captured or timed out '

imgData1 = frame.getBufferByteData()

camera.endCapture()

data1_np = np.ndarray(buffer=imgData1,
                      dtype=np.uint8,
                      shape=(frame.height, frame.width))

rgb = cv2.cvtColor(data1_np, cv2.COLOR_BAYER_RG2RGB)

cv2.imwrite('testTrigger.png'.format(1), rgb)
camera.revokeAllFrames()
camera.closeCamera()
print 'frame is saved as png'

Hang on error

When an exception is thrown, the objects aren't closed/sutdown properly and cause the program to hang indifinetly (on Windows).

Can not show image in Python

If I open the camera via Vimba Viewer first, it can be opened via python.
It is workable and shows image.
If I open the camera directly via python, it can't be opened.

Do you have any idea for this?

start...
openCamera...
The Vimba lib version is: 1.7.0 , and vimba run successfully!
Available cameras ['DEV_000F315C1E2D']
[AcquisitionMode] Continuous
[ExposureAuto] Continuous
[ExposureAutoAdjustTol] 5
[ExposureAutoAlg] Mean
[ExposureAutoMax] 10000
[ExposureAutoMin] 100
[ExposureAutoRate] 100
[ExposureAutoTarget] 40
[Init_ExposureTimeAbs] 9998.0
[Init_Gain] 0.0
showImage...
[Exposure] 9998.0
[Gain] 0.0
captureFrame...
Traceback (most recent call last):
  File "D:\AVT_test.py", line 158, in <module>
    main()
  File "D:\AVT_test.py", line 147, in main
    ins.start()
  File "D:\AVT_test.py", line 137, in start
    self.captureFrame()
  File "D:\AVT_test.py", line 105, in captureFrame
    self.frame0.queueFrameCapture()
  File "C:\Python35\lib\site-packages\pymba-0.1-py3.5.egg\pymba\vimba_frame.py", line 126, in queueFrameCapture
    raise VimbaException(errorCode)
pymba.vimba_exception.VimbaException: Other error.

python 3.5

Dear all,

I am using a modified version of Pymba for Python 3.5.
There are several challenges if Pymba is ported to Python 3.5.1, Windows 7, 64 bit
major issue:

 from ctypes.util import find_msvcrt
 find_mscvct()

This code, located in vimbadll, does not work in Python 3.5.1, see python bug 26727
For some reason, the find_mscvcrt does not work and returns "none". I know fixed it with:

_cruntime = cdll.LoadLibrary('msvcr100.dll')

This works but according to [python bug 26727] my expectation 'msvcr100.dll' is incorrect.
minor issues:

print "something" should be print("something")

byte strings --> in python 3 you need to use encode and decode.
New style imports i.e.;

from . import vimbastructure as structs
from .vimbaobject import VimbaObject

Pixel Format BayerBG8

Hello,
Really love Pymba, just startet testing it with my AV camera Mako on Linux and it works like a charm.
I have one problem when It comes to the Pixel format BayerBG8 which seems to be the default setting in my Mako camera. Ive changed it in the camera to one that Pymba supports and it works, but it reduces frame rate by quite a lot. Ive also tried manipulating the VibaFrame.py PIXEL_FORMAT variable from "BayerGR8" to "BayerBG8" and tried 1,3,4 as values. I get an image on 1 but it is black and white.
Is there a way to get around this?

Run on 32 bit or arm?

I am trying to run pymba on an arm based processor (Jetson Development board running the Tegra K1 Processor).

Error Generated
from vimbadll import VimbaDLL File "/usr/local/lib/python2.7/dist-packages/pymba-0.1-py2.7.egg/pymba/vimbadll.py", line 21, in <module> "GENICAM_GENTL64_PATH"), "you need your GENICAM_GENTL64_PATH environment set. Make sure you have Vimba installed, and you have loaded the /etc/profile.d/ scripts"

I tried editing /usr/local/lib/python2.7/dist-packages/pymba-0.1-py2.7.egg/pymba/vimbadll.py and changing

else: _cruntime = CDLL("libc.so.6") dll_loader = cdll assert os.environ.get( "GENICAM_GENTL64_PATH"), "you need your GENICAM_GENTL64_PATH environment set. Make sure you have Vimba installed, and you have loaded the /etc/profile.d/ scripts" vimba_dir = "/".join(os.environ.get("GENICAM_GENTL64_PATH").split("/") [1:-3]) vimbaC_path = "/" + vimba_dir + "/VimbaC/DynamicLib/x86_64bit/libVimbaC.so"

to

else: _cruntime = CDLL("libc.so.6") dll_loader = cdll assert os.environ.get( "GENICAM_GENTL32_PATH"), "you need your GENICAM_GENTL32_PATH environment set. Make sure you have Vimba installed, and you have loaded the /etc/profile.d/ scripts" vimba_dir = "/".join(os.environ.get("GENICAM_GENTL32_PATH").split("/") [1:-3]) vimbaC_path = "/" + vimba_dir + "/VimbaC/DynamicLib/arm_32bit/libVimbaC.so"

I thought this would simply change the .so file used from the 64 bit version to the 32 bit version but that only generated a new error:

Traceback (most recent call last): File "vimba-streamer.py", line 1, in <module> from pymba import * File "/usr/local/lib/python2.7/dist-packages/pymba-0.1-py2.7.egg/pymba/__init__.py", line 2, in <module> from vimba import Vimba File "/usr/local/lib/python2.7/dist-packages/pymba-0.1-py2.7.egg/pymba/vimba.py", line 3, in <module> from vimbadll import VimbaDLL File "/usr/local/lib/python2.7/dist-packages/pymba-0.1-py2.7.egg/pymba/vimbadll.py", line 30, in <module> class VimbaDLL(object): File "/usr/local/lib/python2.7/dist-packages/pymba-0.1-py2.7.egg/pymba/vimbadll.py", line 112, in VimbaDLL _vimbaDLL = dll_loader.LoadLibrary(vimbaC_path) File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary return self._dlltype(name) File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__ self._handle = _dlopen(self._name, mode) OSError: /opt/Vimba_1_3/VimbaC/DynamicLib/arm_32bit/libVimbaC.so: cannot open shared object file: No such file or directory

I checked and yes, there is a such file or directory as /opt/Vimba_1_3/VimbaC/DynamicLib/arm_32bit/libVimbaC.so, but regardless this does not work. Does anyone have any thoughts or suggestions? Thank you.

GUI

Has anyone made a GUI for pymba? e.g. using pyQT, wxPython

Wrong buffer initialization in vimbafeature._getStringFeature()

Hi!
I get an exception when I try to access string features from my AVT cameras.

Traceback (most recent call last):
...
File "C:\Anaconda3\envs...\lib\site-packages\pymba\vimbaobject.py", line 37, in getattr
return VimbaFeature(attr, self._handle).value
File "C:\Anaconda3\envs...\lib\site-packages\pymba\vimbafeature.py", line 28, in value
return self._getSetTypeFuncs[self._info.featureDataType]0
File "C:\Anaconda3\envs...\lib\site-packages\pymba\vimbafeature.py", line 206, in getStringFeature
valueToGet = create_string_buffer('\000' * bufferSize)
File "C:\Anaconda3\envs...\lib\ctypes_init
.py", line 63, in create_string_buffer
raise TypeError(init)
TypeError:

The exception is raised in the create_string_buffer() function in ctypes that expects either and int or an bytes parameter.

This is easy to fix by changing in vimbafeature.py the line (#206 as of now) from
valueToGet = create_string_buffer('\000' * bufferSize)
to
valueToGet = create_string_buffer(bufferSize)

Type error reading string features

I am working on an embedded board (iMX6) with Python 3.4 and get a type error reading string features like that:

    with pymba.Vimba() as vimba:
        camera = vimba.getCamera(cameraSerialNumber)
        camera.openCamera()
        currentCameraModelName = camera.DeviceModelName

It looks like the call to ctypes create_string_buffer in vimbafeature.py is wrong:

    def _getStringFeature(self):
        """
        Get the value of a string feature.

        :returns: string -- value of the specified feature.
        """

        # create args
        bufferSize = 256
        valueToGet = create_string_buffer('\000' * bufferSize)
        sizeFilled = c_uint32()

        errorCode = VimbaDLL.featureStringGet(self._handle,
                                              self._name,
                                              valueToGet,
                                              bufferSize,
                                              byref(sizeFilled))
        if errorCode != 0:
            raise VimbaException(errorCode)
        return valueToGet.value.decode()

The function is called with a string which raises a TypeError in cytpes/__init__.py:

def create_string_buffer(init, size=None):
    """create_string_buffer(aBytes) -> character array
    create_string_buffer(anInteger) -> character array
    create_string_buffer(aString, anInteger) -> character array
    """
    if isinstance(init, bytes):
        if size is None:
            size = len(init)+1
        buftype = c_char * size
        buf = buftype()
        buf.value = init
        return buf
    elif isinstance(init, int):
        buftype = c_char * init
        buf = buftype()
        return buf
    raise TypeError(init)

I was able to resolve the issue by changing the call to create_string_buffer with a bytearray as argument:
valueToGet = create_string_buffer(('\000' * bufferSize).encode())

But: as reading string features is quite common, I wonder why no one else had this issue before. Am I missing something?

GigE Camera Outputs All Zero Array Unless Vimba Viewer Is Run First

I am using the Mako camera and running the test_cameras script in the 'tests' folder. When printing out the 'moreUsefulImgData' array, it outputs all zeroes, unless I run the Vimba Viewer prior. Is there something that I need to set prior to acquisition? Like setting up the packet size or image format?

The test code:

#!/usr/bin/python
from __future__ import absolute_import, print_function, division
from pymba import *
import time


def test_cameras():
    # start Vimba
    with Vimba() as vimba:
        # get system object
        system = vimba.getSystem()

        # list available cameras (after enabling discovery for GigE cameras)
        if system.GeVTLIsPresent:
            system.runFeatureCommand("GeVDiscoveryAllOnce")
            time.sleep(0.2)

        cameraIds = vimba.getCameraIds()
        for cameraId in cameraIds:
            print('Camera ID:', cameraId)

        # get and open a camera
        camera0 = vimba.getCamera(cameraIds[0])
        camera0.openCamera()

        # list camera features
        cameraFeatureNames = camera0.getFeatureNames()
        for name in cameraFeatureNames:
            print('Camera feature:', name)

        # get the value of a feature
        print(camera0.AcquisitionMode)

        # set the value of a feature
        camera0.AcquisitionMode = 'SingleFrame'

        # create new frames for the camera
        frame0 = camera0.getFrame()  # creates a frame
        frame1 = camera0.getFrame()  # creates a second frame

        # announce frame
        frame0.announceFrame()

        # capture a camera image
        camera0.startCapture()
        frame0.queueFrameCapture()
        camera0.runFeatureCommand('AcquisitionStart')
        camera0.runFeatureCommand('AcquisitionStop')
        frame0.waitFrameCapture()

        # get image data...
        imgData = frame0.getBufferByteData()

        # ...or use NumPy for fast image display (for use with OpenCV, etc)
        import numpy as np

        moreUsefulImgData = np.ndarray(buffer=frame0.getBufferByteData(),
                                       dtype=np.uint8,
                                       shape=(frame0.height,
                                              frame0.width,
                                              1))
        print(moreUsefulImgData)
        # clean up after capture
        camera0.endCapture()
        camera0.revokeAllFrames()

        # close camera
        camera0.closeCamera()


if __name__ == '__main__':
    test_cameras()

Camera object has no attribute GVSPAdjustPacketSize in v0.3.2

First of all thank you for your work, I use Pymba for another camera and it works great.
I tried to use it for my new camera Mako U-130-B (USB3.0) and i got the message "Camera object has no attribute GVSPAdjustPacketSize"
I checked the previous post and I saw that you tried to fix the problem with the version 0.3.2 but I'm using this version and I still got the issue.
For now it isn't really a problem because I can still avoiding it by writing "camera_NIR.open(adjust_packet_size=False". But this solution is not perfect because I can't change the exposure time or the pixel format ("VimbaException: Operation is invalid with the current access mode"). However I can still change it manually with Vimba viewer.
I just wanted you to know that the issue is still present.
Best regards.

Call to Vimba._getInterfaceInfos crashes python

Steps to reproduce:

from pymba import Vimba

print("Starting Vimba")
vimba = Vimba()
vimba.startup()

print("Vimba Version: %s" % vimba.getVersion())

#system = vimba.getSystem()
#system.runFeatureCommand('GeVDiscoveryAllOnce')

infos = vimba._getInterfaceInfos()  # --> Crash

print("Vimba Shutdown")
vimba.shutdown()

Debugging lead to the fact that the python crashes at line ~83 in vimba.py:

interfaceInfoArray = (structs.VimbaInterfaceInfo * numInterfaces)()

where numInterfaces = 4

Environment:
Python Version: 2.7.6, 32bit
Vimba Version: 1.5.0
OS Version: Windows 7, 64bit
Cameras: 2 x Manta G504

Liveview at 30 fps

Hi,

this wrapper is genius!
Thanks for sharing it to the world.

However, trying several things (and your live preview example), I can only loop with 30 fps, although my AVT Pike can stream with 200 fps. Accessing it via pymba and printing the AcquisitionFrameRate, it displays me something between 205 and 211 (what would be fine). And, when I trying to stream via the Vimba Viewer, I get my 200 fps.

Regardless of displaying it via opencv or not, it still remains at roughly 30 fps.
Is there a way to enhance this framerate?

Thanks for replying
Anki

getCameraIds() fails in Vimba 1.3

Hi

Downloaded and installed PvAPI, Vimba and pymba and ran into a problem while executing vimba.getCameraIds()
Apparently in Vimba 1.3.0 the vimba dll call camerasList return error code -9 (VmbErrorMoreData) even though a zero is passed for the length of the array.
Not sure if this is new actually, but for now I just changed line 93 in vimba.py to:
if errorCode != 0 and errorCode!= -9: # The last check is for allowing incorrect array size error to be ignored
and I can sucessfully discover cameras.

Camera List not working.

Came across this and very interested in incorporating support into SimpleCV (http://simplecv.org). We currently have support for the old PvAPI driver but I would like to update to handle VIMBA.

I have installed under windows, I have confirmed that VIMBA is installed correctly and I can view streaming images in real time through the VimbaViewer.

It appears trying to walk through the code the call just returns 0:

vimba._getCameraInfos()
the line:
numCameras = numFound.value

is 0. I have a feeling this is coming from the driver not necessarily your software. I am using a GigE camera for testing, unfortunately I have about 10 sitting around Manta & Mako, but no 1394 (firewire) based to confirm if GigE is the culprit. Any ideas in solving this would be greatly appreciated as I would also like help port it to linux. I'm also using a 64bit machine and using the 64bit driver.

Capture of multiple frames

In a test construction we try to capture frames with a very high framerate. The camera is taking pictures behind a strobe, which is turning with frequency of about 50 Hz and has a small window. The signal of the strobe can be used as an external trigger. So the plan is to start taking multiple frames (about 300) after the external trigger (maybe with some delay) with a high framerate (about 2000 to 3000 fps) and then saving the frames to a file. When the trigger is disabled the framerate is achieved. But when the trigger is activated only 25 fps are possible, even when "cam.AcquisitionFrameCount = 300". We tried different combinations of TriggerSelector (AcquisitionStart, AcquisitionRecord, FrameStart) and AcquisitionMode (Continuous, Multiframe, Recorder).
It seems that only one frame is captured or saved after the trigger.
So the question is: Do we have to use another function to get multiple frames after the trigger than "frame.queueFrameCapture()" and "frame.getBufferByteData()"?
How does the recorder work and what are the functions for that? Can you provide an example for capturing multiple frames at once?

Informations in setup.py

Are the informations in setup.py still up to date?

  • is SightMachine the author?
  • why points the url to simplecv.org?
  • why are cv2, cv, pygame, pil and svgwrite required packages for pymba?
  • are all keywords necessary?

I don't want to critizice anyone, i just stumbled across the setup.py and asked myself if the mentioned points are correct.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.