Skip to content

Commit ba47a4e

Browse files
committed
introduce vvs parameters
1 parent bc3dc4d commit ba47a4e

File tree

7 files changed

+87
-10
lines changed

7 files changed

+87
-10
lines changed

doc/tutorial/tracking/tutorial-tracking-mb-generic-json.dox

+24
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Let us first examine the global settings (located at the root of the JSON struct
4747
\endcode
4848

4949
If they are defined globally, they will take precedence over the values defined per tracker.
50+
Some settings such as the "vvs" options, are only defined globally
5051

5152
<table>
5253
<tr><th colspan="2">Key</th><th>Type</th><th>Description</th><th>Optional</th></tr>
@@ -98,6 +99,29 @@ If they are defined globally, they will take precedence over the values defined
9899
<td>Whether to use ogre for visibility testing. OGRE must be installed, otherwise ignored. See vpMbGenericTracker::setOgreVisibilityTest()</td>
99100
<td>Yes</td>
100101
</tr>
102+
<tr><th colspan="5">vvs (optional)</th></tr>
103+
<tr>
104+
<td>lambda</td>
105+
<td>float</td>
106+
<td>Virtual visual servoing gain
107+
</td>
108+
<td>vpMbGenericTracker::setLambda()</td>
109+
<td>Yes</td>
110+
</tr>
111+
<tr>
112+
<td>maxIter</td>
113+
<td>integer > 0</td>
114+
<td>Number of iterations for virtual visual servoing</td>
115+
<td>vpMbGenericTracker::setMaxIter()</td>
116+
<td>Yes</td>
117+
</tr>
118+
<tr>
119+
<td>initialMu</td>
120+
<td>float</td>
121+
<td>Initial Mu for levenberg marquardt optimization</td>
122+
<td>vpMbGenericTracker::setInitialMu(</td>
123+
<td>Yes</td>
124+
</tr>
101125
</table>
102126

103127
\subsection json-per-tracker-settings Individual camera tracker settings

modules/tracker/mbt/src/vpMbGenericTracker.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -3019,6 +3019,15 @@ void vpMbGenericTracker::loadConfigFileJSON(const std::string &settingsFile, boo
30193019
setOgreVisibilityTest(visJson.value("ogre", useOgre));
30203020
setScanLineVisibilityTest(visJson.value("scanline", useScanLine));
30213021
}
3022+
3023+
// VVS global settings
3024+
if (settings.contains("vvs")) {
3025+
const json vvsJson = settings["vvs"];
3026+
setLambda(vvsJson.value("lambda", this->m_lambda));
3027+
setMaxIter(vvsJson.value("maxIter", this->m_maxIter));
3028+
setInitialMu(vvsJson.value("initialMu", this->m_initialMu));
3029+
}
3030+
30223031
//If a 3D model is defined, load it
30233032
if (settings.contains("model")) {
30243033
loadModel(settings.at("model").get<std::string>(), verbose);
@@ -3047,6 +3056,12 @@ void vpMbGenericTracker::saveConfigFile(const std::string &settingsFile) const
30473056
}
30483057
}
30493058
j["trackers"] = trackers;
3059+
j["vvs"] = json {
3060+
{"lambda", m_lambda},
3061+
{"maxIter", m_maxIter},
3062+
{"initialMu", m_initialMu}
3063+
};
3064+
30503065
std::ofstream f(settingsFile);
30513066
if (f.good()) {
30523067
const unsigned indentLevel = 4;

modules/tracker/mbt/test/generic-with-dataset/testMbtJsonSettings.cpp

+26-10
Original file line numberDiff line numberDiff line change
@@ -245,37 +245,53 @@ SCENARIO("MBT JSON Serialization", "[json]")
245245
);
246246
}
247247

248+
THEN("VVS properties should be the same")
249+
{
250+
vpMbGenericTracker t2 = baseTrackerConstructor();
251+
t2.setMaxIter(4096);
252+
t2.setLambda(5.0);
253+
t2.setInitialMu(5.0);
254+
255+
t2.loadConfigFile(jsonPath);
256+
257+
checkProperties(t1, t2,
258+
&vpMbGenericTracker::getMaxIter, "VVS m iterations be the same",
259+
&vpMbGenericTracker::getLambda, "VVS lambda should be the same",
260+
&vpMbGenericTracker::getInitialMu, "VVS initial mu be the same"
261+
);
262+
}
263+
248264
WHEN("Modifying JSON file/Using a custom JSON file")
249265
{
250266
THEN("Removing version from file generates an error on load")
251267
{
252268
modifyJson([](json &j) -> void {
253269
j.erase("version");
254-
});
270+
});
255271
REQUIRE_THROWS(t1.loadConfigFile(jsonPath));
256272
}
257273

258274
THEN("Using an unsupported version generates an error on load")
259275
{
260276
modifyJson([](json &j) -> void {
261277
j["version"] = "0.0.0";
262-
});
278+
});
263279
REQUIRE_THROWS(t1.loadConfigFile(jsonPath));
264280
}
265281

266282
THEN("Using an undefined reference camera generates an error")
267283
{
268284
modifyJson([](json &j) -> void {
269285
j["referenceCameraName"] = "C3";
270-
});
286+
});
271287
REQUIRE_THROWS(t1.loadConfigFile(jsonPath));
272288
}
273289

274290
THEN("Not defining a transformation matrix for the reference camera is valid")
275291
{
276292
modifyJson([&t1](json &j) -> void {
277293
j["trackers"][t1.getReferenceCameraName()].erase("camTref");
278-
});
294+
});
279295
REQUIRE_NOTHROW(t1.loadConfigFile(jsonPath));
280296
}
281297

@@ -284,7 +300,7 @@ SCENARIO("MBT JSON Serialization", "[json]")
284300
modifyJson([&t1](json &j) -> void {
285301
std::string otherCamName = t1.getReferenceCameraName() == "C1" ? "C2" : "C1";
286302
j["trackers"][otherCamName].erase("camTref");
287-
});
303+
});
288304
REQUIRE_THROWS(t1.loadConfigFile(jsonPath));
289305
}
290306

@@ -301,7 +317,7 @@ SCENARIO("MBT JSON Serialization", "[json]")
301317
for (const auto &c : t1.getCameraNames()) {
302318
j["trackers"][c].erase("clipping");
303319
}
304-
});
320+
});
305321
REQUIRE_NOTHROW(t2.loadConfigFile(jsonPath, false));
306322
REQUIRE(t2.getClipping() == clipping);
307323
REQUIRE(t2.getNearClippingDistance() == clipping_near);
@@ -323,7 +339,7 @@ SCENARIO("MBT JSON Serialization", "[json]")
323339
for (const auto &c : t1.getCameraNames()) {
324340
j["trackers"][c]["clipping"].erase("near");
325341
}
326-
});
342+
});
327343
t2.loadConfigFile(jsonPath);
328344
REQUIRE(t2.getNearClippingDistance() == clipping_near);
329345
REQUIRE(t2.getFarClippingDistance() == t1.getFarClippingDistance());
@@ -335,7 +351,7 @@ SCENARIO("MBT JSON Serialization", "[json]")
335351
for (const auto &c : t1.getCameraNames()) {
336352
j["trackers"][c]["clipping"].erase("far");
337353
}
338-
});
354+
});
339355
t2.loadConfigFile(jsonPath);
340356
REQUIRE(t2.getNearClippingDistance() == t1.getNearClippingDistance());
341357
REQUIRE(t2.getFarClippingDistance() == clipping_far);
@@ -347,7 +363,7 @@ SCENARIO("MBT JSON Serialization", "[json]")
347363
for (const auto &c : t1.getCameraNames()) {
348364
j["trackers"][c]["clipping"].erase("flags");
349365
}
350-
});
366+
});
351367
t2.loadConfigFile(jsonPath);
352368
REQUIRE(t2.getNearClippingDistance() == t1.getNearClippingDistance());
353369
REQUIRE(t2.getFarClippingDistance() == t1.getFarClippingDistance());
@@ -358,7 +374,7 @@ SCENARIO("MBT JSON Serialization", "[json]")
358374
}
359375
}
360376
}
361-
int main(int argc, char *argv [])
377+
int main(int argc, char *argv[])
362378
{
363379
Catch::Session session; // There must be exactly one instance
364380
session.applyCommandLine(argc, argv);

tutorial/tracking/model-based/generic-rgbd/model/cube/realsense-color-and-depth-with-model-path.json

+5
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,10 @@
164164
}
165165
}
166166
},
167+
"vvs" :{
168+
"lambda": 1.0,
169+
"maxIter": 30,
170+
"initialMu": 0.01
171+
},
167172
"version": "1.0"
168173
}

tutorial/tracking/model-based/generic-rgbd/model/cube/realsense-color-and-depth.json

+5
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,10 @@
163163
}
164164
}
165165
},
166+
"vvs" :{
167+
"lambda": 1.0,
168+
"maxIter": 30,
169+
"initialMu": 0.01
170+
},
166171
"version": "1.0"
167172
}

tutorial/tracking/model-based/generic-rgbd/model/cube/realsense-color-and-depth.json.example

+7
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,12 @@
179179
}
180180
}
181181
},
182+
//! [VVS]
183+
"vvs" :{
184+
"lambda": 1.0,
185+
"maxIter": 30,
186+
"initialMu": 0.01
187+
},
188+
//! [VVS]
182189
"version": "1.0"
183190
}

tutorial/tracking/model-based/generic-rgbd/model/cube/realsense-color-only.json

+5
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,10 @@
8787
}
8888
}
8989
},
90+
"vvs" :{
91+
"lambda": 1.0,
92+
"maxIter": 30,
93+
"initialMu": 0.01
94+
},
9095
"version": "1.0"
9196
}

0 commit comments

Comments
 (0)