Skip to content

Commit

Permalink
Fix IS_INVALID_BUFFER_SIZE bug. Consider absolute X and Y for memory … (
Browse files Browse the repository at this point in the history
anqixu#107)

* Fix IS_INVALID_BUFFER_SIZE bug when trying to use absolute X and Y for memory allocation (caused an ini or on cam setting)
* Avoid bug by intentionally ignoring the absolute positioning
  • Loading branch information
singhjeet1989 authored Jun 29, 2021
1 parent ae8a02e commit 749ee7a
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/ueye_cam_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,34 @@ INT UEyeCamDriver::syncCamConfig(string dft_mode_str) {
cam_name_ << "] (" << err2str(is_err) << ")");
return is_err;
}

// Check if absolute AOI positioning is set in the cam (e.g. by an .ini)
// if yes, deactivate it as it is intentionally not supported by this driver
UINT start_posX_absolute = 0;
UINT start_posY_absolute = 0;

if ((is_err = is_AOI(cam_handle_, IS_AOI_IMAGE_GET_POS_X_ABS,
(void*) &start_posX_absolute, sizeof(start_posX_absolute))) != IS_SUCCESS) {
ERROR_STREAM("Could not retrieve Area Of Interest (AOI) information for parameter start X absolute for [" <<
cam_name_ << "] (" << err2str(is_err) << ")");
return is_err;
}

if ((is_err = is_AOI(cam_handle_, IS_AOI_IMAGE_GET_POS_Y_ABS,
(void*) &start_posY_absolute, sizeof(start_posY_absolute))) != IS_SUCCESS) {
ERROR_STREAM("Could not retrieve Area Of Interest (AOI) information for parameter start Y absolute for [" <<
cam_name_ << "] (" << err2str(is_err) << ")");
return is_err;
}

if ((start_posX_absolute == IS_AOI_IMAGE_POS_ABSOLUTE) || (start_posY_absolute == IS_AOI_IMAGE_POS_ABSOLUTE)) {
cam_aoi_.s32X = cam_aoi_.s32X & ~(IS_AOI_IMAGE_POS_ABSOLUTE); // Remove the bit which was set by the bitwise OR with IS_AOI_IMAGE_POS_ABSOLUTE
cam_aoi_.s32Y = cam_aoi_.s32Y & ~(IS_AOI_IMAGE_POS_ABSOLUTE);
WARN_STREAM("AOI absolute positioning intentionally not supported, ignoring for [" << cam_name_ << "]");
if ((is_err = setResolution(cam_aoi_.s32Width, cam_aoi_.s32Height,
cam_aoi_.s32X, cam_aoi_.s32Y, false)) != IS_SUCCESS) return is_err;
}

color_mode_ = is_SetColorMode(cam_handle_, IS_GET_COLOR_MODE);
if (!isSupportedColorMode(color_mode_)) {
WARN_STREAM("Current color mode (IDS format: " << colormode2str(color_mode_)
Expand Down Expand Up @@ -1173,10 +1201,10 @@ INT UEyeCamDriver::reallocateCamBuffer() {
cam_name_ << "] (" << err2str(is_err) << ")");
return is_err;
}

// Allocate new memory section for IDS driver to use as frame buffer
if ((is_err = is_AllocImageMem(cam_handle_, cam_aoi_.s32Width, cam_aoi_.s32Height,
bits_per_pixel_, &cam_buffer_, &cam_buffer_id_)) != IS_SUCCESS) {
if ((is_err = is_AllocImageMem(cam_handle_, cam_aoi_.s32Width , cam_aoi_.s32Height,
bits_per_pixel_, &cam_buffer_, &cam_buffer_id_)) != IS_SUCCESS) {
ERROR_STREAM("Failed to allocate " << cam_aoi_.s32Width << " x " << cam_aoi_.s32Height <<
" image buffer for [" << cam_name_ << "]");
return is_err;
Expand Down

0 comments on commit 749ee7a

Please sign in to comment.