diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-12-03 07:10:12 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-12-03 07:10:12 +0100 |
commit | ac36fa53e970bf79d68499b52433d33ed994c4c5 (patch) | |
tree | b98ad2b555c8b16ab108ff77be6c1ea063606e0e /tracker-aruco | |
parent | 1aeb193a0277e2f1319dd1e935f8111cf01d301c (diff) |
tracker/{aruco,pt}: use RAII for QObject
Diffstat (limited to 'tracker-aruco')
-rw-r--r-- | tracker-aruco/ftnoir_tracker_aruco.cpp | 23 | ||||
-rw-r--r-- | tracker-aruco/ftnoir_tracker_aruco.h | 4 |
2 files changed, 9 insertions, 18 deletions
diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp index 0df89fcb..5473eb6f 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.cpp +++ b/tracker-aruco/ftnoir_tracker_aruco.cpp @@ -42,15 +42,13 @@ constexpr const double aruco_tracker::size_min; constexpr const double aruco_tracker::size_max; aruco_tracker::aruco_tracker() : - stop(false), - layout(nullptr), - videoWidget(nullptr), fps(0), obj_points(4), intrinsics(cv::Matx33d::eye()), rmat(cv::Matx33d::eye()), roi_points(4), - last_roi(65535, 65535, 0, 0) + last_roi(65535, 65535, 0, 0), + stop(false) { // param 2 ignored for Otsu thresholding. it's required to use our fork of Aruco. detector.setThresholdParams(7, -1); @@ -62,10 +60,6 @@ aruco_tracker::~aruco_tracker() { stop = true; wait(); - if (videoWidget) - delete videoWidget; - if(layout) - delete layout; // fast start/stop causes breakage portable::sleep(1000); camera.release(); @@ -74,18 +68,15 @@ aruco_tracker::~aruco_tracker() void aruco_tracker::start_tracker(QFrame* videoframe) { videoframe->show(); - videoWidget = new cv_video_widget(videoframe); - QHBoxLayout* layout_ = new QHBoxLayout(); - layout_->setContentsMargins(0, 0, 0, 0); - layout_->addWidget(videoWidget); - if (videoframe->layout()) - delete videoframe->layout(); - videoframe->setLayout(layout_); + videoWidget = qptr<cv_video_widget>(videoframe); + layout = qptr<QHBoxLayout>(); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(videoWidget.data()); + videoframe->setLayout(layout.data()); videoWidget->show(); start(); for (int i = 0; i < 6; i++) pose[i] = 0; - layout = layout_; } void aruco_tracker::getRT(cv::Matx33d& r_, cv::Vec3d& t_) diff --git a/tracker-aruco/ftnoir_tracker_aruco.h b/tracker-aruco/ftnoir_tracker_aruco.h index 54940d28..edec2437 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.h +++ b/tracker-aruco/ftnoir_tracker_aruco.h @@ -78,8 +78,8 @@ private: cv::VideoCapture camera; QMutex camera_mtx; QMutex mtx; - QHBoxLayout* layout; - cv_video_widget* videoWidget; + qshared<cv_video_widget> videoWidget; + qshared<QHBoxLayout> layout; settings s; double pose[6], fps; cv::Mat frame, grayscale, color; |