From d7fb4b69ef543c8201b043424b9f24bfe8e050d1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 27 Feb 2023 14:10:00 +0100 Subject: tracker/nn, video/opencv: allow non-trackhat cameras --- tracker-neuralnet/ftnoir_tracker_neuralnet.cpp | 39 +- tracker-neuralnet/lang/nl_NL.ts | 72 ++++ tracker-neuralnet/lang/ru_RU.ts | 72 ++++ tracker-neuralnet/lang/stub.ts | 72 ++++ tracker-neuralnet/lang/zh_CN.ts | 72 ++++ tracker-neuralnet/neuralnet-trackercontrols.ui | 518 +++++++++++++++++++++---- 6 files changed, 757 insertions(+), 88 deletions(-) (limited to 'tracker-neuralnet') diff --git a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp index f1585954..5f582340 100644 --- a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp +++ b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp @@ -448,9 +448,6 @@ NeuralNetTracker::~NeuralNetTracker() module_status NeuralNetTracker::start_tracker(QFrame* videoframe) { - if (camera_name_to_index("TrackHat sensor") == -1) - return error("Can't open camera 'TrackHat sensor'"); - videoframe->show(); video_widget_ = std::make_unique(videoframe); layout_ = std::make_unique(); @@ -506,15 +503,33 @@ bool NeuralNetTracker::load_and_initialize_model() bool NeuralNetTracker::open_camera() { - //int rint = std::clamp(*settings_.resolution, 0, (int)std::size(resolution_choices)-1); - int rint = 1; + int rint = std::clamp(*settings_.resolution, 0, (int)std::size(resolution_choices)-1); resolution_tuple res = resolution_choices[rint]; - //int fps = enum_to_fps(settings_.force_fps); - int fps = 60; + int fps = enum_to_fps(settings_.force_fps); QMutexLocker l(&camera_mtx_); - camera_ = video::make_camera("TrackHat sensor"); + camera_ = nullptr; + const QString name = settings_.camera_name; + + if (name.isEmpty() || name == "TrackHat sensor") + { + camera_ = video::make_camera_("TrackHat sensor"); + if (camera_) + { + video::impl::camera::info args {}; + args.width = 640; + args.height = 480; + args.fps = 60; + args.use_mjpeg = true; + if (camera_->start(args)) + return true; + } + if (!name.isEmpty()) + return false; + } + + camera_ = video::make_camera(name); if (!camera_) return false; @@ -529,8 +544,7 @@ bool NeuralNetTracker::open_camera() if (fps) args.fps = fps; - //args.use_mjpeg = settings_.use_mjpeg; - args.use_mjpeg = true; + args.use_mjpeg = settings_.use_mjpeg; if (!camera_->start(args)) { @@ -608,6 +622,8 @@ void NeuralNetTracker::run() std::chrono::duration_cast( clk.now() - t).count()*1.e-3); } + + camera_ = nullptr; } @@ -730,11 +746,12 @@ NeuralNetDialog::NeuralNetDialog() : make_fps_combobox(); make_resolution_combobox(); -#if 0 + ui_.cameraName->addItem(QString{}); for (const auto& str : video::camera_names()) ui_.cameraName->addItem(str); tie_setting(settings_.camera_name, ui_.cameraName); +#if 0 tie_setting(settings_.fov, ui_.cameraFOV); #endif tie_setting(settings_.offset_fwd, ui_.tx_spin); diff --git a/tracker-neuralnet/lang/nl_NL.ts b/tracker-neuralnet/lang/nl_NL.ts index 09a2ebd7..b1e03913 100644 --- a/tracker-neuralnet/lang/nl_NL.ts +++ b/tracker-neuralnet/lang/nl_NL.ts @@ -44,6 +44,78 @@ Don't roll or change position. Exposure preset + + Camera Configuration + + + + Camera name + + + + The requested resolution for cases where the camera delivers maximum frame rate only for a particular resolution. The image may still be downscaled to the internal resolution. + + + + Field of view. Needed to transform the pose to world coordinates. + + + + Diagonal FOV + + + + Resolution + + + + Requested video frame rate. Actual setting may not be supported by the camera. + + + + Frames per second + + + + MJPEG + + + + Tuning / Debug + + + + Number of threads. Can be used to balance the CPU load between the game and the tracker. + + + + ROI Smoothing Alpha + + + + ROI Zoom + + + + Show the image patch that the pose estimation model sees. + + + + Show Network Input + + + + Amount of smoothing of the face region coordinates. Can help stabilize the pose. + + + + Thread Count + + + + Zoom factor for the face region. Applied before the patch is fed into the pose estimation model. There is a sweet spot near 1. + + neuralnet_tracker_ns::NeuralNetDialog diff --git a/tracker-neuralnet/lang/ru_RU.ts b/tracker-neuralnet/lang/ru_RU.ts index 3b1bb257..fcca70a9 100644 --- a/tracker-neuralnet/lang/ru_RU.ts +++ b/tracker-neuralnet/lang/ru_RU.ts @@ -44,6 +44,78 @@ Don't roll or change position. Exposure preset + + Camera Configuration + + + + Camera name + + + + The requested resolution for cases where the camera delivers maximum frame rate only for a particular resolution. The image may still be downscaled to the internal resolution. + + + + Field of view. Needed to transform the pose to world coordinates. + + + + Diagonal FOV + + + + Resolution + + + + Requested video frame rate. Actual setting may not be supported by the camera. + + + + Frames per second + + + + MJPEG + + + + Tuning / Debug + + + + Number of threads. Can be used to balance the CPU load between the game and the tracker. + + + + ROI Smoothing Alpha + + + + ROI Zoom + + + + Show the image patch that the pose estimation model sees. + + + + Show Network Input + + + + Amount of smoothing of the face region coordinates. Can help stabilize the pose. + + + + Thread Count + + + + Zoom factor for the face region. Applied before the patch is fed into the pose estimation model. There is a sweet spot near 1. + + neuralnet_tracker_ns::NeuralNetDialog diff --git a/tracker-neuralnet/lang/stub.ts b/tracker-neuralnet/lang/stub.ts index 8461ce0f..ecd559b1 100644 --- a/tracker-neuralnet/lang/stub.ts +++ b/tracker-neuralnet/lang/stub.ts @@ -44,6 +44,78 @@ Don't roll or change position. Exposure preset + + Camera Configuration + + + + Camera name + + + + The requested resolution for cases where the camera delivers maximum frame rate only for a particular resolution. The image may still be downscaled to the internal resolution. + + + + Field of view. Needed to transform the pose to world coordinates. + + + + Diagonal FOV + + + + Resolution + + + + Requested video frame rate. Actual setting may not be supported by the camera. + + + + Frames per second + + + + MJPEG + + + + Tuning / Debug + + + + Number of threads. Can be used to balance the CPU load between the game and the tracker. + + + + ROI Smoothing Alpha + + + + ROI Zoom + + + + Show the image patch that the pose estimation model sees. + + + + Show Network Input + + + + Amount of smoothing of the face region coordinates. Can help stabilize the pose. + + + + Thread Count + + + + Zoom factor for the face region. Applied before the patch is fed into the pose estimation model. There is a sweet spot near 1. + + neuralnet_tracker_ns::NeuralNetDialog diff --git a/tracker-neuralnet/lang/zh_CN.ts b/tracker-neuralnet/lang/zh_CN.ts index 4b24f3db..ab458d6f 100644 --- a/tracker-neuralnet/lang/zh_CN.ts +++ b/tracker-neuralnet/lang/zh_CN.ts @@ -44,6 +44,78 @@ Don't roll or change position. Exposure preset + + Camera Configuration + + + + Camera name + + + + The requested resolution for cases where the camera delivers maximum frame rate only for a particular resolution. The image may still be downscaled to the internal resolution. + + + + Field of view. Needed to transform the pose to world coordinates. + + + + Diagonal FOV + + + + Resolution + + + + Requested video frame rate. Actual setting may not be supported by the camera. + + + + Frames per second + + + + MJPEG + + + + Tuning / Debug + + + + Number of threads. Can be used to balance the CPU load between the game and the tracker. + + + + ROI Smoothing Alpha + + + + ROI Zoom + + + + Show the image patch that the pose estimation model sees. + + + + Show Network Input + + + + Amount of smoothing of the face region coordinates. Can help stabilize the pose. + + + + Thread Count + + + + Zoom factor for the face region. Applied before the patch is fed into the pose estimation model. There is a sweet spot near 1. + + neuralnet_tracker_ns::NeuralNetDialog diff --git a/tracker-neuralnet/neuralnet-trackercontrols.ui b/tracker-neuralnet/neuralnet-trackercontrols.ui index 1c3e9eb6..009b15fd 100644 --- a/tracker-neuralnet/neuralnet-trackercontrols.ui +++ b/tracker-neuralnet/neuralnet-trackercontrols.ui @@ -9,15 +9,401 @@ 0 0 - 445 - 290 + 608 + 384 Tracker settings - + + + + + 0 + 0 + + + + true + + + Camera Configuration + + + false + + + false + + + + 10 + + + 8 + + + + + QLayout::SetDefaultConstraint + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 2 + + + + + Camera name + + + + + + + + 0 + 0 + + + + The requested resolution for cases where the camera delivers maximum frame rate only for a particular resolution. The image may still be downscaled to the internal resolution. + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Field of view. Needed to transform the pose to world coordinates. + + + + + + 35 + + + 90 + + + + + + + Diagonal FOV + + + + + + + Resolution + + + + + + + Exposure preset + + + + + + + + 0 + 0 + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 2 + + + + + + 0 + 0 + + + + Requested video frame rate. Actual setting may not be supported by the camera. + + + + + + + Frames per second + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + + + MJPEG + + + + + + + + 0 + 0 + + + + Camera settings + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + true + + + Tuning / Debug + + + + + + Qt::Vertical + + + + + + + Number of threads. Can be used to balance the CPU load between the game and the tracker. + + + 1 + + + 32 + + + + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + ROI Smoothing Alpha + + + + + + + ROI Zoom + + + + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + Show the image patch that the pose estimation model sees. + + + Show Network Input + + + + + + + + 0 + 0 + + + + + 150 + 16777215 + + + + Amount of smoothing of the face region coordinates. Can help stabilize the pose. + + + false + + + 2 + + + 1.000000000000000 + + + 0.010000000000000 + + + 1.000000000000000 + + + + + + + Thread Count + + + + + + + Zoom factor for the face region. Applied before the patch is fed into the pose estimation model. There is a sweet spot near 1. + + + 0.100000000000000 + + + 2.000000000000000 + + + 0.010000000000000 + + + 1.000000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + @@ -78,21 +464,8 @@ - - - - - 0 - 0 - - - - Right - - - - - + + 150 @@ -110,6 +483,19 @@ + + + + + 0 + 0 + + + + Up + + + @@ -123,8 +509,8 @@ - - + + 150 @@ -142,8 +528,8 @@ - - + + 0 @@ -151,7 +537,7 @@ - Up + Right @@ -223,6 +609,12 @@ Don't roll or change position. false + + + 0 + 0 + + Start calibration @@ -237,7 +629,14 @@ Don't roll or change position. - + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + true @@ -253,59 +652,7 @@ Don't roll or change position. - - - - Camera settings - - - - - - - 1 - 0 - - - - Exposure preset - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - Camera settings - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - + Qt::Vertical @@ -320,6 +667,23 @@ Don't roll or change position. + + camera_settings + cameraName + cameraFOV + resolution + exposure_preset + use_mjpeg + cameraFPS + tx_spin + ty_spin + tz_spin + tcalib_button + threadCount + showNetworkInput + roiFilterAlpha + roiZoom + -- cgit v1.2.3