alliedvision / VimbaPython

Old Allied Vision Vimba Python API. The successor to this API is VmbPy
BSD 2-Clause "Simplified" License
93 stars 40 forks source link

The VimbaPython Example runs once and gets stuck in capturing mode, camera has to be detached and attached again. #111

Closed Lineup12 closed 2 years ago

Lineup12 commented 2 years ago

Hello, I use an Allied Vision 1800 U-120c. I have an issue running example python code synchronous_grab.py: When I attach the Camera to the Computer with the USB and run the synchronous_grab.py for the first time it runs smoothly and I get 10 frames. The Terminal output: `////////////////////////////////////////// /// Vimba API Synchronous Grab Example /// //////////////////////////////////////////

Got Frame(id=0, status=FrameStatus.Complete, buffer=0x7ff0b40ef010) Got Frame(id=1, status=FrameStatus.Complete, buffer=0x556d43281e20) Got Frame(id=2, status=FrameStatus.Complete, buffer=0x556d43989e60) Got Frame(id=3, status=FrameStatus.Complete, buffer=0x556d43d0de70) Got Frame(id=4, status=FrameStatus.Complete, buffer=0x556d44091e80) Got Frame(id=5, status=FrameStatus.Incomplete, buffer=0x556d44415e90) Got Frame(id=6, status=FrameStatus.Complete, buffer=0x556d44799ea0) Got Frame(id=7, status=FrameStatus.Complete, buffer=0x556d44b1deb0) Got Frame(id=8, status=FrameStatus.Complete, buffer=0x556d44ea1ec0) Got Frame(id=9, status=FrameStatus.Complete, buffer=0x556d45225ed0) `

However if I run the code again, I get an error:

vimba.error.VimbaTimeout: Frame capturing on Camera 'DEV_XXXXXXXXXXXX' timed out.

The whole terminal output: `////////////////////////////////////////// /// Vimba API Synchronous Grab Example /// //////////////////////////////////////////

Traceback (most recent call last): File "/home/s/.pyenv/versions/3.7.13/lib/python3.7/site-packages/vimba/camera.py", line 233, in wait_for_frames timeout_ms) File "/home/s/.pyenv/versions/3.7.13/lib/python3.7/site-packages/vimba/util/tracer.py", line 134, in wrapper return func(*args, *kwargs) File "/home/s/.pyenv/versions/3.7.13/lib/python3.7/site-packages/vimba/c_binding/vimba_c.py", line 753, in call_vimba_c getattr(_lib_instance, func_name)(args) File "/home/s/.pyenv/versions/3.7.13/lib/python3.7/site-packages/vimba/c_binding/vimba_c.py", line 671, in _eval_vmberror raise VimbaCError(result) vimba.c_binding.vimba_common.VimbaCError: VimbaCError(<VmbError.Timeout: -12>)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "synchronous_grab.py", line 122, in main() File "synchronous_grab.py", line 112, in main for frame in cam.get_frame_generator(limit=10, timeout_ms=3000): File "/home/s/.pyenv/versions/3.7.13/lib/python3.7/site-packages/vimba/camera.py", line 324, in _frame_generator fsm.wait_for_frames(timeout_ms) File "/home/s/.pyenv/versions/3.7.13/lib/python3.7/site-packages/vimba/camera.py", line 299, in wait_for_frames self.__state.wait_for_frames(timeout_ms) File "/home/s/.pyenv/versions/3.7.13/lib/python3.7/site-packages/vimba/util/tracer.py", line 134, in wrapper return func(*args, **kwargs) File "/home/s/.pyenv/versions/3.7.13/lib/python3.7/site-packages/vimba/camera.py", line 236, in wait_for_frames raise _build_camera_error(self.context.cam, e) from e vimba.error.VimbaTimeout: Frame capturing on Camera 'DEV_1AB22C01574C' timed out.`

After the first run of the synchronous_grab.py the light on the back of the camera starts blinking and keeps blinking. If I detach and reattach the USB cable, the light stops blinking and I can run the code and get frames just one more time.

Could you please tell me how I can get the frames over and over and don't have to detach the camera for every run?

nordeh commented 2 years ago

Hi,

it seems like the acquisition is still active after the first run for any reason. Please add to setup_camera(): cam.AcquisitionStop.run()

Thanks, Norman

Lineup12 commented 2 years ago

Thanks for your response. How should I add it? I have tried multiple way but the result is the same. It still keeps blinking. and have to be detached to work again.

def setup_camera(cam: Camera):
    with cam:
        # Try to adjust GeV packet size. This Feature is only available for GigE - Cameras.
        try:
            cam.GVSPAdjustPacketSize.run()

            while not cam.GVSPAdjustPacketSize.is_done():
                pass

        except (AttributeError, VimbaFeatureError):
            pass
            cam.AcquisitionStop.run()

and also I added it in main():

  def main():
      print_preamble()
      cam_id = parse_args()

      with Vimba.get_instance():
          with get_camera(cam_id) as cam:
                setup_camera(cam)

              # Acquire 10 frame with a custom timeout (default is 2000ms) per frame acquisition.
              for frame in cam.get_frame_generator(limit=10, timeout_ms=5000):
                  print('Got {}'.format(frame), flush=True)
              cam.AcquisitionStop.run()

it did not solve it. I still get the blinking light. my dmesg:

[ 1008.709343] usb 2-3: USB disconnect, device number 3 [ 1013.926952] usb 2-3: new SuperSpeed USB device number 4 using xhci_hcd [ 1013.955696] usb 2-3: New USB device found, idVendor=1ab2, idProduct=0001, bcdDevice= 1.00 [ 1013.955710] usb 2-3: New USB device strings: Mfr=2, Product=3, SerialNumber=4 [ 1013.955716] usb 2-3: Product: ALVIUM 1800 U-120c [ 1013.955720] usb 2-3: Manufacturer: Allied Vision [ 1013.955724] usb 2-3: SerialNumber: XXXXX ( I changed this )

In the Viewer I get this error when I start and stop and start the viewer: Name: Allied Vision 1800 U-120c Model: 1800 U-120c S/N: 01VT8 ID: DEV_XXXXXXXXX ( I changed this ) Interface ID: VimbaUSBInterface_0x0 17:00:44:250 ERROR: ControllerTree returned: -19 (A multiple register read or write was partially completed) 17:00:46:628 ERROR: GetFeatures returned: -19 (A multiple register read or write was partially completed)

nordeh commented 2 years ago

Please contact our support team to figure out if it's an issue of your camera or USB controller: https://www.alliedvision.com/de/kontakt/technischer-support-reparatur-/-rma/

arunprakash-avt commented 2 years ago

Hi, In the main please replace it with the above code the following code

def main(): print_preamble() cam_id = parse_args()

  with Vimba.get_instance():
      with get_camera(cam_id) as cam:
            cam.AcquisitionStop.run()
            setup_camera(cam)

          # Acquire 10 frame with a custom timeout (default is 2000ms) per frame acquisition.
          for frame in cam.get_frame_generator(limit=10, timeout_ms=5000):
              print('Got {}'.format(frame), flush=True)
          cam.AcquisitionStop.run()

Thanks Arun Prakash

Lineup12 commented 2 years ago

The problem was that I was using a virtual machine. #106

I have installed everything in my normal daily machine. And it works fine.

without the virtual machine the camera works fine with the examples. However when I use usb3 and I run the synchronous_grab.py the camera starts blinking and does not stop. The script can run again with no problem but the light keeps blinking. This does not happen when I use usb2. The light stops blinking after the execution of the program is done.