Skip to content

Commit 67df2a7

Browse files
committed
Fix interaction matrix for depth, Interaction matrix for 3D point error
1 parent fd13c6e commit 67df2a7

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

modules/tracker/rbt/include/visp3/rbt/vpPointMap.h

+37
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,43 @@ class VISP_EXPORT vpPointMap
8080
}
8181
}
8282

83+
void compute3DErrorAndJacobian(const vpArray2D<int> &indices, const vpHomogeneousMatrix &cTw, const vpMatrix &observations, vpMatrix &J, vpColVector &e) const
84+
{
85+
J.resize(indices.getRows() * 3, 6, true, false);
86+
e.resize(indices.getRows() * 3, 1, false);
87+
88+
vpColVector cX(3);
89+
vpColVector wX(3);
90+
const vpRotationMatrix cRw = cTw.getRotationMatrix();
91+
const vpTranslationVector t = cTw.getTranslationVector();
92+
for (unsigned int i = 0; i < indices.getRows(); ++i) {
93+
const unsigned int pointIndex = indices[i][0];
94+
const double *p = m_X[pointIndex];
95+
wX[0] = p[0]; wX[1] = p[1]; wX[2] = p[2];
96+
cX = cRw * wX;
97+
cX += t;
98+
99+
const double X = cX[0], Y = cX[1], Z = cX[2];
100+
101+
e[i * 3] = X - observations[i][0];
102+
e[i * 3 + 1] = Y - observations[i][1];
103+
e[i * 3 + 2] = Z - observations[i][2];
104+
105+
J[i * 3][0] = -1;
106+
J[i * 3 + 1][1] = -1;
107+
J[i * 3 + 2][2] = -1;
108+
109+
J[i * 3][4] = -Z;
110+
J[i * 3][5] = Y;
111+
112+
J[i * 3 + 1][3] = Z;
113+
J[i * 3 + 1][5] = -X;
114+
115+
J[i * 3 + 2][3] = -Y;
116+
J[i * 3 + 2][4] = X;
117+
}
118+
}
119+
83120
private:
84121
vpMatrix m_X; // N x 3, points expressed in world frame
85122
unsigned m_maxPoints;

modules/tracker/rbt/include/visp3/rbt/vpRBDenseDepthTracker.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class VISP_EXPORT vpRBDenseDepthTracker : public vpRBFeatureTracker
154154

155155
inline void interaction(vpMatrix &L, unsigned i)
156156
{
157-
const double X = currentPoint[0], Y = currentPoint[1], Z = currentPoint[2];
157+
const double X = oP.get_X(), Y = oP.get_Y(), Z = oP.get_Z();
158158
const double nx = cameraNormal[0], ny = cameraNormal[1], nz = cameraNormal[2];
159159
L[i][0] = nx;
160160
L[i][1] = ny;

modules/tracker/rbt/src/features/vpRBDenseDepthTracker.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ void vpRBDenseDepthTracker::extractFeatures(const vpRBFeatureTrackerInput &frame
6060
const vpHomogeneousMatrix &cMo = frame.renders.cMo;
6161
vpHomogeneousMatrix oMc = cMo.inverse();
6262
vpRotationMatrix cRo = cMo.getRotationMatrix();
63+
vpTranslationVector co = oMc.getTranslationVector();
6364
bool useMask = m_useMask && frame.hasMask();
6465
m_depthPoints.clear();
6566
m_depthPoints.reserve(static_cast<size_t>(bb.getArea() / (m_step * m_step * 2)));
6667
vpDepthPoint point;
6768
for (unsigned int i = static_cast<unsigned int>(bb.getTop()); i < static_cast<unsigned int>(bb.getBottom()); i += m_step) {
6869
for (unsigned int j = static_cast<unsigned int>(bb.getLeft()); j < static_cast<unsigned int>(bb.getRight()); j += m_step) {
69-
// if (renderDepth[i][j] > frame.renders.zNear && renderDepth[i][j] < frame.renders.zFar && depthMap[i][j] > frame.renders.zNear * 0.33 && depthMap[i][j] < frame.renders.zFar * 3.0) {
7070
double Z = renderDepth[i][j];
7171
double currZ = depthMap[i][j];
7272
if (Z > 0.f && currZ > 0.f) {
@@ -80,14 +80,16 @@ void vpRBDenseDepthTracker::extractFeatures(const vpRBFeatureTrackerInput &frame
8080
point.objectNormal[1] = frame.renders.normals[i][j].G;
8181
point.objectNormal[2] = frame.renders.normals[i][j].B;
8282

83-
//fastRotationMatmul(cRo, frame.renders.normals[i][j], point.objectNormal);
84-
//vpColVector cameraNormal = cRo * objectNormal;
85-
// if (acos(cameraNormal * vpColVector({ 0.0, 0.0, -1.0 })) > vpMath::rad(70.0)) {
86-
// continue;
87-
// }
83+
fastProjection(oMc, x * Z, y * Z, Z, point.oP);
84+
85+
vpColVector cameraRay({ co[0] - point.oP.get_oX(), co[1] - point.oP.get_oY(), co[2] - point.oP.get_oZ() });
86+
cameraRay.normalize();
87+
88+
if (acos(cameraRay * point.objectNormal) > vpMath::rad(85.0)) {
89+
continue;
90+
}
8891
// vpColVector cp({ x * Z, y * Z, Z, 1 });
8992
// vpColVector oP = oMc * cp;
90-
fastProjection(oMc, x * Z, y * Z, Z, point.oP);
9193
// point.oP = vpPoint(oP);
9294
point.pixelPos.set_ij(i, j);
9395
point.currentPoint[0] = x * currZ;
@@ -136,7 +138,7 @@ void vpRBDenseDepthTracker::computeVVSIter(const vpRBFeatureTrackerInput &/*fram
136138
}
137139

138140
//m_weights = 0.0;
139-
//m_robust.setMinMedianAbsoluteDeviation(1e-3);
141+
m_robust.setMinMedianAbsoluteDeviation(1e-3);
140142
m_robust.MEstimator(vpRobust::TUKEY, m_error, m_weights);
141143
for (unsigned int i = 0; i < m_depthPoints.size(); ++i) {
142144
m_weighted_error[i] = m_error[i] * m_weights[i];

0 commit comments

Comments
 (0)