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

API not started error VmbError.ApiNotStarted: -2 #90

Open hugoleon77 opened 2 years ago

hugoleon77 commented 2 years ago

Have had very many issues getting this library to work.

I am running a Windows machine with a Guppy Pro camera and Anaconda 4.11 with python 3.9 and jupyter

This is my latest error and am not sure how to resolve this

---------------------------------------------------------------------------VimbaCError Traceback (most recent call last)~\VimbaPython_Source\vimba\camera.py in _open(self) 906 try:--> 907 call_vimba_c('VmbCameraOpen', self.info.cameraIdString, self.access_mode, 908 byref(self.__handle)) ~\VimbaPython_Source\vimba\util\tracer.py in wrapper(*args, *kwargs) 133 else:--> 134 return func(args, *kwargs) 135 ~\VimbaPython_Source\vimba\c_binding\vimba_c.py in call_vimba_c(func_name, args) 752 global _lib_instance--> 753 getattr(_lib_instance, func_name)(args) 754 ~\VimbaPython_Source\vimba\c_binding\vimba_c.py in _eval_vmberror(result, func, args) 670 if result not in (VmbError.Success, None):--> 671 raise VimbaCError(result) 672 VimbaCError: VimbaCError(<VmbError.ApiNotStarted: -2>)

The above exception was the direct cause of the following exception: VimbaCameraError Traceback (most recent call last)C:\Users\JAMES~1.HAL\AppData\Local\Temp/ipykernel_10360/2024278461.py in 1 with Vimba. get_instance () as vimba: 2 cams = vimba . get_all_cameras ()----> 3 with cams [0] as cam: 4 frame = cam. get_frame () 5 frame. convert_pixel_format (PixelFormat.Mono8)~\VimbaPython_Source\vimba\util\tracer.py in wrapper(*args, kwargs) 132 133 else:--> 134 return func(*args, *kwargs) 135 136 return wrapper ~\VimbaPython_Source\vimba\camera.py in enter(self) 360 def enter(self): 361 if not self.context_cnt:--> 362 self._open() 363 364 self.context_cnt += 1~\VimbaPython_Source\vimba\util\tracer.py in wrapper(args, kwargs) 132 133 else:--> 134 return func(*args, kwargs) 135 136 return wrapper ~\VimbaPython_Source\vimba\util\context_decorator.py in wrapper(*args, *kwargs) 42 def wrapper(args, kwargs): 43 args[0]._context_entered = True---> 44 return func(*args, **kwargs) 45 46 return wrapper ~\VimbaPython_Source\vimba\camera.py in _open(self) 922 exc = VimbaCameraError(repr(err)) 923 --> 924 raise exc from e 925 926 self.__feats = discover_features(self.__handle)VimbaCameraError: <VmbError.ApiNotStarted: -2>

BernardoLuck commented 2 years ago

Hi,

From your description I see that you are using Python 3.6. VimbaPython requieres Python version 3.7 or higher

Best regards

Bernardo

hugoleon77 commented 2 years ago

Hi,

From your description I see that you are using Python 3.6. VimbaPython requieres Python version 3.7 or higher

Best regards

Bernardo

Sorry that was a typo, we are actually on python 3.9

wonwon0 commented 1 year ago

i have this error too. If you found the cause please share.

Teresa-AlliedVision commented 1 year ago

Hi, can you give an example of your code and/or check that the applicable commands are within the with Vimba.get_instance(): statement? Cheers, Teresa

4n1rudh-fh commented 1 year ago

Hey @wonwon0, as mentioned by @Teresa-AlliedVision, please make sure to indent your code such that it is within the VmbSystem.get_instance() with-block. For whatever functionality (in this case, saving an image from the camera using VimbaX API), it should be written as given below:

from vmbpy import *
import cv2

with VmbSystem.get_instance() as vmb:
        cams = vmb.get_all_cameras()
        print("Cameras found: {}".format(len(cams)))

        with cams[0] as cam:
            frame = cam.get_frame()
            frame.convert_pixel_format(PixelFormat.Mono8)
            cv2.imwrite("frame.jpg", frame.as_opencv_image())

This example code can be found here.