summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStéphane Lenclud <github@lenclud.com>2019-04-24 23:34:36 +0200
committerStéphane Lenclud <github@lenclud.com>2019-04-24 23:34:36 +0200
commit4039631386ae84abbf476263b28c92d91ac23b81 (patch)
treef55a4139c1ef03e20a9d7dbf5948d7964fc6db3d
parent77a469de95a498a4860b7da72b38508d40c2bede (diff)
Adding support for four points model.
Can't get it to work correctly though.
-rw-r--r--tracker-easy/lang/nl_NL.ts40
-rw-r--r--tracker-easy/lang/ru_RU.ts41
-rw-r--r--tracker-easy/lang/stub.ts40
-rw-r--r--tracker-easy/lang/zh_CN.ts40
-rw-r--r--tracker-easy/point-extractor.cpp4
-rw-r--r--tracker-easy/point-extractor.h5
-rw-r--r--tracker-easy/preview.cpp10
-rw-r--r--tracker-easy/preview.h2
-rw-r--r--tracker-easy/settings.h6
-rw-r--r--tracker-easy/tracker-easy-dialog.cpp20
-rw-r--r--tracker-easy/tracker-easy-settings.ui261
-rw-r--r--tracker-easy/tracker-easy.cpp116
-rw-r--r--tracker-easy/tracker-easy.h8
13 files changed, 437 insertions, 156 deletions
diff --git a/tracker-easy/lang/nl_NL.ts b/tracker-easy/lang/nl_NL.ts
index 22a99106..f084f93f 100644
--- a/tracker-easy/lang/nl_NL.ts
+++ b/tracker-easy/lang/nl_NL.ts
@@ -142,10 +142,6 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Custom</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
<source>z:</source>
<translation type="unfinished"></translation>
</message>
@@ -154,22 +150,10 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Location of the two remaining model points&lt;br/&gt;with respect to the reference point in default pose&lt;/p&gt;&lt;p&gt;Use any units you want, not necessarily centimeters.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
<source>y:</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;3&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;2&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
<source>Model position</source>
<translation type="unfinished"></translation>
</message>
@@ -254,5 +238,29 @@ Don&apos;t roll or change position.</source>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Four</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Model vertices</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Top&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Left&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Right&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Center&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
</TS>
diff --git a/tracker-easy/lang/ru_RU.ts b/tracker-easy/lang/ru_RU.ts
index d45c89d1..e05e58f3 100644
--- a/tracker-easy/lang/ru_RU.ts
+++ b/tracker-easy/lang/ru_RU.ts
@@ -142,10 +142,6 @@
<translation>Кепка</translation>
</message>
<message>
- <source>Custom</source>
- <translation>Свой</translation>
- </message>
- <message>
<source>z:</source>
<translation></translation>
</message>
@@ -154,23 +150,10 @@
<translation></translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Location of the two remaining model points&lt;br/&gt;with respect to the reference point in default pose&lt;/p&gt;&lt;p&gt;Use any units you want, not necessarily centimeters.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translatorcomment>Расположение двух оставшихся точек модели относительно опорной точки в стандартной позе. Возможно исп-ть любые единицы измерения, не обязательно сантиметры.</translatorcomment>
- <translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt; Расположение двух оставшихся точек модели&lt;br/&gt;относительно опорной точки в стандартной позе. &lt;/p&gt;&lt;p&gt;Возможно использовать любые единицы измерения.&lt;/p&gt;&lt;/body&gt;&lt;/html</translation>
- </message>
- <message>
<source>y:</source>
<translation></translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;3&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation></translation>
- </message>
- <message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;2&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation></translation>
- </message>
- <message>
<source>Model position</source>
<translation>Положение модели</translation>
</message>
@@ -259,5 +242,29 @@ ROLL или X/Y-смещения.</translation>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Four</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Model vertices</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Top&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Left&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Right&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Center&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
</TS>
diff --git a/tracker-easy/lang/stub.ts b/tracker-easy/lang/stub.ts
index 1b58a8f4..89c6d087 100644
--- a/tracker-easy/lang/stub.ts
+++ b/tracker-easy/lang/stub.ts
@@ -142,10 +142,6 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Custom</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
<source>z:</source>
<translation type="unfinished"></translation>
</message>
@@ -154,22 +150,10 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Location of the two remaining model points&lt;br/&gt;with respect to the reference point in default pose&lt;/p&gt;&lt;p&gt;Use any units you want, not necessarily centimeters.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
<source>y:</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;3&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;2&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
<source>Model position</source>
<translation type="unfinished"></translation>
</message>
@@ -254,5 +238,29 @@ Don&apos;t roll or change position.</source>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Four</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Model vertices</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Top&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Left&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Right&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Center&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
</TS>
diff --git a/tracker-easy/lang/zh_CN.ts b/tracker-easy/lang/zh_CN.ts
index d524aaed..417de26a 100644
--- a/tracker-easy/lang/zh_CN.ts
+++ b/tracker-easy/lang/zh_CN.ts
@@ -142,10 +142,6 @@
<translation>帽子式</translation>
</message>
<message>
- <source>Custom</source>
- <translation>自定义模式</translation>
- </message>
- <message>
<source>z:</source>
<translation>Z:</translation>
</message>
@@ -154,22 +150,10 @@
<translation>X:</translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Location of the two remaining model points&lt;br/&gt;with respect to the reference point in default pose&lt;/p&gt;&lt;p&gt;Use any units you want, not necessarily centimeters.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;三点中的两点位置是相对第一个点的&lt;/p&gt;&lt;p&gt;单位不一定要用厘米&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
- </message>
- <message>
<source>y:</source>
<translation>Y:</translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;3&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;3&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
- </message>
- <message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;2&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
- <translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;2&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
- </message>
- <message>
<source>Model position</source>
<translation>姿态空间位置</translation>
</message>
@@ -254,5 +238,29 @@ Don&apos;t roll or change position.</source>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Four</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Model vertices</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Top&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Left&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Right&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Center&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
</TS>
diff --git a/tracker-easy/point-extractor.cpp b/tracker-easy/point-extractor.cpp
index 61175a57..0a5ca81d 100644
--- a/tracker-easy/point-extractor.cpp
+++ b/tracker-easy/point-extractor.cpp
@@ -35,7 +35,7 @@ namespace EasyTracker
}
- void PointExtractor::ExtractPoints(const cv::Mat& aFrame, cv::Mat* aPreview, std::vector<cv::Point>& aPoints)
+ void PointExtractor::ExtractPoints(const cv::Mat& aFrame, cv::Mat* aPreview, int aNeededPointCount, std::vector<cv::Point>& aPoints)
{
//TODO: Assert if channel size is neither one nor two
// Make sure our frame channel is 8 bit
@@ -133,7 +133,7 @@ namespace EasyTracker
// Typically noise comming from zippers and metal parts on your clothing.
// With a cap tracker it also successfully discards noise from glasses.
// However it may not work as good with a clip user wearing glasses.
- while (aPoints.size() > KPointCount) // Until we have no more than three points
+ while (aPoints.size() > aNeededPointCount) // Until we have no more than three points
{
int maxY = 0;
size_t index = -1;
diff --git a/tracker-easy/point-extractor.h b/tracker-easy/point-extractor.h
index 3c65b193..b037eed6 100644
--- a/tracker-easy/point-extractor.h
+++ b/tracker-easy/point-extractor.h
@@ -17,16 +17,13 @@
namespace EasyTracker
{
-
- const int KPointCount = 3;
-
class PointExtractor
{
public:
PointExtractor();
// extracts points from frame and draws some processing info into frame, if draw_output is set
// dt: time since last call in seconds
- void ExtractPoints(const cv::Mat& aFrame, cv::Mat* aPreview, std::vector<cv::Point>& aPoints);
+ void ExtractPoints(const cv::Mat& aFrame, cv::Mat* aPreview, int aNeededPointCount, std::vector<cv::Point>& aPoints);
// Settings
Settings s;
diff --git a/tracker-easy/preview.cpp b/tracker-easy/preview.cpp
index 4d6b7c61..218fca43 100644
--- a/tracker-easy/preview.cpp
+++ b/tracker-easy/preview.cpp
@@ -105,19 +105,17 @@ namespace EasyTracker
cv::putText(iFrameRgb, aString, cv::Point(4,iFrameRgb.size().height-4), cv::FONT_HERSHEY_PLAIN, 2, cv::Scalar(0, 255, 0),2);
}
- void Preview::DrawCross(cv::Point aPoint)
+ void Preview::DrawCross(const cv::Point& aPoint, const cv::Scalar& aColor)
{
- constexpr int len = 9;
-
- static const cv::Scalar color(0, 255, 255);
+ constexpr int len = 9;
cv::line(iFrameRgb,
cv::Point(aPoint.x - len, aPoint.y),
cv::Point(aPoint.x + len, aPoint.y),
- color, 2);
+ aColor, 2);
cv::line(iFrameRgb,
cv::Point(aPoint.x, aPoint.y - len),
cv::Point(aPoint.x, aPoint.y + len),
- color, 2);
+ aColor, 2);
}
void Preview::ensure_size(cv::Mat& frame, int w, int h, int type)
diff --git a/tracker-easy/preview.h b/tracker-easy/preview.h
index 74ef89aa..d5cc8c30 100644
--- a/tracker-easy/preview.h
+++ b/tracker-easy/preview.h
@@ -21,7 +21,7 @@ namespace EasyTracker
Preview& operator=(const cv::Mat& frame);
QImage get_bitmap();
- void DrawCross(cv::Point aPoint);
+ void DrawCross(const cv::Point& aPoint, const cv::Scalar& aColor);
void DrawInfo(const std::string& aString);
operator cv::Mat&() { return iFrameResized; }
diff --git a/tracker-easy/settings.h b/tracker-easy/settings.h
index b4c14967..8c6a2b3e 100644
--- a/tracker-easy/settings.h
+++ b/tracker-easy/settings.h
@@ -27,8 +27,10 @@ namespace EasyTracker {
max_point_size{ b, "max-point-size", 50 };
value<int> DeadzoneRectHalfEdgeSize { b, "deadzone-rect-half-edge-size", 1 };
- value<int> m01_x{ b, "m_01-x", 0 }, m01_y{ b, "m_01-y", 0 }, m01_z{ b, "m_01-z", 0 };
- value<int> m02_x{ b, "m_02-x", 0 }, m02_y{ b, "m_02-y", 0 }, m02_z{ b, "m_02-z", 0 };
+ value<int> iFourPointsTopX{ b, "iFourPointsTopX", 0 }, iFourPointsTopY{ b, "iFourPointsTopY", 0 }, iFourPointsTopZ{ b, "iFourPointsTopZ", 0 };
+ value<int> iFourPointsLeftX{ b, "iFourPointsLeftX", 0 }, iFourPointsLeftY{ b, "iFourPointsLeftY", 0 }, iFourPointsLeftZ{ b, "iFourPointsLeftZ", 0 };
+ value<int> iFourPointsRightX{ b, "iFourPointsRightX", 0 }, iFourPointsRightY{ b, "iFourPointsRightY", 0 }, iFourPointsRightZ{ b, "iFourPointsRightZ", 0 };
+ value<int> iFourPointsCenterX{ b, "iFourPointsCenterX", 0 }, iFourPointsCenterY{ b, "iFourPointsCenterY", 0 }, iFourPointsCenterZ{ b, "iFourPointsCenterZ", 0 };
value<int> t_MH_x{ b, "model-centroid-x", 0 },
t_MH_y{ b, "model-centroid-y", 0 },
diff --git a/tracker-easy/tracker-easy-dialog.cpp b/tracker-easy/tracker-easy-dialog.cpp
index fe0091c5..ce100b48 100644
--- a/tracker-easy/tracker-easy-dialog.cpp
+++ b/tracker-easy/tracker-easy-dialog.cpp
@@ -55,13 +55,21 @@ namespace EasyTracker
tie_setting(s.cap_y, ui.cap_height_spin);
tie_setting(s.cap_z, ui.cap_length_spin);
- tie_setting(s.m01_x, ui.m1x_spin);
- tie_setting(s.m01_y, ui.m1y_spin);
- tie_setting(s.m01_z, ui.m1z_spin);
+ tie_setting(s.iFourPointsTopX, ui.iSpinFourTopX);
+ tie_setting(s.iFourPointsTopY, ui.iSpinFourTopY);
+ tie_setting(s.iFourPointsTopZ, ui.iSpinFourTopZ);
- tie_setting(s.m02_x, ui.m2x_spin);
- tie_setting(s.m02_y, ui.m2y_spin);
- tie_setting(s.m02_z, ui.m2z_spin);
+ tie_setting(s.iFourPointsLeftX, ui.iSpinFourLeftX);
+ tie_setting(s.iFourPointsLeftY, ui.iSpinFourLeftY);
+ tie_setting(s.iFourPointsLeftZ, ui.iSpinFourLeftZ);
+
+ tie_setting(s.iFourPointsRightX, ui.iSpinFourRightX);
+ tie_setting(s.iFourPointsRightY, ui.iSpinFourRightY);
+ tie_setting(s.iFourPointsRightZ, ui.iSpinFourRightZ);
+
+ tie_setting(s.iFourPointsCenterX, ui.iSpinFourCenterX);
+ tie_setting(s.iFourPointsCenterY, ui.iSpinFourCenterY);
+ tie_setting(s.iFourPointsCenterZ, ui.iSpinFourCenterZ);
tie_setting(s.t_MH_x, ui.tx_spin);
tie_setting(s.t_MH_y, ui.ty_spin);
diff --git a/tracker-easy/tracker-easy-settings.ui b/tracker-easy/tracker-easy-settings.ui
index 2ec56a04..9b9c67a8 100644
--- a/tracker-easy/tracker-easy-settings.ui
+++ b/tracker-easy/tracker-easy-settings.ui
@@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>418</width>
+ <width>422</width>
<height>724</height>
</rect>
</property>
@@ -115,7 +115,7 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="currentIndex">
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="tabTracker">
<attribute name="title">
@@ -871,22 +871,35 @@
</item>
</layout>
</widget>
- <widget class="QWidget" name="tabCustom">
+ <widget class="QWidget" name="tabModelFourPoints">
<property name="enabled">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<attribute name="title">
- <string>Custom</string>
+ <string>Four</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
- <string>Model Dimensions</string>
+ <string>Model vertices</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
- <item row="3" column="1">
- <widget class="QLabel" name="label_57">
+ <item row="0" column="6">
+ <widget class="QSpinBox" name="iSpinFourTopZ">
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="minimum">
+ <number>-65535</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_68">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -894,12 +907,25 @@
</sizepolicy>
</property>
<property name="text">
- <string>z:</string>
+ <string>x:</string>
</property>
</widget>
</item>
- <item row="2" column="5">
- <widget class="QSpinBox" name="m2y_spin">
+ <item row="0" column="3">
+ <widget class="QLabel" name="label_76">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>y:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QSpinBox" name="iSpinFourTopX">
<property name="suffix">
<string> mm</string>
</property>
@@ -911,8 +937,8 @@
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QLabel" name="label_63">
+ <item row="0" column="5">
+ <widget class="QLabel" name="label_65">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -920,12 +946,25 @@
</sizepolicy>
</property>
<property name="text">
- <string>x:</string>
+ <string>z:</string>
</property>
</widget>
</item>
- <item row="1" column="2">
- <widget class="QSpinBox" name="m1x_spin">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_75">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Top&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QSpinBox" name="iSpinFourTopY">
<property name="suffix">
<string> mm</string>
</property>
@@ -937,8 +976,8 @@
</property>
</widget>
</item>
- <item row="2" column="2">
- <widget class="QSpinBox" name="m1y_spin">
+ <item row="2" column="6">
+ <widget class="QSpinBox" name="iSpinFourLeftZ">
<property name="suffix">
<string> mm</string>
</property>
@@ -950,8 +989,8 @@
</property>
</widget>
</item>
- <item row="3" column="5">
- <widget class="QSpinBox" name="m2z_spin">
+ <item row="2" column="2">
+ <widget class="QSpinBox" name="iSpinFourLeftX">
<property name="suffix">
<string> mm</string>
</property>
@@ -963,8 +1002,8 @@
</property>
</widget>
</item>
- <item row="1" column="5">
- <widget class="QSpinBox" name="m2x_spin">
+ <item row="2" column="4">
+ <widget class="QSpinBox" name="iSpinFourLeftY">
<property name="suffix">
<string> mm</string>
</property>
@@ -976,21 +1015,73 @@
</property>
</widget>
</item>
- <item row="0" column="0" colspan="6">
- <widget class="QLabel" name="label_56">
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_74">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Left&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QLabel" name="label_72">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>y:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="5">
+ <widget class="QLabel" name="label_73">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Location of the two remaining model points&lt;br/&gt;with respect to the reference point in default pose&lt;/p&gt;&lt;p&gt;Use any units you want, not necessarily centimeters.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>z:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="label_71">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>x:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_60">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Right&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="2">
- <widget class="QSpinBox" name="m1z_spin">
+ <widget class="QSpinBox" name="iSpinFourRightX">
<property name="suffix">
<string> mm</string>
</property>
@@ -1002,8 +1093,21 @@
</property>
</widget>
</item>
- <item row="2" column="4">
- <widget class="QLabel" name="label_70">
+ <item row="3" column="1">
+ <widget class="QLabel" name="label_63">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>x:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QLabel" name="label_58">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -1015,8 +1119,21 @@
</property>
</widget>
</item>
- <item row="1" column="4">
- <widget class="QLabel" name="label_67">
+ <item row="3" column="4">
+ <widget class="QSpinBox" name="iSpinFourRightY">
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="minimum">
+ <number>-65535</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="5">
+ <widget class="QLabel" name="label_57">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -1024,11 +1141,24 @@
</sizepolicy>
</property>
<property name="text">
- <string>x:</string>
+ <string>z:</string>
</property>
</widget>
</item>
- <item row="1" column="3">
+ <item row="3" column="6">
+ <widget class="QSpinBox" name="iSpinFourRightZ">
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="minimum">
+ <number>-65535</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
<widget class="QLabel" name="label_64">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
@@ -1037,12 +1167,12 @@
</sizepolicy>
</property>
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;3&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Center&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_60">
+ <item row="5" column="1">
+ <widget class="QLabel" name="label_67">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -1050,12 +1180,25 @@
</sizepolicy>
</property>
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot; font-size:16pt; vertical-align:sub;&quot;&gt;2&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>x:</string>
</property>
</widget>
</item>
- <item row="3" column="4">
- <widget class="QLabel" name="label_69">
+ <item row="5" column="2">
+ <widget class="QSpinBox" name="iSpinFourCenterX">
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="minimum">
+ <number>-65535</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="3">
+ <widget class="QLabel" name="label_70">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -1063,12 +1206,25 @@
</sizepolicy>
</property>
<property name="text">
- <string>z:</string>
+ <string>y:</string>
</property>
</widget>
</item>
- <item row="2" column="1">
- <widget class="QLabel" name="label_58">
+ <item row="5" column="4">
+ <widget class="QSpinBox" name="iSpinFourCenterY">
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="minimum">
+ <number>-65535</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="5">
+ <widget class="QLabel" name="label_69">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -1076,7 +1232,20 @@
</sizepolicy>
</property>
<property name="text">
- <string>y:</string>
+ <string>z:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="6">
+ <widget class="QSpinBox" name="iSpinFourCenterZ">
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="minimum">
+ <number>-65535</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
</property>
</widget>
</item>
@@ -1318,12 +1487,6 @@ Don't roll or change position.</string>
<tabstop>cap_length_spin</tabstop>
<tabstop>cap_height_spin</tabstop>
<tabstop>cap_width_spin</tabstop>
- <tabstop>m1x_spin</tabstop>
- <tabstop>m1y_spin</tabstop>
- <tabstop>m1z_spin</tabstop>
- <tabstop>m2x_spin</tabstop>
- <tabstop>m2y_spin</tabstop>
- <tabstop>m2z_spin</tabstop>
<tabstop>tx_spin</tabstop>
<tabstop>ty_spin</tabstop>
<tabstop>tz_spin</tabstop>
diff --git a/tracker-easy/tracker-easy.cpp b/tracker-easy/tracker-easy.cpp
index ebc6e128..971127d4 100644
--- a/tracker-easy/tracker-easy.cpp
+++ b/tracker-easy/tracker-easy.cpp
@@ -77,7 +77,6 @@ namespace EasyTracker
// Compute Euler angles from rotation matrix
void getEulerAngles(cv::Mat &rotCamerMatrix, cv::Vec3d &eulerAngles)
{
-
cv::Mat cameraMatrix, rotMatrix, transVect, rotMatrixX, rotMatrixY, rotMatrixZ;
double* _r = rotCamerMatrix.ptr<double>();
double projMatrix[12] = { _r[0],_r[1],_r[2],0,
@@ -100,11 +99,20 @@ namespace EasyTracker
// Construct the points defining the object we want to detect based on settings.
// We are converting them from millimeters to centimeters.
// TODO: Need to support clip too. That's cap only for now.
- // s.active_model_panel != PointModel::Clip
iModel.clear();
- iModel.push_back(cv::Point3f(iSettings.cap_x / 10.0, iSettings.cap_z / 10.0, -iSettings.cap_y / 10.0)); // Right
- iModel.push_back(cv::Point3f(-iSettings.cap_x / 10.0, iSettings.cap_z / 10.0, -iSettings.cap_y / 10.0)); // Left
- iModel.push_back(cv::Point3f(0, 0, 0)); // Top
+ if (iSettings.active_model_panel == FourPoints)
+ {
+ iModel.push_back(cv::Point3f(iSettings.iFourPointsTopX / 10.0, iSettings.iFourPointsTopY / 10.0, iSettings.iFourPointsTopZ / 10.0)); // Top
+ iModel.push_back(cv::Point3f(iSettings.iFourPointsRightX / 10.0, iSettings.iFourPointsRightY / 10.0, iSettings.iFourPointsRightZ / 10.0)); // Right
+ iModel.push_back(cv::Point3f(iSettings.iFourPointsLeftX / 10.0, iSettings.iFourPointsLeftY / 10.0, iSettings.iFourPointsLeftZ / 10.0)); // Left
+ iModel.push_back(cv::Point3f(iSettings.iFourPointsCenterX / 10.0, iSettings.iFourPointsCenterY / 10.0, iSettings.iFourPointsCenterZ / 10.0)); // Center
+ }
+ else if (iSettings.active_model_panel == Cap)
+ {
+ iModel.push_back(cv::Point3f(0, 0, 0)); // Top
+ iModel.push_back(cv::Point3f(iSettings.cap_x / 10.0, iSettings.cap_z / 10.0, -iSettings.cap_y / 10.0)); // Right
+ iModel.push_back(cv::Point3f(-iSettings.cap_x / 10.0, iSettings.cap_z / 10.0, -iSettings.cap_y / 10.0)); // Left
+ }
}
///
@@ -149,11 +157,14 @@ namespace EasyTracker
}
iPoints.clear();
- iPointExtractor.ExtractPoints(iMatFrame, (doPreview ? &iPreview.iFrameRgb : nullptr), iPoints);
+ iPointExtractor.ExtractPoints(iMatFrame, (doPreview ? &iPreview.iFrameRgb : nullptr), iModel.size(), iPoints);
- const bool success = iPoints.size() >= KPointCount;
+ const bool success = iPoints.size() >= iModel.size();
int topPointIndex = -1;
+ int rightPointIndex = -1;
+ int leftPointIndex = -1;
+ int centerPointIndex = -1;
{
QMutexLocker l(&center_lock);
@@ -167,7 +178,7 @@ namespace EasyTracker
// Tracked points must match the order of the object model points.
// Find top most point, that's the one with min Y as we assume our guy's head is not up side down
int minY = std::numeric_limits<int>::max();
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < iPoints.size(); i++)
{
if (iPoints[i].y < minY)
{
@@ -176,11 +187,11 @@ namespace EasyTracker
}
}
- int rightPointIndex = -1;
+
int maxX = 0;
// Find right most point
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < iPoints.size(); i++)
{
// Excluding top most point
if (i != topPointIndex && iPoints[i].x > maxX)
@@ -191,21 +202,38 @@ namespace EasyTracker
}
// Find left most point
- int leftPointIndex = -1;
- for (int i = 0; i < 3; i++)
+
+ int minX = std::numeric_limits<int>::max();;
+ for (int i = 0; i < iPoints.size(); i++)
{
- // Excluding top most point
- if (i != topPointIndex && i != rightPointIndex)
+ // Excluding top most point and right most point
+ if (i != topPointIndex && i != rightPointIndex && iPoints[i].x < minX)
{
leftPointIndex = i;
- break;
+ minX = iPoints[i].x;
}
}
- //
+ // Find center point, the last one
+ for (int i = 0; i < iPoints.size(); i++)
+ {
+ // Excluding the three points we already have
+ if (i != topPointIndex && i != rightPointIndex && i != leftPointIndex)
+ {
+ centerPointIndex = i;
+ }
+ }
+
+ // Order matters
+ iTrackedPoints.push_back(iPoints[topPointIndex]);
iTrackedPoints.push_back(iPoints[rightPointIndex]);
iTrackedPoints.push_back(iPoints[leftPointIndex]);
- iTrackedPoints.push_back(iPoints[topPointIndex]);
+ if (iModel.size() > iTrackedPoints.size())
+ {
+ // We are tracking more than 3 points
+ iTrackedPoints.push_back(iPoints[centerPointIndex]);
+ }
+
bool movedEnough = true;
// Check if we moved enough since last time we were here
@@ -243,7 +271,32 @@ namespace EasyTracker
iAngles.clear();
iBestSolutionIndex = -1;
// Solve P3P problem with OpenCV
- int solutionCount = cv::solveP3P(iModel, iTrackedPoints, iCameraMatrix, iDistCoeffsMatrix, iRotations, iTranslations, iSolver);
+ int solutionCount = 0;
+ if (iModel.size() == 3)
+ {
+ solutionCount = cv::solveP3P(iModel, iTrackedPoints, iCameraMatrix, iDistCoeffsMatrix, iRotations, iTranslations, iSolver);
+ }
+ else
+ {
+ //Guess extrinsic boolean is only for ITERATIVE method, it will be set to false for all other method
+ cv::Mat rotation, translation;
+ // Init only needed for iterative, it's also useless as it is
+ rotation = cv::Mat::zeros(3, 1, CV_64FC1);
+ translation = cv::Mat::zeros(3, 1, CV_64FC1);
+ rotation.setTo(cv::Scalar(0));
+ translation.setTo(cv::Scalar(0));
+ /////
+ iRotations.clear();
+ iTranslations.clear();
+ bool solved = cv::solvePnP(iModel, iTrackedPoints, iCameraMatrix, iDistCoeffsMatrix, rotation, translation, true, iSolver );
+ if (solved)
+ {
+ solutionCount = 1;
+ iRotations.push_back(rotation);
+ iTranslations.push_back(translation);
+ }
+ }
+
if (solutionCount > 0)
{
@@ -306,13 +359,34 @@ namespace EasyTracker
ss << "FPS: " << iFps << "/" << iSkippedFps;
iPreview.DrawInfo(ss.str());
- //
+ //Color is BGR
if (topPointIndex != -1)
{
// Render a cross to indicate which point is the head
- iPreview.DrawCross(iPoints[topPointIndex]);
+ static const cv::Scalar color(0, 255, 255); // Yellow
+ iPreview.DrawCross(iPoints[topPointIndex],color);
+ }
+
+ if (rightPointIndex != -1)
+ {
+ static const cv::Scalar color(255, 0, 255); // Pink
+ iPreview.DrawCross(iPoints[rightPointIndex], color);
}
+ if (leftPointIndex != -1)
+ {
+ static const cv::Scalar color(255, 0, 0); // Blue
+ iPreview.DrawCross(iPoints[leftPointIndex], color);
+ }
+
+ if (centerPointIndex != -1)
+ {
+ static const cv::Scalar color(0, 255, 0); // Green
+ iPreview.DrawCross(iPoints[centerPointIndex], color);
+ }
+
+
+
// Render our deadzone rects
for (const cv::Rect& rect : iTrackedRects)
{
@@ -462,7 +536,7 @@ namespace EasyTracker
module_status Tracker::start_tracker(QFrame* video_frame)
{
// Check that we support that solver
- if (iSolver!=cv::SOLVEPNP_P3P && iSolver != cv::SOLVEPNP_AP3P)
+ if (iSolver!=cv::SOLVEPNP_P3P && iSolver != cv::SOLVEPNP_AP3P && iModel.size()==3)
{
return module_status("Error: Solver not supported use either P3P or AP3P.");
}
diff --git a/tracker-easy/tracker-easy.h b/tracker-easy/tracker-easy.h
index 41226d23..37337087 100644
--- a/tracker-easy/tracker-easy.h
+++ b/tracker-easy/tracker-easy.h
@@ -33,6 +33,14 @@
namespace EasyTracker
{
+ // Order matters, it must match the order of the UI tabs
+ enum ModelType
+ {
+ Clip,
+ Cap,
+ FourPoints
+ };
+
static const QString KModuleName = "tracker-easy";
class Dialog;