it seems worked for all types of ROI

This commit is contained in:
Timur A. Fatkhullin 2024-12-18 16:56:01 +03:00
parent 192636aeda
commit 86eb2b8ba7
2 changed files with 49 additions and 11 deletions

View File

@ -99,8 +99,10 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptr<acq_params_
// compute image dimension
// NOTE: _acqParams->roiWidth and _acqParams->roiHeight are expected in CCD pixels (not binned)!!!
// auto div = std::div(_acqParams->roiWidth - _acqParams->roiStartX, _acqParams->binX);
auto div = std::div(_acqParams->roiWidth, _acqParams->binX);
auto dimx = div.quot + (div.rem ? 1 : 0);
// div = std::div(_acqParams->roiHeight - _acqParams->roiStartY, _acqParams->binY);
div = std::div(_acqParams->roiHeight, _acqParams->binY);
auto dimy = div.quot + (div.rem ? 1 : 0);
@ -111,12 +113,21 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptr<acq_params_
auto ldiv = std::lldiv(npix, _manager->_dimCCD[0]);
_imageBufferRows = ldiv.quot + (ldiv.rem ? 1 : 0);
bool gap = false;
if ((_acqParams->roiWidth + _acqParams->roiStartX) < _manager->_dimCCD[0]) {
/* IT SEEMS IF MAX ROI X-COORDINATE IS LESS THAN CCD DIM
* EAGLE CAMERA CONTROLLER SETUP READING FOR WIDTH+1 ROI!!! */
gap = true;
++_imageBufferRows;
}
// _imageBufferRows = static_cast<size_t>(std::ceil(npix / _manager->_dimCCD[0]));
// read size
size_t sz = _imageBufferRows * _manager->_dimCCD[0];
try {
// sz = _manager->_dimCCD[0] * _manager->_dimCCD[1];
if (_imageBufferSize < sz) {
_manager->logDebug("Reallocate image buffer to {} elements", sz);
_imageBufferSize = sz;
@ -126,6 +137,9 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptr<acq_params_
auto log_str = std::format("pxd_readushort({}, 1, 0, 0, -1, {}, {}, {}, \"{}\")", _manager->_cameraUnitmap,
_imageBufferRows, (void*)_imageBuffer.get(), _imageBufferSize, color_space);
// _manager->xclibApiCall(pxd_readushort(_manager->_cameraUnitmap, 1, 0, 0, -1, -1,
// (ushort*)_imageBuffer.get(), _imageBufferSize, (char*)color_space),
// log_str);
_manager->xclibApiCall(pxd_readushort(_manager->_cameraUnitmap, 1, 0, 0, -1, _imageBufferRows,
(ushort*)_imageBuffer.get(), _imageBufferSize, (char*)color_space),
log_str);
@ -170,7 +184,19 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptr<acq_params_
fits_create_img(fitsFilePtr, USHORT_IMG, 2, naxes, &status);
_manager->logDebug("Write {} pixels to the HDU ...", npix);
fits_write_img(fitsFilePtr, TUSHORT, 1, npix, (void*)_imageBuffer.get(), &status);
if (gap) {
/* IT SEEMS IF MAX ROI X-COORDINATE IS LESS THAN CCD DIM
* EAGLE CAMERA CONTROLLER SETUP READING FOR WIDTH+1 ROI!!!
* SO ONE NEEDS TO WRITE IMAGE PER ROW WITH SKIPPING EXTRA PIXEL
* AT THE END OF EACH ROW
*/
auto ptr = _imageBuffer.get();
for (size_t i = 0; i < dimy; ++i) {
fits_write_img(fitsFilePtr, TUSHORT, i * dimx + 1, dimx, _imageBuffer.get(), &status);
}
} else {
fits_write_img(fitsFilePtr, TUSHORT, 1, npix, (void*)_imageBuffer.get(), &status);
}
// helper to convert std::string_view to C-lang null-terminated string

View File

@ -967,21 +967,33 @@ void RaptorEagleCCD::startAquisition()
// adjust geometry
auto dv = std::div(_dimCCD[0] - acq_pars->roiStartX, acq_pars->binX);
auto width_max = dv.quot + (dv.rem ? 1 : 0);
// auto dv = std::div(_dimCCD[0] - acq_pars->roiStartX, acq_pars->binX);
// auto width_max = dv.quot + (dv.rem ? 1 : 0);
dv = std::div(_dimCCD[1] - acq_pars->roiStartY, acq_pars->binY);
auto height_max = dv.quot + (dv.rem ? 1 : 0);
// dv = std::div(_dimCCD[1] - acq_pars->roiStartY, acq_pars->binY);
// auto height_max = dv.quot + (dv.rem ? 1 : 0);
if (acq_pars->roiWidth > width_max) {
acq_pars->roiWidth = width_max;
// if (acq_pars->roiWidth > width_max) {
// // acq_pars->roiWidth = width_max;
// logDebug("Adjust ROI width to {}", acq_pars->roiWidth);
// // (*this)[CAMERA_ATTR_ROI_WIDTH] = width_max;
// }
// if (acq_pars->roiHeight > height_max) {
// // acq_pars->roiHeight = height_max;
// logDebug("Adjust ROI height to {}", acq_pars->roiHeight);
// // (*this)[CAMERA_ATTR_ROI_HEIGHT] = height_max;
// }
auto xmax = acq_pars->roiStartX + acq_pars->roiWidth;
auto ymax = acq_pars->roiStartY + acq_pars->roiHeight;
if (xmax > _dimCCD[0]) {
acq_pars->roiWidth = _dimCCD[0] - acq_pars->roiStartX;
logDebug("Adjust ROI width to {}", acq_pars->roiWidth);
(*this)[CAMERA_ATTR_ROI_WIDTH] = width_max;
}
if (acq_pars->roiHeight > height_max) {
acq_pars->roiHeight = height_max;
if (ymax > _dimCCD[1]) {
acq_pars->roiHeight = _dimCCD[1] - acq_pars->roiStartY;
logDebug("Adjust ROI height to {}", acq_pars->roiHeight);
(*this)[CAMERA_ATTR_ROI_HEIGHT] = height_max;
}