diff options
Diffstat (limited to 'ftnoir_tracker_pt')
-rw-r--r-- | ftnoir_tracker_pt/camera.h | 2 | ||||
-rw-r--r-- | ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 6 | ||||
-rw-r--r-- | ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 18 |
3 files changed, 18 insertions, 8 deletions
diff --git a/ftnoir_tracker_pt/camera.h b/ftnoir_tracker_pt/camera.h index 2c42652a..5451ec09 100644 --- a/ftnoir_tracker_pt/camera.h +++ b/ftnoir_tracker_pt/camera.h @@ -89,7 +89,7 @@ public: void start() override; void stop() override; - operator cv::VideoCapture&() { return *cap; } + operator cv::VideoCapture*() { return cap; } protected: bool _get_frame(cv::Mat* frame) override; diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index be946018..013777bc 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -72,6 +72,8 @@ void Tracker_PT::run() if (!log_file.open(QIODevice::WriteOnly | QIODevice::Text)) return; QTextStream log_stream(&log_file); #endif + + apply_settings(); while((commands & ABORT) == 0) { @@ -152,9 +154,11 @@ void Tracker_PT::apply_settings() { qDebug()<<"Tracker:: Applying settings"; QMutexLocker l(&camera_mtx); + camera.stop(); camera.set_device_index(camera_name_to_index(s.camera_name)); camera.set_res(s.cam_res_x, s.cam_res_y); camera.set_fps(s.cam_fps); + camera.start(); cv::Mat intrinsics_ = cv::Mat::eye(3, 3, CV_32FC1); cv::Mat dist_coeffs_ = cv::Mat::zeros(5, 1, CV_32FC1); intrinsics = cv::Mat(); @@ -183,8 +187,6 @@ void Tracker_PT::start_tracker(QFrame *parent_window) video_layout->addWidget(video_widget); video_frame->setLayout(video_layout); video_widget->resize(video_frame->width(), video_frame->height()); - camera.start(); - apply_settings(); start(); } diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index 70511a3f..780e997b 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -89,7 +89,13 @@ TrackerDialog_PT::TrackerDialog_PT() void TrackerDialog_PT::camera_settings() { - open_camera_settings(tracker ? &static_cast<cv::VideoCapture&>(tracker->camera) : nullptr, s.camera_name, tracker ? &tracker->camera_mtx : nullptr); + if (tracker) + { + QMutexLocker l(&tracker->camera_mtx); + open_camera_settings(static_cast<cv::VideoCapture*>(tracker->camera), s.camera_name, &tracker->camera_mtx); + } + else + open_camera_settings(nullptr, s.camera_name, nullptr); } void TrackerDialog_PT::startstop_trans_calib(bool start) @@ -121,11 +127,13 @@ void TrackerDialog_PT::poll_tracker_info() if (tracker) { QString to_print; - - // display caminfo CamInfo info; - tracker->get_cam_info(&info); - to_print = QString::number(info.res_x)+"x"+QString::number(info.res_y)+" @ "+QString::number(info.fps)+" FPS"; + { + QMutexLocker l(&tracker->camera_mtx); + // display caminfo + tracker->get_cam_info(&info); + to_print = QString::number(info.res_x)+"x"+QString::number(info.res_y)+" @ "+QString::number(info.fps)+" FPS"; + } ui.caminfo_label->setText(to_print); // display pointinfo |