From 9082f0979d327dc748ed78d8195aaed955f01b31 Mon Sep 17 00:00:00 2001 From: Andrew Humphreys Date: Wed, 25 Mar 2026 09:06:35 -0400 Subject: [PATCH 1/2] Modified "getNextNumPyFrame(...)" method The prior implementation of the getNextNumPyFrame method used the "frame.size" method to determine the buffer size; however the value of interest is not the size itself but the number of bytes. The consequence of this was that the datatype of the array had to be specifically a 1-byte datatype (i.e., uint8). If data in question is 16 bit for example, the user would need to supply one view of the buffer to the Pixielink Wrapper API using an 8-bit datatype, and use another view (with `dtype='>u2'` for example) to view or manipulate the data. Doing this may be useful for unpacking 12-bit packed, it is not always helpful. --- pixelinkWrapper/pixelink.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pixelinkWrapper/pixelink.py b/pixelinkWrapper/pixelink.py index 5f75431..02c64d8 100644 --- a/pixelinkWrapper/pixelink.py +++ b/pixelinkWrapper/pixelink.py @@ -1376,14 +1376,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,) From 735f5da090ffc2bae3b3bfebd0c14484fd48c42c Mon Sep 17 00:00:00 2001 From: Andrew Humphreys Date: Wed, 25 Mar 2026 09:22:18 -0400 Subject: [PATCH 2/2] Modified __init__ of PxLApi Class The prior behavior looked for the `libPxLApi.so` shared object in proper install directories using the `CDLL` method (i.e., `/usr/lib`). This file itself is a Symlink, so the find command was also used to lookup the full file path in the $PIXELINK_SDK_LIB directory. Since we are already looking it up, I added support for directly importing the DLL file from the result of the find command if it is not found by the `CDLL` method first. This means that the SDK need not be "properly" installed, but simply placed in a directory labelled with $PIXELINK_SDK_LIB for the library to work. Since standalone files are not offered for the windows version, but simply a bundled installer I left the windows behavior in tact as there is not a strong use case for this functionality on windows. --- pixelinkWrapper/pixelink.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pixelinkWrapper/pixelink.py b/pixelinkWrapper/pixelink.py index 02c64d8..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"