rois shoudl work. left to implement tests for individual rois, create multiple datasets (1 for each roi) in the virutal data file. currently virutal dataset with roi is not implemented and a warning is given instead. wonder why since the inviduviaual roi files are clipped

This commit is contained in:
2025-06-20 17:20:19 +02:00
parent aac3f8904b
commit 24f878a17b
15 changed files with 314 additions and 364 deletions

View File

@@ -48,10 +48,10 @@ void DataProcessor::SetUdpPortNumber(const uint16_t portNumber) {
void DataProcessor::SetActivate(bool enable) { activated = enable; }
void DataProcessor::SetReceiverROI(ROI roi) {
receiverRoi = roi;
receiverRoiEnabled = receiverRoi.completeRoi() ? false : true;
receiverNoRoi = receiverRoi.noRoi();
void DataProcessor::SetPortROI(ROI roi) {
portRoi = roi;
isPartiallyInRoi = portRoi.completeRoi() ? false : true;
isOutsideRoi = portRoi.noRoi();
}
void DataProcessor::SetDataStreamEnable(bool enable) {
@@ -154,17 +154,17 @@ void DataProcessor::CreateFirstFiles(const std::string &fileNamePrefix,
CloseFiles();
// deactivated (half module/ single port or no roi), dont write file
if (!activated || !detectorDataStream || receiverNoRoi) {
if (!activated || !detectorDataStream || isOutsideRoi) {
return;
}
#ifdef HDF5C
int nx = generalData->nPixelsX;
int ny = generalData->nPixelsY;
if (receiverRoiEnabled) {
nx = receiverRoi.xmax - receiverRoi.xmin + 1;
ny = receiverRoi.ymax - receiverRoi.ymin + 1;
if (receiverRoi.ymax == -1 || receiverRoi.ymin == -1) {
if (isPartiallyInRoi) {
nx = portRoi.xmax - portRoi.xmin + 1;
ny = portRoi.ymax - portRoi.ymin + 1;
if (portRoi.ymax == -1 || portRoi.ymin == -1) {
ny = 1;
}
}
@@ -203,7 +203,7 @@ std::string DataProcessor::CreateVirtualFile(
const int modulePos, const int numModX, const int numModY,
std::mutex *hdf5LibMutex) {
if (receiverRoiEnabled) {
if (isPartiallyInRoi) {
throw std::runtime_error(
"Skipping virtual hdf5 file since rx_roi is enabled.");
}
@@ -235,7 +235,7 @@ void DataProcessor::LinkFileInMaster(const std::string &masterFileName,
const bool silentMode,
std::mutex *hdf5LibMutex) {
if (receiverRoiEnabled) {
if (isPartiallyInRoi) {
throw std::runtime_error(
"Should not be here, roi with hdf5 virtual should throw.");
}
@@ -301,7 +301,7 @@ void DataProcessor::ThreadExecution() {
// stream (if time/freq to stream) or free
if (streamCurrentFrame) {
// copy the complete image back if roi enabled
if (receiverRoiEnabled) {
if (isPartiallyInRoi) {
memImage->size = generalData->imageSize;
memcpy(memImage->data, &completeImageToStreamBeforeCropping[0],
generalData->imageSize);
@@ -381,7 +381,7 @@ void DataProcessor::ProcessAnImage(sls_receiver_header &header, size_t &size,
streamCurrentFrame = false;
}
if (receiverRoiEnabled) {
if (isPartiallyInRoi) {
// copy the complete image to stream before cropping
if (streamCurrentFrame) {
memcpy(&completeImageToStreamBeforeCropping[0], data,
@@ -687,12 +687,12 @@ void DataProcessor::ArrangeDbitData(size_t &size, char *data) {
}
void DataProcessor::CropImage(size_t &size, char *data) {
LOG(logDEBUG) << "Cropping Image to ROI " << ToString(receiverRoi);
LOG(logDEBUG) << "Cropping Image to ROI " << ToString(portRoi);
int nPixelsX = generalData->nPixelsX;
int xmin = receiverRoi.xmin;
int xmax = receiverRoi.xmax;
int ymin = receiverRoi.ymin;
int ymax = receiverRoi.ymax;
int xmin = portRoi.xmin;
int xmax = portRoi.xmax;
int ymin = portRoi.ymin;
int ymax = portRoi.ymax;
int xwidth = xmax - xmin + 1;
int ywidth = ymax - ymin + 1;
if (ymin == -1 || ymax == -1) {