diff --git a/pixelinkWrapper/pixelink.py b/pixelinkWrapper/pixelink.py index 5f75431..e20f1af 100644 --- a/pixelinkWrapper/pixelink.py +++ b/pixelinkWrapper/pixelink.py @@ -94,7 +94,6 @@ def _isApiSupported(minApiNumbers, curApiNumbers): else: # on Linux ## Loads Pixelink API library - _Api = CDLL('libPxLApi.so') ## Verifies that the loaded Pixelink API version is supported _minApiVersion = "4.2.2.11" # minimum Pixelink API version supported @@ -103,8 +102,15 @@ def _isApiSupported(minApiNumbers, curApiNumbers): _completedProcess = subprocess.run(_pxlApiSearch, shell=True, text=True, capture_output=True, check=True) _pxlApiPath = _completedProcess.stdout # Finds current version of Pixelink API + try: + # first try using the SimLink to the SO: + _Api = CDLL('libPxLApi.so') + except OSError: + # if this fails, use the results of the + # find command inside $PIXELINK_SDK_LIB + _Api = CDLL(_pxlApiList.split("\n")[-1]) _pxlApiList = _pxlApiPath.split("/") - _curApiVersion = _pxlApiList[len(_pxlApiList)-1].replace("libPxLApi.so.", "").replace("libPxLApiLite.so.", "").strip() + _curApiVersion = _pxlApiList[-1].replace("libPxLApi.so.", "").replace("libPxLApiLite.so.", "").strip() # Checks if the loaded Pixelink API is supported if _isApiSupported(_minApiVersion.split("."), _curApiVersion.split(".")): print("\nWARNING: Pixelink API Version {0} detected. This Python wrapper was designed to\n" @@ -1376,14 +1382,14 @@ def getNextNumPyFrame(hCamera, frame=None): """ ctFrameDesc = PxLApi._FrameDesc() ctFrameDesc.uSize = sizeof(ctFrameDesc) # The API needs to know the version of descriptor - if (frame is None or (0 == frame.size)): + if (frame is None or (0 == frame.nbytes)): # Special case where the user doesn't want a frame with this call -- rather just (sw) triggers a frame for a callback ctBufferSize = -1 rc = PxLApi._Api.PxLGetNextFrame(hCamera, ctBufferSize, 0, byref(ctFrameDesc)) if(not(PxLApi.apiSuccess(rc))): return (rc,) else: - ctBufferSize = frame.size + ctBufferSize = frame.nbytes rc = PxLApi._Api.PxLGetNextFrame(hCamera, ctBufferSize, frame.ctypes.data_as(c_void_p), byref(ctFrameDesc)) if(not(PxLApi.apiSuccess(rc))): return (rc,)