config takes image height and width instead of n_pixels

This commit is contained in:
lhdamiani
2021-07-26 17:00:46 +02:00
parent aa00703701
commit 49434e86c0
12 changed files with 46 additions and 30 deletions
+5 -9
View File
@@ -9,17 +9,11 @@ namespace BufferUtils
{
struct DetectorConfig {
// const std::string streamvis_address;
// const int reduction_factor_streamvis;
// const std::string live_analysis_address;
// const int reduction_factor_live_analysis;
// const std::string PEDE_FILENAME;
// const std::string GAIN_FILENAME;
// const std::string buffer_folder;
const std::string detector_name;
const std::string detector_type;
const int n_modules;
const int image_n_pixels;
const int image_height;
const int image_width;
const int start_udp_port;
@@ -28,7 +22,9 @@ namespace BufferUtils
return os << det_config.detector_name << ' '
<< det_config.detector_type << ' '
<< det_config.n_modules << ' '
<< det_config.start_udp_port << ' ';
<< det_config.start_udp_port << ' '
<< det_config.image_height << ' '
<< det_config.image_width << ' ';
}
};
+2 -1
View File
@@ -162,7 +162,8 @@ BufferUtils::DetectorConfig BufferUtils::read_json_config(
config_parameters["detector_name"].GetString(),
config_parameters["detector_type"].GetString(),
config_parameters["n_modules"].GetInt(),
config_parameters["image_n_pixels"].GetInt(),
config_parameters["image_height"].GetInt(),
config_parameters["image_width"].GetInt(),
config_parameters["start_udp_port"].GetInt(),
};
}
+2 -1
View File
@@ -2,6 +2,7 @@
"detector_name": "cSAXS.EG01V01",
"detector_type": "eiger",
"n_modules": 4,
"image_n_pixels": 264196,
"image_height": 514,
"image_width": 1030,
"start_udp_port": 50000
}
+2 -1
View File
@@ -2,6 +2,7 @@
"detector_name": "cSAXS.EG01V01",
"detector_type": "eiger",
"n_modules": 4,
"image_n_pixels": 529420,
"image_height": 514,
"image_width": 1030,
"start_udp_port": 50200
}
+2 -4
View File
@@ -3,11 +3,9 @@ jf-assembler is the component that receives the confirmation from the std-udp-sy
## Overview
jf-assembler is a single threaded application that is used for assembling the images and send to anyone willing to listen.
jf-assembler is used for assembling the images and send to anyone willing to listen. It receives two arguments:
jf-assembler receives two arguments:
- number of modules: defines how many frames should be assembled together;
- detector's configuration file: detector config file path. Which includes, for example, the total number of modules from the detector that is going to be assembled;
- bit depth: defines properties of the data and the image that will be assembled. For example, number of bytes per line and bytes per image;
Such properties are defined in combination with the detector's header file, which contains the dimensions of the modules and gap pixels (if any).
+10 -2
View File
@@ -8,7 +8,10 @@
class EigerAssembler {
const int n_modules_;
const int n_rows_;
const int n_columns_;
const int bit_depth_;
const int image_height_;
const int image_width_;
const int n_eiger_modules_;
int last_image_status_;
@@ -27,7 +30,8 @@ class EigerAssembler {
public:
EigerAssembler(const int n_modules, const int bit_depth);
EigerAssembler(const int n_modules, const int bit_depth,
const int image_height, const int image_width);
void assemble_image(const char* src_meta, const char* src_data,
char* dst_meta, char* dst_data);
size_t get_image_n_bytes() const;
@@ -46,7 +50,11 @@ public:
<< p.n_bytes_per_eiger_y_gap_ << ", n_bytes_per_image_line_"
<< p.n_bytes_per_image_line_ << ", n_lines_per_frame_"
<< p.n_lines_per_frame_ << ", image_bytes_"
<< p.image_bytes_ << ", n_modules_"
<< p.image_bytes_ << ", image_width_"
<< p.image_width_ << ", n_columns"
<< p.n_columns_ << ", image_height_"
<< p.image_height_ << ", n_rows_"
<< p.n_rows_ << ", n_modules_"
<< p.n_modules_ << ", bit_depth_"
<< p.bit_depth_ << ""
<< ")";
+8 -4
View File
@@ -12,9 +12,13 @@
using namespace std;
using namespace buffer_config;
EigerAssembler::EigerAssembler(const int n_modules, const int bit_depth):
EigerAssembler::EigerAssembler(const int n_modules, const int bit_depth,
const int image_height, const int image_width):
n_modules_(n_modules),
n_rows_(n_modules/2),
image_height_(image_height),
image_width_(image_width),
n_rows_(image_width / MODULE_Y_SIZE),
n_columns_(image_height / MODULE_X_SIZE),
n_eiger_modules_(n_modules/4),
bit_depth_(bit_depth),
n_bytes_per_frame_(MODULE_N_PIXELS * bit_depth / 8),
@@ -64,8 +68,8 @@ void EigerAssembler::assemble_image(const char* src_meta,
// init good image status = 0
image_meta->status = 0;
image_meta->id = frame_meta->id;
image_meta->height = n_rows_ * (MODULE_Y_SIZE + EXTEND_Y_PIXELS);
image_meta->width = n_rows_ * (MODULE_X_SIZE + EXTEND_X_PIXELS);
image_meta->height = image_height_;
image_meta->width = image_width_;
image_meta->dtype = (bit_depth_ <= 8) ? 1 : bit_depth_ / 8;
image_meta->encoding = 0;
image_meta->source_id = 0;
+5 -2
View File
@@ -45,7 +45,7 @@ int main (int argc, char *argv[])
const int bit_depth = atoi(argv[2]);
auto const stream_name = "assembler";
const size_t IMAGE_N_BYTES = config.image_n_pixels * bit_depth / 8;
const size_t IMAGE_N_BYTES = config.image_height * config.image_width * bit_depth / 8;
auto ctx = zmq_ctx_new();
zmq_ctx_set(ctx, ZMQ_IO_THREADS, ASSEMBLER_ZMQ_IO_THREADS);
auto sender = BufferUtils::bind_socket(
@@ -60,13 +60,16 @@ int main (int argc, char *argv[])
cout << " Details of Assembler:";
cout << " detector_name: " << config.detector_name;
cout << " || n_modules: " << config.n_modules;
cout << " || img width: " << config.image_width;
cout << " || img height: " << config.image_height;
cout << endl;
#endif
const size_t FRAME_N_BYTES = MODULE_N_PIXELS * bit_depth / 8;
const size_t N_PACKETS_PER_FRAME = FRAME_N_BYTES / DATA_BYTES_PER_PACKET;
EigerAssembler assembler(config.n_modules, bit_depth);
EigerAssembler assembler(config.n_modules, bit_depth,
config.image_width, config.image_height);
#ifdef DEBUG_OUTPUT
using namespace date;
+4 -2
View File
@@ -17,12 +17,14 @@ struct DetWriterConfig {
return {
config_parameters["detector_name"].GetString(),
config_parameters["image_n_pixels"].GetInt(),
config_parameters["image_height"].GetInt(),
config_parameters["image_width"].GetInt(),
};
}
const std::string detector_name;
const int image_n_pixels;
const int image_height;
const int image_width;
};
+1 -1
View File
@@ -45,7 +45,7 @@ int main (int argc, char *argv[])
auto receiver = BufferUtils::connect_socket(
ctx, config.detector_name, "writer_agent");
const size_t IMAGE_N_BYTES = config.image_n_pixels * bit_depth / 8;
const size_t IMAGE_N_BYTES = config.image_width * config.image_height * bit_depth / 8;
RamBuffer image_buffer(config.detector_name + "_assembler",
sizeof(ImageMetadata), IMAGE_N_BYTES, 1, RAM_BUFFER_N_SLOTS);
+4 -2
View File
@@ -18,13 +18,15 @@ struct StreamSendConfig {
return {
config_parameters["detector_name"].GetString(),
config_parameters["n_modules"].GetInt(),
config_parameters["image_n_pixels"].GetInt(),
config_parameters["image_height"].GetInt(),
config_parameters["image_width"].GetInt(),
};
}
const std::string detector_name;
const int n_modules;
const int image_n_pixels;
const int image_height;
const int image_width;
};
+1 -1
View File
@@ -49,7 +49,7 @@ int main (int argc, char *argv[])
throw runtime_error(zmq_strerror(errno));
}
const size_t IMAGE_N_BYTES = config.image_n_pixels * bit_depth / 8;
const size_t IMAGE_N_BYTES = config.width * config.height * bit_depth / 8;
RamBuffer image_buffer(config.detector_name + "_assembler",
sizeof(ImageMetadata), IMAGE_N_BYTES,
config.n_modules, RAM_BUFFER_N_SLOTS);