33 #include <visp3/ustk_core/usGeometryDisplayTools.h>
35 #include <visp3/core/vpColVector.h>
36 #include <visp3/core/vpDisplay.h>
37 #include <visp3/core/vpMatrix.h>
38 #include <visp3/core/vpRGBa.h>
43 template <
class ImageDataType>
44 void displayFrame(
const vpImage<ImageDataType> &I,
const vpHomogeneousMatrix &imageMframe,
double Xscale,
double Yscale)
46 double origin_x = Xscale * imageMframe[0][3];
47 double origin_y = Yscale * imageMframe[1][3];
54 for (
int j = 0; j < 3; j++) {
55 double z = imageMframe[2][j];
66 order[0] = zmax_index;
67 order[1] = 3 - zmin_index - zmax_index;
68 order[2] = zmin_index;
71 vpColor color[3] = { vpColor::red, vpColor::green, vpColor::blue };
72 for (
unsigned int i = 0; i < 3; i++) {
73 unsigned int j = (
unsigned int)order[i];
74 vpDisplay::displayArrow(I, (
int)origin_y, (
int)origin_x, (
int)(origin_y + 20 * imageMframe[1][j]), (
int)(origin_x + 20 * imageMframe[0][j]),
80 template VISP_EXPORT
void displayFrame<vpRGBa>(
const vpImage<vpRGBa> &,
const vpHomogeneousMatrix &,
double,
double);
84 template <
class ImageDataType>
86 double Xscale,
double Yscale,
const vpColor &color)
88 vpMatrix R(imageMworld.getRotationMatrix());
89 vpColVector T(imageMworld.getTranslationVector());
91 vpColVector imagePoint(R * plane.
getPosition() + T);
94 double x = Xscale * imagePoint[0];
95 double y = Yscale * imagePoint[1];
97 double dx = 0.1 * Xscale * imageDirection[0];
98 double dy = 0.1 * Yscale * imageDirection[1];
100 vpDisplay::displayCross(I, (
int)y, (
int)x, 7, color);
101 vpDisplay::displayLine(I, (
int)(y - dx), (
int)(x + dy), (
int)(y + dx), (
int)(x - dy), color);
104 const vpHomogeneousMatrix &,
double,
double,
const vpColor &);
106 double,
double,
const vpColor &);
110 template <
class ImageDataType>
112 const vpColor &color,
int nbRenderingLines)
116 std::vector<double> params(nbRenderingLines + 1);
118 for (
int i = 1; i < nbRenderingLines + 1; i++) {
119 params.at(i) = params.at(i - 1) + step;
122 vpMatrix imagePoints = curve.
getPoints(vpColVector(params));
124 double x0 = Xscale * imagePoints[0][0];
125 double y0 = Yscale * imagePoints[1][0];
129 for (
int i = 0; i < nbRenderingLines; i++) {
133 x1 = Xscale * imagePoints[0][i + 1];
134 y1 = Yscale * imagePoints[1][i + 1];
136 vpDisplay::displayLine(I, (
int)y0, (
int)x0, (
int)y1, (
int)x1, color);
140 double,
const vpColor &,
int);
142 const vpColor &,
int);
146 template <
class ImageDataType>
148 double Xscale,
double Yscale,
const vpColor &color,
int nbRenderingLines,
double visibilityDistance)
150 unsigned int nbPoints = nbRenderingLines + 1;
153 std::vector<double> params(nbPoints);
155 for (
unsigned int i = 1; i < nbPoints; i++)
156 params.at(i) = params.at(i - 1) + step;
158 vpMatrix points = curve.
getPoints(vpColVector(params));
160 const vpMatrix R(imageMworld.getRotationMatrix());
161 const vpMatrix T(imageMworld.getTranslationVector());
162 const vpMatrix ones(1, nbPoints, 1);
163 vpMatrix imagePoints(R * points + vpMatrix::kron(T, ones));
165 double x0 = Xscale * imagePoints[0][0];
166 double y0 = Yscale * imagePoints[1][0];
167 double z0 = imagePoints[2][0];
172 for (
int i = 0; i < nbRenderingLines; i++) {
177 x1 = Xscale * imagePoints[0][i + 1];
178 y1 = Yscale * imagePoints[1][i + 1];
179 z1 = imagePoints[2][i + 1];
181 if ((vpMath::sign(z0) != vpMath::sign(z1)) || ((fabs(z0) < visibilityDistance) && (fabs(z1) < visibilityDistance)))
182 vpDisplay::displayLine(I, (
int)y0, (
int)x0, (
int)y1, (
int)x1, color);
187 const vpHomogeneousMatrix &,
double,
double,
const vpColor &,
int,
190 const vpHomogeneousMatrix &,
double,
double,
const vpColor &,
int,
double);
192 template <
class ImageDataType>
194 const vpHomogeneousMatrix &imageMworld,
double Xscale,
double Yscale,
195 const vpColor &color)
210 vpColVector Dxy(3, 0);
212 vpColVector Axy = vpColVector::cross(D, Dxy);
213 vpColVector Bxy = vpColVector::cross(D, Axy).normalize();
215 double thetaxy = atan2(Axy[1], Axy[0]);
217 double bxy = r * vpColVector::cross(Bxy, Dxy).frobeniusNorm();
218 if (Bxy.frobeniusNorm() < 0.5)
222 vpImagePoint centerXY(Yscale * C[1], Xscale * C[0]);
223 double A = sqrt(pow(Xscale * cos(thetaxy), 2) + pow(Yscale * sin(thetaxy), 2));
226 thetaxy = atan2(axy * sin(thetaxy), bxy * cos(thetaxy));
227 vpDisplay::displayEllipse(I, centerXY, axy, bxy, thetaxy,
false, color);
230 const vpImage<unsigned char> &,
231 const vpHomogeneousMatrix &,
double,
double,
234 const vpHomogeneousMatrix &,
double,
double,
239 template <
class ImageDataType>
241 double Xscale,
double Yscale,
const vpColor &color,
int nbRenderingLinesPerSegment,
242 double visibilityDistance)
246 nbRenderingLinesPerSegment, visibilityDistance);
249 const vpHomogeneousMatrix &,
double,
double,
const vpColor &,
int,
252 double,
double,
const vpColor &,
int,
double);
254 template <
class ImageDataType>
256 const vpHomogeneousMatrix &imageMworld,
double Xscale,
double Yscale,
const vpColor &color,
257 double visibilityDistance)
263 vpMatrix points(3, nbPoints);
269 const vpMatrix R(imageMworld.getRotationMatrix());
270 const vpMatrix T(imageMworld.getTranslationVector());
271 const vpMatrix ones(1, nbPoints, 1);
272 vpMatrix imagePoints(R * points + vpMatrix::kron(T, ones));
274 for (
unsigned int i = 0; i < nbPoints; i++) {
275 double x = Xscale * imagePoints[0][i];
276 double y = Yscale * imagePoints[1][i];
277 double z = imagePoints[2][i];
278 if (fabs(z) < visibilityDistance)
279 vpDisplay::displayCross(I, (
int)y, (
int)x, 7, color);
283 const vpHomogeneousMatrix &,
double,
double,
284 const vpColor &,
double);
286 const vpHomogeneousMatrix &,
double,
double,
const vpColor &,
289 template <
class ImageDataType>
290 void display(
const usBSpline3D &spline,
const vpImage<ImageDataType> &I,
const vpHomogeneousMatrix &imageMworld,
291 double Xscale,
double Yscale,
const vpColor &color,
int nbRenderingLines,
double visibilityDistance)
293 displayLine(spline, I, imageMworld, Xscale, Yscale, color, nbRenderingLines, visibilityDistance);
294 displayExtremities(spline, I, imageMworld, Xscale, Yscale, color, visibilityDistance);
297 const vpHomogeneousMatrix &,
double,
double,
const vpColor &,
int,
300 double,
double,
const vpColor &,
int,
double);
302 template <
class ImageDataType>
304 const vpHomogeneousMatrix &imageMworld,
double Xscale,
double Yscale,
305 const vpColor &color)
320 vpColVector Dxy(3, 0);
322 vpColVector Axy = vpColVector::cross(D, Dxy);
323 vpColVector Bxy = vpColVector::cross(D, Axy).normalize();
325 double thetaxy = atan2(Axy[1], Axy[0]);
327 double bxy = r * vpColVector::cross(Bxy, Dxy).frobeniusNorm();
328 if (Bxy.frobeniusNorm() < 0.5)
332 vpImagePoint centerXY(Yscale * C[1], Xscale * C[0]);
333 double A = sqrt(pow(Xscale * cos(thetaxy), 2) + pow(Yscale * sin(thetaxy), 2));
336 thetaxy = atan2(axy * sin(thetaxy), bxy * cos(thetaxy));
337 vpDisplay::displayEllipse(I, centerXY, axy, bxy, thetaxy,
false, color);
340 const vpHomogeneousMatrix &,
double,
double,
343 const vpHomogeneousMatrix &,
double,
double,
const usPolynomialCurve3D & accessSegment(int i) const
int getNbSegments() const
Parameters setters and getters.
const usPolynomialCurve3D & accessLastSegment() const
double getCurvatureFromShape(double start, double end, vpColVector ¢er3D, vpColVector &direction3D) const
Curvature.
vpColVector getDirection() const
vpColVector getPosition() const
double getEndParameter() const
double getStartParameter() const
vpMatrix getPoints(vpColVector parameters) const
double getStartParameter() const
vpMatrix getPoints(const vpColVector ¶meters) const
vpColVector getEndPoint() const
double getCurvatureFromShape(double start, double end, vpColVector ¢er3D, vpColVector &direction3D) const
double getEndParameter() const
vpColVector getStartPoint() const