I’m trying to make a call to an (https://www.autelrobotics.com/doc/609/) via a DLL in Python and the app crashes before the call returns. The Windows error logs show it to be a “STATUS_STACK_BUFFER_OVERRUN” exception, but I would think would mean that one of the variables being passed isn’t sized correctly.
import ctypes
import numpy as np
import faulthandler
faulthandler.enable()
sdk_path = 'dependencies/autel/AutelIrTempParserSDK.dll'
ir_temp_parse = ctypes.CDLL(sdk_path)
# Define the data structures
class Autel_IR_INFO_S(ctypes.Structure):
_fields_ = [
('tag', ctypes.c_uint16),
('len', ctypes.c_uint16),
('show_value', ctypes.c_char * 512),
('str_value', ctypes.c_char * 512),
('num_value', ctypes.c_int)
]
class QPointF(ctypes.Structure):
_fields_ = [
('x', ctypes.c_int),
('y', ctypes.c_int)
]
class TempStatInfo(ctypes.Structure):
_fields_ = [
('max', ctypes.c_float),
('min', ctypes.c_float),
('avg', ctypes.c_float),
('maxPoint', QPointF),
('minPoint', QPointF)
]
# Define the function prototypes
ir_temp_parse.GetIrPhotoTempInfo.argtypes = [
ctypes.c_char_p, # filepath
ctypes.c_int, # w
ctypes.c_int, # h
ctypes.POINTER(TempStatInfo), # tempStatInfo
ctypes.POINTER(ctypes.c_void_p), # result (map<string, Autel_IR_INFO_S>)
ctypes.POINTER(ctypes.POINTER(ctypes.c_float)) # tempArray (2D array)
]
ir_temp_parse.GetIrPhotoTempInfo.restype = ctypes.c_int
ir_temp_parse.GetRawTempData.argtypes = [
ctypes.c_char_p, # filepath
ctypes.c_int, # w
ctypes.c_int, # h
ctypes.POINTER(ctypes.c_int16) # rawTempData
]
ir_temp_parse.GetRawTempData.restype = ctypes.c_int
filepath = b'images/autel/IRX_0001_south.jpg'
w, h = 640, 512
tempStatInfo = TempStatInfo()
result = ctypes.cast(ctypes.c_void_p(), ctypes.POINTER(ctypes.c_void_p))
tempArray = (ctypes.POINTER(ctypes.c_float) * h)()
for i in range(h):
tempArray[i] = (ctypes.c_float * w)()
ret = ir_temp_parse.GetIrPhotoTempInfo(filepath, w, h, ctypes.byref(tempStatInfo), result, tempArray)
if ret == 0:
print("GetIrPhotoTempInfo succeeded!")
# Access the results as needed
else:
print("GetIrPhotoTempInfo failed!")
#ret = _GetRawTempData(filepath, 640, 512, rawTempData)
Screenshots from SDK