|
|
@@ -95,7 +95,6 @@ std::unique_ptr<vtk_viewer> augment_viewer;
|
|
|
std::unique_ptr<std::thread> encoder_thread;
|
|
|
bool output_full_frame = false;
|
|
|
bool output_halve_width = false;
|
|
|
-int output_width = -1, output_height = -1;
|
|
|
encoder_type chosen_encoder = ENCODER_JPEG;
|
|
|
nvenc_config main_nvenc_conf;
|
|
|
nvjpeg_config main_nvjpeg_conf;
|
|
|
@@ -195,6 +194,7 @@ struct camera_related {
|
|
|
process_conf.crude_debayer = use_crude_debayer;
|
|
|
process_conf.undistort = undistort_image;
|
|
|
process_conf.enhance = enhance_image;
|
|
|
+ process_conf.resample_height = mq().query_variable<int>(OUTPUT_HEIGHT);
|
|
|
|
|
|
// process image
|
|
|
processor->process(*raw_ptr, img_dev.get(), process_conf, *stream);
|
|
|
@@ -293,12 +293,10 @@ void load_config() {
|
|
|
|
|
|
// load output config
|
|
|
auto output_conf = conf["output"];
|
|
|
- output_width = output_conf["width"].as<int>();
|
|
|
- output_height = output_conf["height"].as<int>();
|
|
|
+ mq().update_variable(OUTPUT_WIDTH, output_conf["width"].as<int>());
|
|
|
+ mq().update_variable(OUTPUT_HEIGHT, output_conf["height"].as<int>());
|
|
|
main_nvenc_conf.bitrate_mbps = output_conf["hevc_bitrate"].as<float>();
|
|
|
main_nvjpeg_conf.quality = output_conf["jpeg_quality"].as<int>();
|
|
|
- left->process_conf.resample_height = output_height; // use output height as resample height
|
|
|
- right->process_conf.resample_height = output_height;
|
|
|
|
|
|
// load sender config
|
|
|
auto sender_conf = conf["sender"];
|
|
|
@@ -334,6 +332,7 @@ void load_config() {
|
|
|
// make variables exist
|
|
|
mq().update_variable(SENDER_CONNECTED, false);
|
|
|
mq().update_variable(REQUEST_IDR, false);
|
|
|
+ mq().update_variable(ENCODER_SHOULD_RESET, false);
|
|
|
}
|
|
|
|
|
|
void initialize_main_window() {
|
|
|
@@ -410,6 +409,7 @@ void initialize_main_window() {
|
|
|
augment_viewer = std::make_unique<vtk_viewer>();
|
|
|
augment_viewer->set_camera_view_angle(augment_render_angle);
|
|
|
for (auto &item: augment_items) {
|
|
|
+ item.actor->GetProperty()->SetColor(1, 0, 0); // TODO: make color configurable
|
|
|
augment_viewer->add_actor(item.actor);
|
|
|
}
|
|
|
reg.reset(registration::create({&sophiar_conn,
|
|
|
@@ -649,7 +649,8 @@ void start_encoder() {
|
|
|
frame_size.width = left->img_dev->size().width * 2;
|
|
|
frame_size.height = left->img_dev->size().height;
|
|
|
} else {
|
|
|
- frame_size = {output_width, output_height};
|
|
|
+ frame_size = {mq().query_variable<int>(OUTPUT_WIDTH),
|
|
|
+ mq().query_variable<int>(OUTPUT_HEIGHT)};
|
|
|
}
|
|
|
output_fbo->create(frame_size);
|
|
|
|
|
|
@@ -1091,6 +1092,13 @@ void render_main_window() {
|
|
|
}
|
|
|
|
|
|
void generate_output_frame() {
|
|
|
+ // re-create encoder if needed
|
|
|
+ if (mq().query_variable<bool>(ENCODER_SHOULD_RESET)) {
|
|
|
+ stop_encoder();
|
|
|
+ start_encoder();
|
|
|
+ mq().update_variable(ENCODER_SHOULD_RESET, false);
|
|
|
+ }
|
|
|
+
|
|
|
// offline drawing
|
|
|
output_fbo->bind();
|
|
|
auto closer = sg::make_scope_guard([&] { output_fbo->unbind(); });
|