mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-07-11 18:31:51 +02:00
works for all rois
This commit is contained in:
@ -1809,15 +1809,16 @@ void DetectorImpl::convertGlobalRoiToPortLevel(
|
||||
// Check if user ROI overlaps with this port ROI
|
||||
if (userRoi.overlap(portRoi)) {
|
||||
defs::ROI clipped{};
|
||||
clipped.xmin = std::max(userRoi.xmin, portRoi.xmin);
|
||||
clipped.xmax = std::min(userRoi.xmax, portRoi.xmax);
|
||||
// Clip user ROI to port ROI
|
||||
clipped.xmin = std::max(userRoi.xmin, portRoi.xmin) - portRoi.xmin;
|
||||
clipped.xmax = std::min(userRoi.xmax, portRoi.xmax) - portRoi.xmin;
|
||||
if (modSize.y > 1) {
|
||||
clipped.ymin = std::max(userRoi.ymin, portRoi.ymin);
|
||||
clipped.ymax = std::min(userRoi.ymax, portRoi.ymax);
|
||||
clipped.ymin = std::max(userRoi.ymin, portRoi.ymin) - portRoi.ymin;
|
||||
clipped.ymax = std::min(userRoi.ymax, portRoi.ymax) - portRoi.ymin;
|
||||
}
|
||||
|
||||
// Check if port ROI already exists for this port
|
||||
if (!portRois[port].completeRoi()) {
|
||||
if (!portRois[port].completeRoi() && !portRois[port].noRoi()) {
|
||||
throw RuntimeError(
|
||||
"Multiple ROIs specified for the same port " +
|
||||
std::to_string(port) +
|
||||
|
@ -690,7 +690,7 @@ void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
|
||||
}
|
||||
|
||||
void DataProcessor::CropImage(size_t &size, char *data) {
|
||||
LOG(logDEBUG) << "Cropping Image to ROI " << ToString(portRoi);
|
||||
LOG(logDEBUG1) << "Cropping Image to ROI " << ToString(portRoi);
|
||||
int nPixelsX = generalData->nPixelsX;
|
||||
int xmin = portRoi.xmin;
|
||||
int xmax = portRoi.xmax;
|
||||
@ -702,7 +702,7 @@ void DataProcessor::CropImage(size_t &size, char *data) {
|
||||
ywidth = 1;
|
||||
ymin = 0;
|
||||
}
|
||||
|
||||
|
||||
// calculate total roi size
|
||||
double bytesPerPixel = generalData->dynamicRange / 8.00;
|
||||
int startOffset = (int)((nPixelsX * ymin + xmin) * bytesPerPixel);
|
||||
|
@ -411,6 +411,19 @@ std::vector<slsDetectorDefs::ROI> Implementation::getPortROIs() const {
|
||||
}
|
||||
|
||||
void Implementation::setPortROIs(const std::vector<defs::ROI> &args) {
|
||||
int nx = static_cast<int>(generalData->nPixelsX);
|
||||
int ny = static_cast<int>(generalData->nPixelsY);
|
||||
// validate rois
|
||||
for (auto &it : args) {
|
||||
if (it.completeRoi() || it.noRoi()) {
|
||||
continue; // valid
|
||||
}
|
||||
if (it.xmin < 0 || it.ymin < 0 || it.xmax < 0 || it.ymax < 0 ||
|
||||
it.xmin >= nx || it.xmax >= nx ||
|
||||
it.ymin >= ny || it.ymax >= ny) {
|
||||
throw RuntimeError("Invalid ROI coordinates: " + ToString(it));
|
||||
}
|
||||
}
|
||||
portRois = args;
|
||||
|
||||
for (size_t i = 0; i != listener.size(); ++i)
|
||||
|
@ -249,8 +249,6 @@ std::string CreateVirtualHDF5File(
|
||||
"version", H5::PredType::NATIVE_DOUBLE, dataspace_attr);
|
||||
attribute.write(H5::PredType::NATIVE_DOUBLE, &dValue);
|
||||
|
||||
LOG(logINFORED) << "Rois:" << ToString(multiRoi);
|
||||
|
||||
for (size_t iRoi = 0; iRoi != multiRoi.size(); ++iRoi) {
|
||||
|
||||
auto currentRoi = multiRoi[iRoi];
|
||||
@ -279,16 +277,6 @@ std::string CreateVirtualHDF5File(
|
||||
int numFiles = numImagesCaught / maxFramesPerFile;
|
||||
if (numImagesCaught % maxFramesPerFile)
|
||||
++numFiles;
|
||||
LOG(logINFORED) << "Current Roi: " << currentRoi
|
||||
<< " detectorSize: " << ToString(detectorSize)
|
||||
<< " portSize: " << ToString(portSize)
|
||||
<< " nTotalPorts: " << nTotalPorts
|
||||
<< " roiWidth: " << roiWidth
|
||||
<< " roiHeight: " << roiHeight
|
||||
<< " nPortsInRoi: " << nPortsInRoi
|
||||
<< " nImages: " << nImages
|
||||
<< " numFiles: " << numFiles
|
||||
<< " maxFramesPerFile: " << maxFramesPerFile;
|
||||
|
||||
hsize_t vdsDims[DATA_RANK] = {nImages, roiHeight, roiWidth};
|
||||
hsize_t vdsDimsPara[VDS_PARA_RANK] = {nImages, nPortsInRoi};
|
||||
@ -354,12 +342,6 @@ std::string CreateVirtualHDF5File(
|
||||
else {
|
||||
++startLocation[2];
|
||||
}
|
||||
LOG(logINFORED) << "iReadout: " << iReadout
|
||||
<< " globalPortRoi: " << globalPortRoi
|
||||
<< " startLocation: " << ToString(startLocation)
|
||||
<< " blockSize: " << ToString(blockSize)
|
||||
<< " portRoiHeight: " << portRoiHeight
|
||||
<< " portRoiWidth: " << portRoiWidth;
|
||||
|
||||
vdsDataSpace.selectHyperslab(
|
||||
H5S_SELECT_SET, numBlocks, startLocation,
|
||||
|
Reference in New Issue
Block a user