diff options
Diffstat (limited to 'tracker-aruco')
-rw-r--r-- | tracker-aruco/CMakeLists.txt | 13 | ||||
-rw-r--r-- | tracker-aruco/aruco-trackercontrols.ui | 98 | ||||
-rw-r--r-- | tracker-aruco/ftnoir_tracker_aruco.cpp | 24 | ||||
-rw-r--r-- | tracker-aruco/ftnoir_tracker_aruco.h | 1 | ||||
-rw-r--r-- | tracker-aruco/lang/nl_NL.ts | 12 | ||||
-rw-r--r-- | tracker-aruco/lang/ru_RU.ts | 12 | ||||
-rw-r--r-- | tracker-aruco/lang/stub.ts | 12 | ||||
-rw-r--r-- | tracker-aruco/lang/zh_CN.ts | 34 |
8 files changed, 150 insertions, 56 deletions
diff --git a/tracker-aruco/CMakeLists.txt b/tracker-aruco/CMakeLists.txt index 69fe7aa1..333edb3e 100644 --- a/tracker-aruco/CMakeLists.txt +++ b/tracker-aruco/CMakeLists.txt @@ -11,6 +11,15 @@ include(opentrack-opencv) find_package(OpenCV QUIET) if(OpenCV_FOUND) + set(opencv-modules core calib3d imgproc features2d flann) + foreach(k ${opencv-modules}) + if(NOT TARGET "opencv_${k}") + return() + endif() + endforeach() + foreach(k ${opencv-modules}) + otr_install_lib("opencv_${k}" "${opentrack-libexec}") + endforeach() set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Aruco paper marker tracker static library path") if(SDK_ARUCO_LIBPATH) set(modules "${SDK_ARUCO_LIBPATH}" opencv_calib3d opencv_imgproc opencv_core) @@ -22,14 +31,14 @@ if(OpenCV_FOUND) try_compile(tracker-aruco_has-working-abi "${CMAKE_CURRENT_BINARY_DIR}" SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/compile-test/abi.cpp" CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${dir}" - "-DCXX_STANDARD=17" "-DCXX_STANDARD_REQUIRED=1" + "-DCXX_STANDARD=20" "-DCXX_STANDARD_REQUIRED=1" OUTPUT_VARIABLE krap) if(NOT tracker-aruco_has-working-abi) message(FATAL_ERROR "${krap}\n" "Must use Aruco fork from <https://github.com/opentrack/aruco>") endif() maybe_add_static_define() - otr_install_lib("${SDK_ARUCO_LIBPATH}" "${opentrack-hier-pfx}") + otr_install_lib("${SDK_ARUCO_LIBPATH}" "${opentrack-libexec}") otr_module(tracker-aruco) target_include_directories(${self} SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS} "${dir}") diff --git a/tracker-aruco/aruco-trackercontrols.ui b/tracker-aruco/aruco-trackercontrols.ui index 9c3bd78a..729d4b48 100644 --- a/tracker-aruco/aruco-trackercontrols.ui +++ b/tracker-aruco/aruco-trackercontrols.ui @@ -9,8 +9,8 @@ <rect> <x>0</x> <y>0</y> - <width>462</width> - <height>221</height> + <width>457</width> + <height>230</height> </rect> </property> <property name="windowTitle"> @@ -64,13 +64,17 @@ <item> <widget class="QFrame" name="frame"> <layout class="QGridLayout" name="gridLayout_4"> - <item row="2" column="1"> - <widget class="QComboBox" name="cameraName"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item row="4" column="0"> + <widget class="QLabel" name="label_11"> + <property name="text"> + <string>Resolution</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Camera name</string> </property> </widget> </item> @@ -93,7 +97,24 @@ </property> </widget> </item> - <item row="3" column="1"> + <item row="1" column="0"> + <widget class="QLabel" name="label_12"> + <property name="text"> + <string>Frames per second</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="cameraFPS"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="4" column="1"> <widget class="QComboBox" name="resolution"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> @@ -113,32 +134,21 @@ </item> <item> <property name="text"> + <string>1280x720</string> + </property> + </item> + <item> + <property name="text"> + <string>1920x1080</string> + </property> + </item> + <item> + <property name="text"> <string>Default (not recommended!)</string> </property> </item> </widget> </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_12"> - <property name="text"> - <string>Frames per second</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_11"> - <property name="text"> - <string>Resolution</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_10"> - <property name="text"> - <string>Camera name</string> - </property> - </widget> - </item> <item row="0" column="0"> <widget class="QLabel" name="label_9"> <property name="text"> @@ -146,8 +156,8 @@ </property> </widget> </item> - <item row="1" column="1"> - <widget class="QComboBox" name="cameraFPS"> + <item row="2" column="1"> + <widget class="QComboBox" name="cameraName"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -156,7 +166,7 @@ </property> </widget> </item> - <item row="4" column="1"> + <item row="5" column="1"> <widget class="QPushButton" name="camera_settings"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> @@ -169,6 +179,26 @@ </property> </widget> </item> + <item row="3" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>MJPEG</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QCheckBox" name="use_mjpeg"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> </layout> </widget> </item> 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())); diff --git a/tracker-aruco/ftnoir_tracker_aruco.h b/tracker-aruco/ftnoir_tracker_aruco.h index 3c50ada0..839be6d5 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.h +++ b/tracker-aruco/ftnoir_tracker_aruco.h @@ -62,6 +62,7 @@ struct settings : opts { value<int> resolution { b, "force-resolution", 0 }; value<int> fov { b, "field-of-view", 56 }; value<aruco_fps> force_fps { b, "force-fps", fps_default }; + value<bool> use_mjpeg { b, "use-mjpeg", false }; settings(); }; diff --git a/tracker-aruco/lang/nl_NL.ts b/tracker-aruco/lang/nl_NL.ts index 87040565..e5a94f3b 100644 --- a/tracker-aruco/lang/nl_NL.ts +++ b/tracker-aruco/lang/nl_NL.ts @@ -59,6 +59,18 @@ <source>Toggle calibration</source> <translation>Schakel tussen kalibratie</translation> </message> + <message> + <source>1280x720</source> + <translation>1280x720</translation> + </message> + <message> + <source>MJPEG</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>1920x1080</source> + <translation type="unfinished">1280x1080 {1920x?}</translation> + </message> </context> <context> <name>aruco_dialog</name> diff --git a/tracker-aruco/lang/ru_RU.ts b/tracker-aruco/lang/ru_RU.ts index 57c8170d..639b59ce 100644 --- a/tracker-aruco/lang/ru_RU.ts +++ b/tracker-aruco/lang/ru_RU.ts @@ -59,6 +59,18 @@ <source>Toggle calibration</source> <translation type="unfinished"></translation> </message> + <message> + <source>1280x720</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>MJPEG</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>1920x1080</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>aruco_dialog</name> diff --git a/tracker-aruco/lang/stub.ts b/tracker-aruco/lang/stub.ts index 67cb36b8..f213eb41 100644 --- a/tracker-aruco/lang/stub.ts +++ b/tracker-aruco/lang/stub.ts @@ -59,6 +59,18 @@ <source>Toggle calibration</source> <translation type="unfinished"></translation> </message> + <message> + <source>1280x720</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>MJPEG</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>1920x1080</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>aruco_dialog</name> diff --git a/tracker-aruco/lang/zh_CN.ts b/tracker-aruco/lang/zh_CN.ts index b5093b4e..5d5646b7 100644 --- a/tracker-aruco/lang/zh_CN.ts +++ b/tracker-aruco/lang/zh_CN.ts @@ -1,47 +1,47 @@ <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> -<TS version="2.1"> +<TS version="2.1" language="zh_CN"> <context> <name>Form</name> <message> <source>Tracker settings</source> - <translation type="unfinished"></translation> + <translation>追踪器设置</translation> </message> <message> <source><html><head/><body><p>Read the <a href="https://github.com/opentrack/opentrack/wiki/Aruco-tracker"><span style=" text-decoration: underline; color:#0000ff;">wiki page</span></a> and especially the last paragraph before printing markers.</p></body></html></source> - <translation type="unfinished"></translation> + <translation type="unfinished"><html><head/><body><p>阅读此<a href="https://github.com/opentrack/opentrack/wiki/Aruco-tracker"><span style=" text-decoration: underline; color:#0077DD;">Wiki页面</span></a> 特别是打印标记前的最后一段. </p></body></html></translation> </message> <message> <source>Diagonal FOV</source> - <translation type="unfinished"></translation> + <translation>对角FOV</translation> </message> <message> <source>640x480</source> - <translation type="unfinished"></translation> + <translation></translation> </message> <message> <source>320x240</source> - <translation type="unfinished"></translation> + <translation></translation> </message> <message> <source>Default (not recommended!)</source> - <translation type="unfinished"></translation> + <translation>默认 (不推荐!)</translation> </message> <message> <source>Camera name</source> - <translation type="unfinished"></translation> + <translation>相机名称</translation> </message> <message> <source>Frames per second</source> - <translation type="unfinished"></translation> + <translation>FPS</translation> </message> <message> <source>Resolution</source> - <translation type="unfinished"></translation> + <translation type="unfinished">分辨率</translation> </message> <message> <source>Camera settings</source> - <translation type="unfinished"></translation> + <translation>相机设置</translation> </message> <message> <source>Head X</source> @@ -57,8 +57,20 @@ </message> <message> <source>Toggle calibration</source> + <translation>切换校准</translation> + </message> + <message> + <source>1280x720</source> + <translation></translation> + </message> + <message> + <source>MJPEG</source> <translation type="unfinished"></translation> </message> + <message> + <source>1920x1080</source> + <translation></translation> + </message> </context> <context> <name>aruco_dialog</name> |