summaryrefslogtreecommitdiffhomepage
path: root/tracker-aruco/ftnoir_tracker_aruco.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-aruco/ftnoir_tracker_aruco.cpp')
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp
index 0cdf4c2c..5130a889 100644
--- a/tracker-aruco/ftnoir_tracker_aruco.cpp
+++ b/tracker-aruco/ftnoir_tracker_aruco.cpp
@@ -56,6 +56,8 @@ static const resolution_tuple resolution_choices[] =
{
{ 640, 480 },
{ 320, 240 },
+ { 1280, 720 },
+ { 1920, 1080 },
{ 0, 0 }
};
@@ -81,8 +83,8 @@ module_status aruco_tracker::start_tracker(QFrame* videoframe)
videoWidget = std::make_unique<cv_video_widget>(videoframe);
layout = std::make_unique<QHBoxLayout>();
layout->setContentsMargins(0, 0, 0, 0);
- layout->addWidget(videoWidget.get());
- videoframe->setLayout(layout.get());
+ layout->addWidget(&*videoWidget);
+ videoframe->setLayout(&*layout);
videoWidget->show();
start();
@@ -101,8 +103,8 @@ bool aruco_tracker::detect_with_roi()
{
if (last_roi.width > 1 && last_roi.height > 1)
{
- detector.setMinMaxSize(clamp(size_min * grayscale.cols / last_roi.width, .01f, 1.f),
- clamp(size_max * grayscale.cols / last_roi.width, .01f, 1.f));
+ detector.setMinMaxSize(std::clamp(size_min * grayscale.cols / last_roi.width, .01f, 1.f),
+ std::clamp(size_max * grayscale.cols / last_roi.width, .01f, 1.f));
detector.detect(grayscale(last_roi), markers, cv::Mat(), cv::Mat(), -1, false);
@@ -157,9 +159,7 @@ static int enum_to_fps(int value)
bool aruco_tracker::open_camera()
{
- int rint = s.resolution;
- if (rint < 0 || rint >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple)))
- rint = 0;
+ int rint = std::clamp(*s.resolution, 0, (int)std::size(resolution_choices)-1);
resolution_tuple res = resolution_choices[rint];
int fps = enum_to_fps(s.force_fps);
@@ -180,6 +180,8 @@ bool aruco_tracker::open_camera()
if (fps)
args.fps = fps;
+ args.use_mjpeg = s.use_mjpeg;
+
if (!camera->start(args))
{
qDebug() << "aruco tracker: can't open camera";
@@ -226,7 +228,7 @@ void aruco_tracker::draw_ar(bool ok)
}
char buf[9];
- ::snprintf(buf, sizeof(buf), "Hz: %d", clamp(int(fps), 0, 9999));
+ ::snprintf(buf, sizeof(buf), "Hz: %d", std::clamp(int(fps), 0, 9999));
cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, 2, cv::Scalar(0, 255, 0), 1);
}
@@ -380,6 +382,7 @@ void aruco_tracker::run()
if (!res)
{
+ camera_mtx.unlock();
portable::sleep(100);
continue;
}
@@ -389,7 +392,9 @@ void aruco_tracker::run()
switch (img.channels)
{
case 1:
- grayscale.setTo(color); break;
+ grayscale.create(img.height, img.width, CV_8UC1);
+ color.copyTo(grayscale);
+ break;
case 3:
cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY);
break;
@@ -524,6 +529,7 @@ aruco_dialog::aruco_dialog() :
tie_setting(s.headpos_x, ui.cx);
tie_setting(s.headpos_y, ui.cy);
tie_setting(s.headpos_z, ui.cz);
+ tie_setting(s.use_mjpeg, ui.use_mjpeg);
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));