GCC Code Coverage Report


./
File: modules/ui/qt/calibration/camera_config_launcher.cpp
Date: 2025-01-21 16:21:04
Lines:
104/244
42.6%
Functions:
7/14
50.0%
Branches:
109/560
19.5%

Line Branch Exec Source
1 /************************************************************************
2 *
3 * Copyright (C) 2014-2024 IRCAD France
4 * Copyright (C) 2014-2020 IHU Strasbourg
5 *
6 * This file is part of Sight.
7 *
8 * Sight is free software: you can redistribute it and/or modify it under
9 * the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Sight is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
20 *
21 ***********************************************************************/
22
23 #include "modules/ui/qt/calibration/camera_config_launcher.hpp"
24
25 #include <core/com/signal.hxx>
26 #include <core/runtime/path.hpp>
27
28 #include <data/calibration_info.hpp>
29 #include <data/camera.hpp>
30 #include <data/map.hpp>
31 #include <data/vector.hpp>
32
33 #include <io/__/service/io_types.hpp>
34 #include <io/__/service/reader.hpp>
35
36 #include <service/op.hpp>
37
38 #include <ui/__/dialog/input.hpp>
39 #include <ui/__/dialog/location.hpp>
40 #include <ui/__/dialog/message.hpp>
41 #include <ui/qt/container/widget.hpp>
42
43 #include <boost/lexical_cast.hpp>
44
45 #include <QHBoxLayout>
46 #include <QInputDialog>
47 #include <QStringList>
48
49 namespace sight::module::ui::qt::calibration
50 {
51
52
2/4
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 camera_config_launcher::camera_config_launcher() noexcept =
53 default;
54
55 //------------------------------------------------------------------------------
56
57 8 camera_config_launcher::~camera_config_launcher() noexcept =
58 default;
59
60 //------------------------------------------------------------------------------
61
62 2 void camera_config_launcher::configuring()
63 {
64 2 this->initialize();
65 2 service::config_t configuration = this->get_config();
66
67 SIGHT_ASSERT(
68 "There must be one (and only one) <config/> element.",
69 configuration.count("config") == 1
70 2 );
71 2 const service::config_t& srvconfig = configuration;
72
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 const service::config_t& config = srvconfig.get_child("config");
73
74
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 const service::config_t& intrinsic = config.get_child("intrinsic");
75
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 const service::config_t& extrinsic = config.get_child("extrinsic");
76
77
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 m_intrinsic_launcher.parse_config(intrinsic, this->get_sptr());
78
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 m_extrinsic_launcher.parse_config(extrinsic, this->get_sptr());
79 2 }
80
81 //------------------------------------------------------------------------------
82
83 2 void camera_config_launcher::starting()
84 {
85 2 this->create();
86
87
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 auto qt_container = std::dynamic_pointer_cast<sight::ui::qt::container::widget>(this->get_container());
88
89
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 auto* layout = new QHBoxLayout();
90
91
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
2 m_camera_combo_box = new QComboBox();
92
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 layout->addWidget(m_camera_combo_box);
93
94 2 QIcon add_icon(QString::fromStdString(
95
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
4 core::runtime::get_module_resource_file_path(
96 "sight::module::ui::icons",
97 "plus.svg"
98 )
99
1/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 .string()
100
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ));
101
4/10
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
2 m_add_button = new QPushButton(add_icon, "");
102
2/4
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
2 m_add_button->setToolTip("Add a new camera.");
103
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 layout->addWidget(m_add_button);
104
105 2 QIcon import_icon(QString::fromStdString(
106
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
4 core::runtime::get_module_resource_file_path(
107 "sight::module::ui::icons",
108 "import.svg"
109 )
110
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
4 .string()
111
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ));
112
4/10
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
2 m_import_button = new QPushButton(import_icon, "");
113
2/4
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
2 m_import_button->setToolTip("Import an intrinsic calibration.");
114
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 layout->addWidget(m_import_button);
115
116 2 QIcon remove_icon(QString::fromStdString(
117
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
4 core::runtime::get_module_resource_file_path(
118 "sight::module::ui::icons",
119 "minus.svg"
120 )
121
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
4 .string()
122
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ));
123
4/10
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
2 m_remove_button = new QPushButton(remove_icon, "");
124
2/4
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
2 m_remove_button->setToolTip("Remove the camera.");
125
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 layout->addWidget(m_remove_button);
126
127
4/10
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
2 m_extrinsic_button = new QPushButton("Extrinsic");
128
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 layout->addWidget(m_extrinsic_button);
129
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 m_extrinsic_button->setCheckable(true);
130
131
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 qt_container->set_layout(layout);
132
133 2 std::size_t nb_cam = 0;
134 2 {
135 2 const auto camera_set = m_camera_set.lock();
136 2 SIGHT_ASSERT("Missing cameraSet.", camera_set);
137 2 nb_cam = camera_set->size();
138 2 }
139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nb_cam == 0)
140 {
141
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 this->add_camera();
142
143
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 m_extrinsic_button->setEnabled(false);
144
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 m_remove_button->setEnabled(false);
145 }
146 else
147 {
148 for(std::size_t i = 0 ; i < nb_cam ; ++i)
149 {
150 m_camera_combo_box->addItem(QString("Camera %1").arg(i + 1));
151 }
152
153 const bool more_than_one_camera = (nb_cam > 1);
154
155 m_extrinsic_button->setEnabled(more_than_one_camera);
156 m_remove_button->setEnabled(more_than_one_camera);
157
158 this->start_intrinsic_config(0);
159 }
160
161
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 QObject::connect(m_camera_combo_box, SIGNAL(currentIndexChanged(int)), this, SLOT(on_camera_changed(int)));
162
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 QObject::connect(m_add_button, &QPushButton::clicked, this, &self_t::on_add_clicked);
163
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 QObject::connect(m_import_button, &QPushButton::clicked, this, &self_t::on_import_clicked);
164
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 QObject::connect(m_remove_button, &QPushButton::clicked, this, &self_t::on_remove_clicked);
165
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 QObject::connect(m_extrinsic_button, &QPushButton::toggled, this, &self_t::on_extrinsic_toggled);
166
1/2
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 }
167
168 //------------------------------------------------------------------------------
169
170 2 void camera_config_launcher::stopping()
171 {
172 2 m_intrinsic_launcher.stop_config();
173 2 m_extrinsic_launcher.stop_config();
174
175 2 this->destroy();
176 2 }
177
178 //------------------------------------------------------------------------------
179
180 void camera_config_launcher::updating()
181 {
182 }
183
184 //------------------------------------------------------------------------------
185
186 void camera_config_launcher::on_camera_changed(int _index)
187 {
188 {
189 const auto camera_set = m_camera_set.lock();
190 SIGHT_ASSERT(
191 "Bad index: " << _index,
192 _index >= 0 && static_cast<std::size_t>(_index) < camera_set->size()
193 );
194 }
195
196 if(_index == 0)
197 {
198 m_extrinsic_button->setChecked(false);
199 m_extrinsic_button->setEnabled(false);
200 }
201 else
202 {
203 m_extrinsic_button->setEnabled(true);
204 }
205
206 if(m_extrinsic_button->isChecked())
207 {
208 this->start_extrinsic_config(static_cast<std::size_t>(_index));
209 }
210 else
211 {
212 this->start_intrinsic_config(static_cast<std::size_t>(_index));
213 }
214 }
215
216 //------------------------------------------------------------------------------
217
218 void camera_config_launcher::on_add_clicked()
219 {
220 m_extrinsic_button->setEnabled(true);
221 m_remove_button->setEnabled(true);
222
223 this->add_camera();
224 }
225
226 //------------------------------------------------------------------------------
227
228 void camera_config_launcher::on_import_clicked()
229 {
230 auto vector = std::make_shared<data::vector>();
231 auto reader = sight::service::add<io::service::reader>("sight::module::io::session::reader");
232 reader->set_inout(vector, io::service::DATA_KEY);
233
234 try
235 {
236 service::config_t config;
237 config.add("dialog.<xmlattr>.extension", ".cam");
238 config.add("dialog.<xmlattr>.description", "Cameras");
239 reader->configure(config);
240
241 reader->start();
242 reader->open_location_dialog();
243 reader->update();
244 reader->stop();
245 }
246 catch(std::exception const& e)
247 {
248 sight::ui::dialog::message dlg;
249 const auto msg = "Cannot read file: " + std::string(e.what());
250 dlg.set_title("Read error");
251 dlg.set_message(msg);
252 dlg.set_icon(sight::ui::dialog::message::icons::critical);
253 SIGHT_ERROR(msg);
254
255 throw;
256 }
257
258 sight::service::remove(reader);
259
260 QStringList cameras;
261 std::map<std::string, data::camera::csptr> camera_map;
262 std::size_t n_set = 0;
263
264 for(const auto& object : *vector)
265 {
266 const auto& camera_set = std::dynamic_pointer_cast<data::camera_set>(object);
267
268 if(camera_set)
269 {
270 for(std::size_t n_camera = 0, end = camera_set->size() ; n_camera != end ; ++n_camera)
271 {
272 const auto& camera = camera_set->get_camera(n_camera);
273 const auto& camera_id =
274 camera->get_camera_id() + " [" + std::to_string(n_set) + ", " + std::to_string(n_camera) + "]";
275
276 camera_map.insert(std::make_pair(camera_id, camera));
277 cameras << QString::fromStdString(camera_id);
278 }
279
280 ++n_set;
281 }
282 }
283
284 if(n_set == 0)
285 {
286 sight::ui::dialog::message::show(
287 "No CameraSet in file",
288 "There are no CameraSet present in the loaded file.",
289 sight::ui::dialog::message::critical
290 );
291 }
292 else if(cameras.empty())
293 {
294 sight::ui::dialog::message::show(
295 "No Cameras in file",
296 "There are CameraSet present in the loaded CameraSet, but no Cameras were found",
297 sight::ui::dialog::message::critical
298 );
299 }
300 else
301 {
302 auto qt_container = std::dynamic_pointer_cast<sight::ui::qt::container::widget>(this->get_container());
303 bool ok = false;
304 auto selected = QInputDialog::getItem(
305 qt_container->get_qt_container(),
306 "Please select a camera",
307 "Camera",
308 cameras,
309 0,
310 false,
311 &ok
312 );
313
314 if(ok)
315 {
316 const auto selected_std = selected.toStdString();
317 const auto selected_camera = camera_map[selected_std];
318 const auto cam_idx = m_camera_combo_box->currentIndex();
319 const auto camera_set = m_camera_set.lock();
320 auto camera = camera_set->get_camera(std::size_t(cam_idx));
321 camera->deep_copy(selected_camera);
322 camera->signal<data::camera::intrinsic_calibrated_signal_t>(
323 data::camera::INTRINSIC_CALIBRATED_SIG
324 )
325 ->async_emit();
326 }
327 }
328 }
329
330 //------------------------------------------------------------------------------
331
332 void camera_config_launcher::on_remove_clicked()
333 {
334 const auto index = static_cast<std::size_t>(m_camera_combo_box->currentIndex());
335 if(index > 0)
336 {
337 m_camera_combo_box->blockSignals(true);
338
339 {
340 const auto camera_set = m_camera_set.lock();
341 // Remove camera
342 data::camera::sptr camera = camera_set->get_camera(index);
343 camera_set->remove_camera(camera);
344
345 auto sig = camera_set->signal<data::camera_set::removed_camera_signal_t>(
346 data::camera_set::REMOVED_CAMERA_SIG
347 );
348 sig->async_emit(camera);
349
350 // Remove calibrationInfo
351 std::string calibration_info_key = "calibrationInfo_" + std::to_string(index);
352 const auto activity = m_activity.lock();
353 activity->erase(calibration_info_key);
354
355 const std::size_t nb_cam = camera_set->size();
356 if(nb_cam == 1)
357 {
358 m_extrinsic_button->setEnabled(false);
359 m_remove_button->setEnabled(false);
360 }
361
362 // Renamed all items from 1 to nbCam
363 m_camera_combo_box->clear();
364 for(std::size_t i = 0 ; i < nb_cam ; ++i)
365 {
366 m_camera_combo_box->addItem(QString("Camera %1").arg(i + 1));
367 }
368 }
369
370 // select first camera
371 m_camera_combo_box->setCurrentIndex(0);
372 this->start_intrinsic_config(0);
373 m_camera_combo_box->blockSignals(false);
374 }
375 else
376 {
377 sight::ui::dialog::message::show("Warning", "The first camera can not be deleted");
378 }
379 }
380
381 //------------------------------------------------------------------------------
382
383 void camera_config_launcher::on_extrinsic_toggled(bool _checked)
384 {
385 std::size_t index = 0;
386 {
387 const auto camera_set = m_camera_set.lock();
388 index = static_cast<std::size_t>(m_camera_combo_box->currentIndex());
389 SIGHT_ASSERT("Bad index: " << index, index < camera_set->size());
390 }
391 if(_checked)
392 {
393 this->start_extrinsic_config(index);
394 }
395 else
396 {
397 this->start_intrinsic_config(index);
398 }
399 }
400
401 //------------------------------------------------------------------------------
402
403 2 void camera_config_launcher::start_intrinsic_config(std::size_t _index)
404 {
405 2 sight::app::field_adaptor_t replace_map;
406 2 {
407 2 const auto camera_set = m_camera_set.lock();
408
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 data::camera::sptr camera = camera_set->get_camera(_index);
409
410
2/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 std::string calibration_info_key = "calibrationInfo_" + std::to_string(_index);
411
412 2 const auto activity = m_activity.lock();
413
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 auto calib_info = std::dynamic_pointer_cast<data::calibration_info>((*activity)[calibration_info_key]);
414
415 2 const auto board_properties = m_board_properties.lock();
416
417
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
2 replace_map["camera"] = camera->get_id();
418
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
2 replace_map["calibrationInfo"] = calib_info->get_id();
419
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
2 replace_map["board_properties"] = board_properties->get_id();
420
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
6 }
421
422
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 m_extrinsic_launcher.stop_config();
423
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 m_intrinsic_launcher.stop_config();
424
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
4 m_intrinsic_launcher.start_config(this->get_sptr(), replace_map);
425 2 }
426
427 //------------------------------------------------------------------------------
428
429 void camera_config_launcher::start_extrinsic_config(std::size_t _index)
430 {
431 sight::app::field_adaptor_t replace_map;
432 {
433 const std::size_t camera_idx = std::max(_index, std::size_t(1));
434
435 const auto camera_set = m_camera_set.lock();
436
437 data::camera::sptr camera1 = camera_set->get_camera(0);
438 data::camera::sptr camera2 = camera_set->get_camera(camera_idx);
439
440 // Check if the two cameras are calibrated
441 if(!camera1->get_is_calibrated() || !camera2->get_is_calibrated())
442 {
443 sight::ui::dialog::message::show("Calibration", "Cameras must be intrinsically calibrated.");
444 m_extrinsic_button->setChecked(false);
445 return;
446 }
447
448 // cspell: ignore Extr
449 // Add 2 calibration info in Activity if not exist
450 std::string calibration_info1_key = "calibrationInfoExtr0_" + std::to_string(camera_idx);
451 std::string calibration_info2_key = "calibrationInfoExtr1_" + std::to_string(camera_idx);
452 const auto activity = m_activity.lock();
453 data::calibration_info::sptr calib_info1;
454 data::calibration_info::sptr calib_info2;
455 // Get the calibrationInfo from the activity if it exists or create it.
456 if(activity->find(calibration_info1_key) == activity->end()
457 || activity->find(calibration_info2_key) == activity->end())
458 {
459 calib_info1 = std::make_shared<data::calibration_info>();
460 calib_info2 = std::make_shared<data::calibration_info>();
461
462 (*activity)[calibration_info1_key] = calib_info1;
463 (*activity)[calibration_info2_key] = calib_info2;
464 }
465 else
466 {
467 calib_info1 = std::dynamic_pointer_cast<data::calibration_info>((*activity)[calibration_info1_key]);
468 calib_info2 = std::dynamic_pointer_cast<data::calibration_info>((*activity)[calibration_info2_key]);
469 }
470
471 const auto board_properties = m_board_properties.lock();
472
473 replace_map["camera1"] = camera1->get_id();
474 replace_map["camera2"] = camera2->get_id();
475 replace_map["calibrationInfo1"] = calib_info1->get_id();
476 replace_map["calibrationInfo2"] = calib_info2->get_id();
477 replace_map["camIndex"] = std::to_string(_index);
478 replace_map["board_properties"] = board_properties->get_id();
479 replace_map["cameraSet"] = camera_set->get_id();
480 }
481
482 m_extrinsic_launcher.stop_config();
483 m_intrinsic_launcher.stop_config();
484 m_extrinsic_launcher.start_config(this->get_sptr(), replace_map);
485 }
486
487 //------------------------------------------------------------------------------
488
489 2 void camera_config_launcher::add_camera()
490 {
491 2 std::size_t nb_cam = 0;
492 2 {
493 2 const auto camera_set = m_camera_set.lock();
494
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 nb_cam = camera_set->size();
495
496
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 data::camera::sptr camera = std::make_shared<data::camera>();
497
498 // Add the CalibrationInfo in activity to be saved in activity
499
2/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 std::string calibration_info_key = "calibrationInfo_" + std::to_string(nb_cam);
500
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 data::calibration_info::sptr calib_info = std::make_shared<data::calibration_info>();
501
502 2 const auto activity = m_activity.lock();
503
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 (*activity)[calibration_info_key] = calib_info;
504
505 // Add the camera
506
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 camera_set->add_camera(camera);
507
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 auto sig = camera_set->signal<data::camera_set::added_camera_signal_t>(
508 data::camera_set::ADDED_CAMERA_SIG
509
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 );
510
3/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
6 sig->async_emit(camera);
511
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
6 }
512
513 2 m_camera_combo_box->blockSignals(true);
514
3/6
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
2 m_camera_combo_box->addItem(QString("Camera %1").arg(nb_cam + 1));
515 2 m_camera_combo_box->setCurrentIndex(static_cast<int>(nb_cam));
516 2 m_extrinsic_button->setChecked(false);
517 2 this->start_intrinsic_config(nb_cam);
518 2 m_camera_combo_box->blockSignals(false);
519 2 }
520
521 //------------------------------------------------------------------------------
522
523 } // namespace sight::module::ui::qt::calibration
524