summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.cpp23
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.h4
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp27
-rw-r--r--tracker-pt/ftnoir_tracker_pt.h8
4 files changed, 23 insertions, 39 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;
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index ca25e858..0e43b812 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -19,8 +19,6 @@
//-----------------------------------------------------------------------------
Tracker_PT::Tracker_PT() :
- video_widget(nullptr),
- video_frame(nullptr),
point_count(0),
commands(0),
ever_success(false)
@@ -32,13 +30,7 @@ Tracker_PT::~Tracker_PT()
{
set_command(ABORT);
wait();
- if (video_widget)
- delete video_widget;
- video_widget = NULL;
- if (video_frame)
- {
- if (video_frame->layout()) delete video_frame->layout();
- }
+
// fast start/stop causes breakage
camera.stop();
}
@@ -180,7 +172,7 @@ void Tracker_PT::run()
video_widget->update_image(frame_);
}
}
- qDebug() << "pt: Thread stopping";
+ qDebug() << "pt: thread stopped";
}
void Tracker_PT::apply_settings()
@@ -209,17 +201,16 @@ void Tracker_PT::apply_settings()
qDebug() << "pt: done applying settings";
}
-void Tracker_PT::start_tracker(QFrame *parent_window)
+void Tracker_PT::start_tracker(QFrame* video_frame)
{
- video_frame = parent_window;
video_frame->setAttribute(Qt::WA_NativeWindow);
- video_frame->show();
- video_widget = new cv_video_widget(video_frame);
- QHBoxLayout* video_layout = new QHBoxLayout(parent_window);
- video_layout->setContentsMargins(0, 0, 0, 0);
- video_layout->addWidget(video_widget);
- video_frame->setLayout(video_layout);
+ video_widget = qptr<cv_video_widget>(video_frame);
+ layout = qptr<QHBoxLayout>(video_frame);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(video_widget.data());
+ video_frame->setLayout(layout.data());
video_widget->resize(video_frame->width(), video_frame->height());
+ video_frame->show();
start();
}
diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h
index 020694ae..66928655 100644
--- a/tracker-pt/ftnoir_tracker_pt.h
+++ b/tracker-pt/ftnoir_tracker_pt.h
@@ -18,12 +18,14 @@
#include "point_tracker.h"
#include "compat/timer.hpp"
#include "cv/video-widget.hpp"
+#include "compat/util.hpp"
#include <QCoreApplication>
#include <QThread>
#include <QMutex>
#include <QMutexLocker>
#include <QTime>
+#include <QLayout>
#include <atomic>
#include <memory>
#include <vector>
@@ -65,12 +67,12 @@ private:
QMutex camera_mtx;
QMutex data_mtx;
- CVCamera camera;
+ Camera camera;
PointExtractor point_extractor;
PointTracker point_tracker;
- cv_video_widget* video_widget;
- QFrame* video_frame;
+ qshared<cv_video_widget> video_widget;
+ qshared<QLayout> layout;
settings_pt s;
Timer time;