61 lines
2.1 KiB
C++
61 lines
2.1 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#include <random>
|
|
#include "../image_analysis/StrongPixelSet.h"
|
|
|
|
int main() {
|
|
Logger logger("SpotFindingPerformanceTest");
|
|
|
|
size_t nstrong_pixel = 4000;
|
|
std::vector<uint8_t> strong_pixel(RAW_MODULE_SIZE, 0);
|
|
|
|
std::mt19937 g1(67678);
|
|
std::uniform_int_distribution<size_t> distribution(0, RAW_MODULE_SIZE - 1);
|
|
|
|
DeviceOutput dev_output;
|
|
dev_output.spot_finding_result.strong_pixel_count = nstrong_pixel;
|
|
|
|
for (auto &i: dev_output.spot_finding_result.strong_pixel)
|
|
i = 0;
|
|
|
|
// Can think of smarter way to select pixels
|
|
int pixels_set = 0;
|
|
while (pixels_set < nstrong_pixel) {
|
|
size_t pixel = distribution(g1);
|
|
if (strong_pixel[pixel] == 0) {
|
|
strong_pixel[pixel] = 1;
|
|
dev_output.spot_finding_result.strong_pixel[pixel / 8] |= (1 << (pixel % 8));
|
|
pixels_set++;
|
|
}
|
|
}
|
|
|
|
DiffractionExperiment experiment(DetectorGeometry(18, 3, 8, 36));
|
|
experiment.DetectorDistance_mm(50.0).BeamX_pxl(1200).BeamY_pxl(1200);
|
|
|
|
SpotFindingSettings settings{
|
|
.min_pix_per_spot = 1,
|
|
.max_pix_per_spot = 250,
|
|
.high_resolution_limit = 0.3,
|
|
.low_resolution_limit = 100.0
|
|
};
|
|
|
|
int iterations = 200;
|
|
{
|
|
int tmp = 0;
|
|
auto start_time = std::chrono::system_clock::now();
|
|
for (int i = 0; i < iterations; i++) {
|
|
std::vector<DiffractionSpot> spots, spots_out;
|
|
for (int m = 0; m < experiment.GetModulesNum(); m++) {
|
|
StrongPixelSet strong_pixel_set;
|
|
strong_pixel_set.ReadFPGAOutput(experiment, dev_output);
|
|
strong_pixel_set.FindSpots(experiment, settings, spots, m);
|
|
}
|
|
FilterSpotsByCount(experiment, spots, spots_out);
|
|
tmp += spots_out.size();
|
|
}
|
|
auto end_time = std::chrono::system_clock::now();
|
|
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);
|
|
logger.Info("Performance {:.2f} us", elapsed.count() / static_cast<double>(iterations));
|
|
}
|
|
}
|