diff options
Diffstat (limited to 'tracker-pt')
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt.cpp | 21 | ||||
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt.h | 4 | ||||
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt_dialog.cpp | 2 | ||||
-rw-r--r-- | tracker-pt/lang/nl_NL.ts | 7 | ||||
-rw-r--r-- | tracker-pt/lang/ru_RU.ts | 7 | ||||
-rw-r--r-- | tracker-pt/lang/stub.ts | 7 | ||||
-rw-r--r-- | tracker-pt/lang/zh_CN.ts | 191 | ||||
-rw-r--r-- | tracker-pt/module/camera.cpp | 33 | ||||
-rw-r--r-- | tracker-pt/module/camera.h | 6 | ||||
-rw-r--r-- | tracker-pt/point_tracker.cpp | 2 | ||||
-rw-r--r-- | tracker-pt/point_tracker.h | 2 | ||||
-rw-r--r-- | tracker-pt/pt-api.cpp | 1 | ||||
-rw-r--r-- | tracker-pt/pt-api.hpp | 6 |
13 files changed, 149 insertions, 140 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index af086e5c..243fbd60 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -120,22 +120,12 @@ void Tracker_PT::run() qDebug() << "pt: thread stopped"; } -void Tracker_PT::maybe_reopen_camera() +bool Tracker_PT::maybe_reopen_camera() { QMutexLocker l(&camera_mtx); - pt_camera_open_status status = camera->start(camera_name_to_index(s.camera_name), - s.cam_fps, s.cam_res_x, s.cam_res_y); - - switch (status) - { - case cam_open_error: - break; - case cam_open_ok_change: - break; - case cam_open_ok_no_change: - break; - } + return camera->start(camera_name_to_index(s.camera_name), + s.cam_fps, s.cam_res_x, s.cam_res_y); } void Tracker_PT::set_fov(int value) @@ -156,11 +146,12 @@ module_status Tracker_PT::start_tracker(QFrame* video_frame) //video_widget->resize(video_frame->width(), video_frame->height()); video_frame->show(); - maybe_reopen_camera(); + if (!maybe_reopen_camera()) + return { tr("Can't open camera") }; start(QThread::HighPriority); - return status_ok(); + return {}; } void Tracker_PT::data(double *data) diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h index d1f7e1d7..03812092 100644 --- a/tracker-pt/ftnoir_tracker_pt.h +++ b/tracker-pt/ftnoir_tracker_pt.h @@ -53,7 +53,7 @@ public: int get_n_points(); bool get_cam_info(pt_camera_info* info); public slots: - void maybe_reopen_camera(); + bool maybe_reopen_camera(); void set_fov(int value); protected: void run() override; @@ -81,7 +81,7 @@ private: std::atomic<unsigned> point_count = 0; std::atomic<bool> ever_success = false; - static constexpr f rad2deg = f(180/M_PI); + static constexpr inline f rad2deg = f(180/M_PI); //static constexpr float deg2rad = float(M_PI/180); }; diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index 10a2c6cb..5bd1a4c8 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -90,7 +90,7 @@ TrackerDialog_PT::TrackerDialog_PT(const QString& module_name) : connect(this, &TrackerDialog_PT::poll_tracker_info, this, &TrackerDialog_PT::poll_tracker_info_impl, Qt::DirectConnection); - static constexpr pt_color_type color_types[] = { + constexpr pt_color_type color_types[] = { pt_color_average, pt_color_natural, pt_color_red_only, diff --git a/tracker-pt/lang/nl_NL.ts b/tracker-pt/lang/nl_NL.ts index 16aaa82e..34f88c88 100644 --- a/tracker-pt/lang/nl_NL.ts +++ b/tracker-pt/lang/nl_NL.ts @@ -276,4 +276,11 @@ Don't roll or change position.</source> <translation type="unfinished"></translation> </message> </context> +<context> + <name>pt_module::Tracker_PT</name> + <message> + <source>Can't open camera</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/tracker-pt/lang/ru_RU.ts b/tracker-pt/lang/ru_RU.ts index 88f3cb4a..63b4847a 100644 --- a/tracker-pt/lang/ru_RU.ts +++ b/tracker-pt/lang/ru_RU.ts @@ -281,4 +281,11 @@ ROLL или X/Y-смещения.</translation> <translation>Параметры камеры:</translation> </message> </context> +<context> + <name>pt_module::Tracker_PT</name> + <message> + <source>Can't open camera</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/tracker-pt/lang/stub.ts b/tracker-pt/lang/stub.ts index a3377c2e..e83487a9 100644 --- a/tracker-pt/lang/stub.ts +++ b/tracker-pt/lang/stub.ts @@ -276,4 +276,11 @@ Don't roll or change position.</source> <translation type="unfinished"></translation> </message> </context> +<context> + <name>pt_module::Tracker_PT</name> + <message> + <source>Can't open camera</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/tracker-pt/lang/zh_CN.ts b/tracker-pt/lang/zh_CN.ts index 2a8e9ca0..07d8c469 100644 --- a/tracker-pt/lang/zh_CN.ts +++ b/tracker-pt/lang/zh_CN.ts @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> -<TS version="2.1"> +<TS version="2.1" language="zh_CN"> <context> <name>TrackerDialog_PT</name> <message> @@ -29,7 +29,7 @@ </message> <message> <source>Start calibration</source> - <translation type="unfinished"></translation> + <translation type="unfinished">开始校准</translation> </message> <message> <source>%1x%2 @ %3 FPS</source> @@ -52,227 +52,234 @@ <name>UICPTClientControls</name> <message> <source>PointTracker Settings</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Status</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Extracted Points:</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Camera Info:</source> - <translation type="unfinished"></translation> + <translation>PointTracker设置</translation> </message> <message> <source>Camera</source> - <translation type="unfinished"></translation> + <translation>摄像头</translation> </message> <message> <source>Camera settings</source> - <translation type="unfinished"></translation> + <translation>摄像头设置</translation> </message> <message> <source>°</source> - <translation type="unfinished"></translation> + <translation>度</translation> </message> <message> <source>Diagonal field of view</source> - <translation type="unfinished"></translation> + <translation>对角线</translation> </message> <message> <source>Width</source> - <translation type="unfinished"></translation> + <translation></translation> </message> <message> <source>FPS</source> - <translation type="unfinished"></translation> + <translation>帧数</translation> </message> <message> <source>Desired capture height</source> - <translation type="unfinished"></translation> + <translation>期望高度</translation> </message> <message> <source> px</source> - <translation type="unfinished"></translation> + <translation> 像素点</translation> </message> <message> <source>Dynamic pose timeout</source> - <translation type="unfinished"></translation> + <translation>动态姿态超时时间</translation> </message> <message> <source>Desired capture framerate</source> - <translation type="unfinished"></translation> + <translation>期望帧数</translation> </message> <message> <source> Hz</source> - <translation type="unfinished"></translation> + <translation> 赫兹</translation> </message> <message> <source>Desired capture width</source> - <translation type="unfinished"></translation> + <translation>期望宽度</translation> </message> <message> <source>Height</source> - <translation type="unfinished"></translation> + <translation>高度</translation> </message> <message> <source> ms</source> - <translation type="unfinished"></translation> + <translation> 毫秒</translation> </message> <message> <source>Device</source> - <translation type="unfinished"></translation> + <translation>设备名称</translation> </message> <message> <source>Open</source> - <translation type="unfinished"></translation> + <translation>打开</translation> </message> <message> <source>Camera settings (when available)</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Color channels used</source> - <translation type="unfinished"></translation> + <translation>摄像头设置 (连接时)</translation> </message> <message> - <source>Average</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Natural</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Red only</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Blue only</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Dynamic pose (for caps only, never clips)</source> - <translation type="unfinished"></translation> + <source>Point extraction</source> + <translation>跟踪点解析</translation> </message> <message> - <source>Point extraction</source> - <translation type="unfinished"></translation> + <source>Max size</source> + <translation>最大</translation> </message> <message> <source>Threshold</source> - <translation type="unfinished"></translation> + <translation>大小门限值</translation> </message> <message> <source>Min size</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Max size</source> - <translation type="unfinished"></translation> + <translation>最小</translation> </message> <message> <source>Intensity threshold for point extraction</source> - <translation type="unfinished"></translation> + <translation>点密度</translation> </message> <message> - <source>Enable, slider sets point size</source> - <translation type="unfinished"></translation> + <source>Automatic threshold</source> + <translation>自动门限值</translation> </message> <message> - <source>Automatic threshold</source> - <translation type="unfinished"></translation> + <source>Enable, slider sets point size</source> + <translation>激活,滑动,设置跟踪点大小</translation> </message> <message> <source>Maximum point diameter</source> - <translation type="unfinished"></translation> + <translation>最大点直径</translation> </message> <message> <source>Minimum point diameter</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Value</source> - <translation type="unfinished"></translation> + <translation>最小点直径</translation> </message> <message> <source>Model</source> - <translation type="unfinished"></translation> + <translation>点模式</translation> </message> <message> <source>Clip</source> - <translation type="unfinished"></translation> + <translation>夹子式</translation> </message> <message> <source>Model Dimensions</source> - <translation type="unfinished"></translation> + <translation>尺寸</translation> </message> <message> <source> mm</source> - <translation type="unfinished"></translation> + <translation> 毫米</translation> </message> <message> <source>Side</source> - <translation type="unfinished"></translation> + <translation>侧面</translation> </message> <message> <source>Front</source> - <translation type="unfinished"></translation> + <translation>正面</translation> </message> <message> <source>Cap</source> - <translation type="unfinished"></translation> + <translation>帽子式</translation> </message> <message> <source>Custom</source> - <translation type="unfinished"></translation> + <translation>自定义模式</translation> </message> <message> <source>z:</source> - <translation type="unfinished"></translation> + <translation>Z:</translation> </message> <message> <source>x:</source> - <translation type="unfinished"></translation> + <translation>X:</translation> </message> <message> <source><html><head/><body><p>Location of the two remaining model points<br/>with respect to the reference point in default pose</p><p>Use any units you want, not necessarily centimeters.</p></body></html></source> - <translation type="unfinished"></translation> + <translation><html><head/><body><p>三点中的两点位置是相对第一个点的</p><p>单位不一定要用厘米</p></body></html></translation> </message> <message> <source>y:</source> - <translation type="unfinished"></translation> + <translation>Y:</translation> </message> <message> <source><html><head/><body><p><span style=" font-size:16pt;">P</span><span style=" font-size:16pt; vertical-align:sub;">3</span></p></body></html></source> - <translation type="unfinished"></translation> + <translation><html><head/><body><p><span style=" font-size:16pt;">P</span><span style=" font-size:16pt; vertical-align:sub;">3</span></p></body></html></translation> </message> <message> <source><html><head/><body><p><span style=" font-size:16pt;">P</span><span style=" font-size:16pt; vertical-align:sub;">2</span></p></body></html></source> - <translation type="unfinished"></translation> + <translation><html><head/><body><p><span style=" font-size:16pt;">P</span><span style=" font-size:16pt; vertical-align:sub;">2</span></p></body></html></translation> </message> <message> <source>Model position</source> + <translation>姿态空间位置</translation> + </message> + <message> + <source>Start calibration</source> + <translation>开始校准</translation> + </message> + <message> + <source>About</source> + <translation>关于</translation> + </message> + <message> + <source><html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 1.1</span></p><p><span style=" font-weight:600;">by Patrick Ruoff</span></p><p><a href="http://ftnoirpt.sourceforge.net/"><span style=" font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html></source> + <translation><html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 1.1</span></p><p><span style=" font-weight:600;">Patrick Ruoff</span></p><p><a href="http://ftnoirpt.sourceforge.net/"><span style=" font-weight:600; text-decoration: underline; color:#0000ff;">参考手册 (外部链接)</span></a></p></body></html></translation> + </message> + <message> + <source>Status</source> + <translation>状态</translation> + </message> + <message> + <source>Extracted Points:</source> + <translation>解析出的点:</translation> + </message> + <message> + <source>Camera Info:</source> + <translation>设备信息:</translation> + </message> + <message> + <source>Color channels used</source> <translation type="unfinished"></translation> </message> <message> - <source>Use only yaw and pitch while calibrating. -Don't roll or change position.</source> + <source>Average</source> <translation type="unfinished"></translation> </message> <message> - <source>Start calibration</source> + <source>Natural</source> <translation type="unfinished"></translation> </message> <message> - <source>About</source> + <source>Red only</source> <translation type="unfinished"></translation> </message> <message> - <source><html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 1.1</span></p><p><span style=" font-weight:600;">by Patrick Ruoff</span></p><p><a href="http://ftnoirpt.sourceforge.net/"><span style=" font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html></source> + <source>Blue only</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Dynamic pose (for caps only, never clips)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Value</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Use only yaw and pitch while calibrating. +Don't roll or change position.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>pt_module::Tracker_PT</name> + <message> + <source>Can't open camera</source> <translation type="unfinished"></translation> </message> </context> diff --git a/tracker-pt/module/camera.cpp b/tracker-pt/module/camera.cpp index ba4583da..9c62e8a3 100644 --- a/tracker-pt/module/camera.cpp +++ b/tracker-pt/module/camera.cpp @@ -36,19 +36,18 @@ void Camera::show_camera_settings() { const int idx = camera_name_to_index(s.camera_name); - if (bool(*this)) + if (cap && cap->isOpened()) video_property_page::show_from_capture(*cap, idx); else - { video_property_page::show(idx); - } } Camera::result Camera::get_info() const { if (cam_info.res_x == 0 || cam_info.res_y == 0) - return result(false, pt_camera_info()); - return result(true, cam_info); + return { false, pt_camera_info() }; + else + return { true, cam_info }; } Camera::result Camera::get_frame(pt_frame& frame_) @@ -82,7 +81,7 @@ Camera::result Camera::get_frame(pt_frame& frame_) return result(false, pt_camera_info()); } -pt_camera_open_status Camera::start(int idx, int fps, int res_x, int res_y) +bool Camera::start(int idx, int fps, int res_x, int res_y) { if (idx >= 0 && fps >= 0 && res_x >= 0 && res_y >= 0) { @@ -110,7 +109,7 @@ pt_camera_open_status Camera::start(int idx, int fps, int res_x, int res_y) if (cam_desired.fps) cap->set(cv::CAP_PROP_FPS, cam_desired.fps); - if (cap->isOpened() && cap->grab()) + if (cap->isOpened()) { cam_info = pt_camera_info(); active_name = QString(); @@ -118,22 +117,24 @@ pt_camera_open_status Camera::start(int idx, int fps, int res_x, int res_y) dt_mean = 0; active_name = desired_name; - t.start(); + cv::Mat tmp; - return cam_open_ok_change; - } - else - { - stop(); - return cam_open_error; + if (_get_frame(tmp)) + { + t.start(); + return true; + } } + + cap = nullptr; + return false; } - return cam_open_ok_no_change; + return true; } stop(); - return cam_open_error; + return false; } void Camera::stop() diff --git a/tracker-pt/module/camera.h b/tracker-pt/module/camera.h index 96234840..79e3dca0 100644 --- a/tracker-pt/module/camera.h +++ b/tracker-pt/module/camera.h @@ -26,7 +26,7 @@ struct Camera final : pt_camera { Camera(const QString& module_name); - pt_camera_open_status start(int idx, int fps, int res_x, int res_y) override; + bool start(int idx, int fps, int res_x, int res_y) override; void stop() override; result get_frame(pt_frame& Frame) override; @@ -36,8 +36,6 @@ struct Camera final : pt_camera QString get_desired_name() const override; QString get_active_name() const override; - operator bool() const override { return cap && cap->isOpened(); } - void set_fov(double value) override { fov = value; } void show_camera_settings() override; @@ -45,9 +43,7 @@ private: warn_result_unused bool _get_frame(cv::Mat& Frame); double dt_mean = 0, fov = 30; - Timer t; - pt_camera_info cam_info; pt_camera_info cam_desired; QString desired_name, active_name; diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp index 5efbbfe8..6116bec5 100644 --- a/tracker-pt/point_tracker.cpp +++ b/tracker-pt/point_tracker.cpp @@ -16,8 +16,6 @@ using namespace types; #include <QDebug> -constexpr unsigned PointModel::N_POINTS; - static void get_row(const mat33& m, int i, vec3& v) { v[0] = m(i,0); diff --git a/tracker-pt/point_tracker.h b/tracker-pt/point_tracker.h index 6abe5df9..5e741c75 100644 --- a/tracker-pt/point_tracker.h +++ b/tracker-pt/point_tracker.h @@ -32,7 +32,7 @@ using namespace types; struct PointModel final { - static constexpr unsigned N_POINTS = 3; + static constexpr inline unsigned N_POINTS = 3; vec3 M01; // M01 in model frame vec3 M02; // M02 in model frame diff --git a/tracker-pt/pt-api.cpp b/tracker-pt/pt-api.cpp index 298f405a..596590dc 100644 --- a/tracker-pt/pt-api.cpp +++ b/tracker-pt/pt-api.cpp @@ -57,7 +57,6 @@ double pt_point_extractor::threshold_radius_value(int w, int h, int threshold) return radius; } - std::tuple<double, double> pt_pixel_pos_mixin::to_pixel_pos(double x, double y, int w, int h) { return std::make_tuple(w*(x+.5), .5*(h - 2*y*w)); diff --git a/tracker-pt/pt-api.hpp b/tracker-pt/pt-api.hpp index e946c5d0..de097a04 100644 --- a/tracker-pt/pt-api.hpp +++ b/tracker-pt/pt-api.hpp @@ -30,8 +30,6 @@ struct OTR_PT_EXPORT pt_camera_info final int idx = -1; }; -enum pt_camera_open_status : unsigned { cam_open_error, cam_open_ok_no_change, cam_open_ok_change }; - struct OTR_PT_EXPORT pt_pixel_pos_mixin { static std::tuple<double, double> to_pixel_pos(double x, double y, int w, int h); @@ -73,7 +71,7 @@ struct OTR_PT_EXPORT pt_camera pt_camera(); virtual ~pt_camera(); - virtual warn_result_unused pt_camera_open_status start(int idx, int fps, int res_x, int res_y) = 0; + virtual warn_result_unused bool start(int idx, int fps, int res_x, int res_y) = 0; virtual void stop() = 0; virtual warn_result_unused result get_frame(pt_frame& frame) = 0; @@ -84,8 +82,6 @@ struct OTR_PT_EXPORT pt_camera virtual QString get_active_name() const = 0; virtual void set_fov(double value) = 0; - virtual operator bool() const = 0; - virtual void show_camera_settings() = 0; }; |