Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpWireFrameSimulator.cpp
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * Wire frame simulator
32 */
33
38
39#include <fcntl.h>
40#include <stdio.h>
41#include <string.h>
42#include <vector>
43#include <visp3/robot/vpWireFrameSimulator.h>
44
45#include "vpArit.h"
46#include "vpBound.h"
47#include "vpClipping.h"
48#include "vpCoreDisplay.h"
49#include "vpKeyword.h"
50#include "vpLex.h"
51#include "vpMy.h"
52#include "vpParser.h"
53#include "vpProjection.h"
54#include "vpRfstack.h"
55#include "vpScene.h"
56#include "vpTmstack.h"
57#include "vpToken.h"
58#include "vpView.h"
59#include "vpVwstack.h"
60
61#include <visp3/core/vpDebug.h>
62#include <visp3/core/vpCameraParameters.h>
63#include <visp3/core/vpException.h>
64#include <visp3/core/vpIoTools.h>
65#include <visp3/core/vpMeterPixelConversion.h>
66#include <visp3/core/vpPoint.h>
67
69extern Point2i *point2i;
70extern Point2i *listpoint2i;
71
72/*
73 Copy the scene corresponding to the registeresd parameters in the image.
74*/
75void vpWireFrameSimulator::display_scene(Matrix mat, Bound_scene &sc, const vpImage<vpRGBa> &I, const vpColor &color)
76{
77 // extern Bound *clipping_Bound ();
78 Bound *bp, *bend;
79 Bound *clip; /* surface apres clipping */
80 Byte b = (Byte)*get_rfstack();
81 Matrix m;
82
83 // bcopy ((char *) mat, (char *) m, sizeof (Matrix));
84 memmove((char *)m, (char *)mat, sizeof(Matrix));
85 View_to_Matrix(get_vwstack(), *(get_tmstack()));
86 postmult_matrix(m, *(get_tmstack()));
87 bp = sc.bound.ptr;
88 bend = bp + sc.bound.nbr;
89 for (; bp < bend; bp++) {
90 if ((clip = clipping_Bound(bp, m)) != NULL) {
91 Face *fp = clip->face.ptr;
92 Face *fend = fp + clip->face.nbr;
93
94 set_Bound_face_display(clip, b); // regarde si is_visible
95
96 point_3D_2D(clip->point.ptr, clip->point.nbr, static_cast<int>(I.getWidth()), static_cast<int>(I.getHeight()), point2i);
97 for (; fp < fend; fp++) {
98 if (fp->is_visible) {
99 wireframe_Face(fp, point2i);
100 Point2i *pt = listpoint2i;
101 for (int i = 1; i < fp->vertex.nbr; i++) {
102 vpDisplay::displayLine(I, vpImagePoint((pt)->y, (pt)->x), vpImagePoint((pt + 1)->y, (pt + 1)->x), color,
103 thickness_);
104 pt++;
105 }
106 if (fp->vertex.nbr > 2) {
107 vpDisplay::displayLine(I, vpImagePoint((listpoint2i)->y, (listpoint2i)->x), vpImagePoint((pt)->y, (pt)->x),
108 color, thickness_);
109 }
110 }
111 }
112 }
113 }
114}
115
116/*
117 Copy the scene corresponding to the registeresd parameters in the image.
118*/
119void vpWireFrameSimulator::display_scene(Matrix mat, Bound_scene &sc, const vpImage<unsigned char> &I,
120 const vpColor &color)
121{
122 // extern Bound *clipping_Bound ();
123
124 Bound *bp, *bend;
125 Bound *clip; /* surface apres clipping */
126 Byte b = (Byte)*get_rfstack();
127 Matrix m;
128
129 // bcopy ((char *) mat, (char *) m, sizeof (Matrix));
130 memmove((char *)m, (char *)mat, sizeof(Matrix));
131 View_to_Matrix(get_vwstack(), *(get_tmstack()));
132 postmult_matrix(m, *(get_tmstack()));
133 bp = sc.bound.ptr;
134 bend = bp + sc.bound.nbr;
135 for (; bp < bend; bp++) {
136 if ((clip = clipping_Bound(bp, m)) != NULL) {
137 Face *fp = clip->face.ptr;
138 Face *fend = fp + clip->face.nbr;
139
140 set_Bound_face_display(clip, b); // regarde si is_visible
141
142 point_3D_2D(clip->point.ptr, clip->point.nbr, static_cast<int>(I.getWidth()), static_cast<int>(I.getHeight()), point2i);
143 for (; fp < fend; fp++) {
144 if (fp->is_visible) {
145 wireframe_Face(fp, point2i);
146 Point2i *pt = listpoint2i;
147 for (int i = 1; i < fp->vertex.nbr; i++) {
148 vpDisplay::displayLine(I, vpImagePoint((pt)->y, (pt)->x), vpImagePoint((pt + 1)->y, (pt + 1)->x), color,
149 thickness_);
150 pt++;
151 }
152 if (fp->vertex.nbr > 2) {
153 vpDisplay::displayLine(I, vpImagePoint((listpoint2i)->y, (listpoint2i)->x), vpImagePoint((pt)->y, (pt)->x),
154 color, thickness_);
155 }
156 }
157 }
158 }
159 }
160}
161
171 : scene(), desiredScene(), camera(), objectImage(), fMo(), fMc(), camMf(), refMo(), cMo(), cdMo(), object(PLATE),
174 fMoList(), nbrPtLimit(1000), old_iPr(), old_iPz(), old_iPt(), blockedr(false), blockedz(false), blockedt(false),
175 blocked(false), camMf2(), f2Mf(), px_int(1), py_int(1), px_ext(1), py_ext(1), displayObject(false),
177 camTrajType(CT_LINE), extCamChanged(false), rotz(), thickness_(1), scene_dir()
178{
179 // set scene_dir from #define VISP_SCENE_DIR if it exists
180 // VISP_SCENES_DIR may contain multiple locations separated by ";"
181 std::vector<std::string> scene_dirs = vpIoTools::splitChain(std::string(VISP_SCENES_DIR), std::string(";"));
182 bool sceneDirExists = false;
183 for (size_t i = 0; i < scene_dirs.size(); i++)
184 if (vpIoTools::checkDirectory(scene_dirs[i]) == true) { // directory exists
185 scene_dir = scene_dirs[i];
186 sceneDirExists = true;
187 break;
188 }
189 if (!sceneDirExists) {
190 try {
191 scene_dir = vpIoTools::getenv("VISP_SCENES_DIR");
192 std::cout << "The simulator uses data from VISP_SCENES_DIR=" << scene_dir << std::endl;
193 }
194 catch (...) {
195 std::cout << "Cannot get VISP_SCENES_DIR environment variable" << std::endl;
196 }
197 }
198
199 open_display();
200 open_clipping();
201
202 old_iPr = vpImagePoint(-1, -1);
203 old_iPz = vpImagePoint(-1, -1);
204 old_iPt = vpImagePoint(-1, -1);
205
206 rotz.buildFrom(0, 0, 0, 0, 0, vpMath::rad(180));
207
208 scene.name = NULL;
209 scene.bound.ptr = NULL;
210 scene.bound.nbr = 0;
211
212 desiredScene.name = NULL;
213 desiredScene.bound.ptr = NULL;
214 desiredScene.bound.nbr = 0;
215
216 camera.name = NULL;
217 camera.bound.ptr = NULL;
218 camera.bound.nbr = 0;
219}
220
225{
226 if (sceneInitialized) {
227 if (displayObject)
228 free_Bound_scene(&(this->scene));
229 if (displayCamera) {
230 free_Bound_scene(&(this->camera));
231 }
233 free_Bound_scene(&(this->desiredScene));
234 }
235 close_clipping();
236 close_display();
237
238 cameraTrajectory.clear();
239 poseList.clear();
240 fMoList.clear();
241}
242
258{
259 char name_cam[FILENAME_MAX];
260 char name[FILENAME_MAX];
261
262 object = obj;
263 this->desiredObject = desired_object;
264
265 const char *scene_dir_ = scene_dir.c_str();
266 if (strlen(scene_dir_) >= FILENAME_MAX) {
267 throw(vpException(vpException::memoryAllocationError, "Not enough memory to initialize the camera name"));
268 }
269
270 strcpy(name_cam, scene_dir_);
271 if (desiredObject != D_TOOL) {
272 strcat(name_cam, "/camera.bnd");
273 set_scene(name_cam, &camera, cameraFactor);
274 }
275 else {
276 strcat(name_cam, "/tool.bnd");
277 set_scene(name_cam, &(this->camera), 1.0);
278 }
279
280 strcpy(name, scene_dir_);
281 switch (obj) {
282 case THREE_PTS: {
283 strcat(name, "/3pts.bnd");
284 break;
285 }
286 case CUBE: {
287 strcat(name, "/cube.bnd");
288 break;
289 }
290 case PLATE: {
291 strcat(name, "/plate.bnd");
292 break;
293 }
294 case SMALL_PLATE: {
295 strcat(name, "/plate_6cm.bnd");
296 break;
297 }
298 case RECTANGLE: {
299 strcat(name, "/rectangle.bnd");
300 break;
301 }
302 case SQUARE_10CM: {
303 strcat(name, "/square10cm.bnd");
304 break;
305 }
306 case DIAMOND: {
307 strcat(name, "/diamond.bnd");
308 break;
309 }
310 case TRAPEZOID: {
311 strcat(name, "/trapezoid.bnd");
312 break;
313 }
314 case THREE_LINES: {
315 strcat(name, "/line.bnd");
316 break;
317 }
318 case ROAD: {
319 strcat(name, "/road.bnd");
320 break;
321 }
322 case TIRE: {
323 strcat(name, "/circles2.bnd");
324 break;
325 }
326 case PIPE: {
327 strcat(name, "/pipe.bnd");
328 break;
329 }
330 case CIRCLE: {
331 strcat(name, "/circle.bnd");
332 break;
333 }
334 case SPHERE: {
335 strcat(name, "/sphere.bnd");
336 break;
337 }
338 case CYLINDER: {
339 strcat(name, "/cylinder.bnd");
340 break;
341 }
342 case PLAN: {
343 strcat(name, "/plan.bnd");
344 break;
345 }
346 case POINT_CLOUD: {
347 strcat(name, "/point_cloud.bnd");
348 break;
349 }
350 }
351 set_scene(name, &(this->scene), 1.0);
352
353 scene_dir_ = scene_dir.c_str();
354 if (strlen(scene_dir_) >= FILENAME_MAX) {
355 throw(vpException(vpException::memoryAllocationError, "Not enough memory to initialize the desired object name"));
356 }
357
358 switch (desiredObject) {
359 case D_STANDARD: {
360 break;
361 }
362 case D_CIRCLE: {
363 strcpy(name, scene_dir_);
364 strcat(name, "/circle_sq2.bnd");
365 break;
366 }
367 case D_TOOL: {
368 strcpy(name, scene_dir_);
369 strcat(name, "/tool.bnd");
370 break;
371 }
372 }
373 set_scene(name, &(this->desiredScene), 1.0);
374
375 if (obj == PIPE)
376 load_rfstack(IS_INSIDE);
377 else
378 add_rfstack(IS_BACK);
379
380 add_vwstack("start", "depth", 0.0, 100.0);
381 add_vwstack("start", "window", -0.1, 0.1, -0.1, 0.1);
382 add_vwstack("start", "type", PERSPECTIVE);
383
384 sceneInitialized = true;
385 displayObject = true;
387 displayCamera = true;
389}
390
411 const std::list<vpImageSimulator> &imObj)
412{
413 initScene(obj, desired_object);
414 objectImage = imObj;
416}
417
429void vpWireFrameSimulator::initScene(const char *obj, const char *desired_object)
430{
431 char name_cam[FILENAME_MAX];
432 char name[FILENAME_MAX];
433
434 object = THREE_PTS;
436
437 const char *scene_dir_ = scene_dir.c_str();
438 if (strlen(scene_dir_) >= FILENAME_MAX) {
439 throw(vpException(vpException::memoryAllocationError, "Not enough memory to initialize the camera name"));
440 }
441
442 strcpy(name_cam, scene_dir_);
443 strcat(name_cam, "/camera.bnd");
444 set_scene(name_cam, &camera, cameraFactor);
445
446 if (strlen(obj) >= FILENAME_MAX) {
447 throw(vpException(vpException::memoryAllocationError, "Not enough memory to initialize the name"));
448 }
449
450 strcpy(name, obj);
451 Model_3D model;
452 model = getExtension(obj);
453 if (model == BND_MODEL)
454 set_scene(name, &(this->scene), 1.0);
455 else if (model == WRL_MODEL)
456 set_scene_wrl(name, &(this->scene), 1.0);
457 else if (model == UNKNOWN_MODEL) {
458 vpERROR_TRACE("Unknown file extension for the 3D model");
459 }
460
461 if (strlen(desired_object) >= FILENAME_MAX) {
462 throw(vpException(vpException::memoryAllocationError, "Not enough memory to initialize the camera name"));
463 }
464
465 strcpy(name, desired_object);
466 model = getExtension(desired_object);
467 if (model == BND_MODEL)
468 set_scene(name, &(this->desiredScene), 1.0);
469 else if (model == WRL_MODEL)
470 set_scene_wrl(name, &(this->desiredScene), 1.0);
471 else if (model == UNKNOWN_MODEL) {
472 vpERROR_TRACE("Unknown file extension for the 3D model");
473 }
474
475 add_rfstack(IS_BACK);
476
477 add_vwstack("start", "depth", 0.0, 100.0);
478 add_vwstack("start", "window", -0.1, 0.1, -0.1, 0.1);
479 add_vwstack("start", "type", PERSPECTIVE);
480
481 sceneInitialized = true;
482 displayObject = true;
484 displayCamera = true;
485}
486
503void vpWireFrameSimulator::initScene(const char *obj, const char *desired_object,
504 const std::list<vpImageSimulator> &imObj)
505{
506 initScene(obj, desired_object);
507 objectImage = imObj;
509}
510
524{
525 char name_cam[FILENAME_MAX];
526 char name[FILENAME_MAX];
527
528 object = obj;
529
530 const char *scene_dir_ = scene_dir.c_str();
531 if (strlen(scene_dir_) >= FILENAME_MAX) {
532 throw(vpException(vpException::memoryAllocationError, "Not enough memory to initialize the camera name"));
533 }
534
535 strcpy(name_cam, scene_dir_);
536 strcat(name_cam, "/camera.bnd");
537 set_scene(name_cam, &camera, cameraFactor);
538
539 strcpy(name, scene_dir_);
540 switch (obj) {
541 case THREE_PTS: {
542 strcat(name, "/3pts.bnd");
543 break;
544 }
545 case CUBE: {
546 strcat(name, "/cube.bnd");
547 break;
548 }
549 case PLATE: {
550 strcat(name, "/plate.bnd");
551 break;
552 }
553 case SMALL_PLATE: {
554 strcat(name, "/plate_6cm.bnd");
555 break;
556 }
557 case RECTANGLE: {
558 strcat(name, "/rectangle.bnd");
559 break;
560 }
561 case SQUARE_10CM: {
562 strcat(name, "/square10cm.bnd");
563 break;
564 }
565 case DIAMOND: {
566 strcat(name, "/diamond.bnd");
567 break;
568 }
569 case TRAPEZOID: {
570 strcat(name, "/trapezoid.bnd");
571 break;
572 }
573 case THREE_LINES: {
574 strcat(name, "/line.bnd");
575 break;
576 }
577 case ROAD: {
578 strcat(name, "/road.bnd");
579 break;
580 }
581 case TIRE: {
582 strcat(name, "/circles2.bnd");
583 break;
584 }
585 case PIPE: {
586 strcat(name, "/pipe.bnd");
587 break;
588 }
589 case CIRCLE: {
590 strcat(name, "/circle.bnd");
591 break;
592 }
593 case SPHERE: {
594 strcat(name, "/sphere.bnd");
595 break;
596 }
597 case CYLINDER: {
598 strcat(name, "/cylinder.bnd");
599 break;
600 }
601 case PLAN: {
602 strcat(name, "/plan.bnd");
603 break;
604 }
605 case POINT_CLOUD: {
606 strcat(name, "/point_cloud.bnd");
607 break;
608 }
609 }
610 set_scene(name, &(this->scene), 1.0);
611
612 if (obj == PIPE)
613 load_rfstack(IS_INSIDE);
614 else
615 add_rfstack(IS_BACK);
616
617 add_vwstack("start", "depth", 0.0, 100.0);
618 add_vwstack("start", "window", -0.1, 0.1, -0.1, 0.1);
619 add_vwstack("start", "type", PERSPECTIVE);
620
621 sceneInitialized = true;
622 displayObject = true;
623 displayCamera = true;
624
625 displayDesiredObject = false;
626 displayImageSimulator = false;
627}
628
645void vpWireFrameSimulator::initScene(const vpSceneObject &obj, const std::list<vpImageSimulator> &imObj)
646{
647 initScene(obj);
648 objectImage = imObj;
650}
651
663{
664 char name_cam[FILENAME_MAX];
665 char name[FILENAME_MAX];
666
667 object = THREE_PTS;
668
669 const char *scene_dir_ = scene_dir.c_str();
670 if (strlen(scene_dir_) >= FILENAME_MAX) {
671 throw(vpException(vpException::memoryAllocationError, "Not enough memory to initialize the camera name"));
672 }
673
674 strcpy(name_cam, scene_dir_);
675 strcat(name_cam, "/camera.bnd");
676 set_scene(name_cam, &camera, cameraFactor);
677
678 if (strlen(obj) >= FILENAME_MAX) {
679 throw(vpException(vpException::memoryAllocationError, "Not enough memory to initialize the name"));
680 }
681
682 strcpy(name, obj);
683 Model_3D model;
684 model = getExtension(obj);
685 if (model == BND_MODEL)
686 set_scene(name, &(this->scene), 1.0);
687 else if (model == WRL_MODEL)
688 set_scene_wrl(name, &(this->scene), 1.0);
689 else if (model == UNKNOWN_MODEL) {
690 vpERROR_TRACE("Unknown file extension for the 3D model");
691 }
692
693 add_rfstack(IS_BACK);
694
695 add_vwstack("start", "depth", 0.0, 100.0);
696 add_vwstack("start", "window", -0.1, 0.1, -0.1, 0.1);
697 add_vwstack("start", "type", PERSPECTIVE);
698
699 sceneInitialized = true;
700 displayObject = true;
701 displayCamera = true;
702}
703
719void vpWireFrameSimulator::initScene(const char *obj, const std::list<vpImageSimulator> &imObj)
720{
721 initScene(obj);
722 objectImage = imObj;
724}
725
735{
736 if (!sceneInitialized)
737 throw(vpException(vpException::notInitialized, "The scene has to be initialized"));
738
739 double u;
740 double v;
741 // if(px_int != 1 && py_int != 1)
742 // we assume px_int and py_int > 0
743 if ((std::fabs(px_int - 1.) > vpMath::maximum(px_int, 1.) * std::numeric_limits<double>::epsilon()) &&
744 (std::fabs(py_int - 1) > vpMath::maximum(py_int, 1.) * std::numeric_limits<double>::epsilon())) {
745 u = static_cast<double>(I.getWidth()) / (2 * px_int);
746 v = static_cast<double>(I.getHeight()) / (2 * py_int);
747 }
748 else {
749 u = static_cast<double>(I.getWidth()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
750 v = static_cast<double>(I.getHeight()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
751 }
752
753 float o44c[4][4], o44cd[4][4], x, y, z;
754 Matrix id = IDENTITY_MATRIX;
755
756 vp2jlc_matrix(cMo.inverse(), o44c);
757 vp2jlc_matrix(cdMo.inverse(), o44cd);
758
760 I = vpRGBa(255);
761
762 for (std::list<vpImageSimulator>::iterator it = objectImage.begin(); it != objectImage.end(); ++it) {
763 vpImageSimulator *imSim = &(*it);
764 imSim->setCameraPosition(rotz * cMo);
766 }
767
768 if (I.display != NULL)
770 }
771
772 add_vwstack("start", "cop", o44c[3][0], o44c[3][1], o44c[3][2]);
773 x = o44c[2][0] + o44c[3][0];
774 y = o44c[2][1] + o44c[3][1];
775 z = o44c[2][2] + o44c[3][2];
776 add_vwstack("start", "vrp", x, y, z);
777 add_vwstack("start", "vpn", o44c[2][0], o44c[2][1], o44c[2][2]);
778 add_vwstack("start", "vup", o44c[1][0], o44c[1][1], o44c[1][2]);
779 add_vwstack("start", "window", -u, u, -v, v);
780 if (displayObject)
781 display_scene(id, this->scene, I, curColor);
782
783 add_vwstack("start", "cop", o44cd[3][0], o44cd[3][1], o44cd[3][2]);
784 x = o44cd[2][0] + o44cd[3][0];
785 y = o44cd[2][1] + o44cd[3][1];
786 z = o44cd[2][2] + o44cd[3][2];
787 add_vwstack("start", "vrp", x, y, z);
788 add_vwstack("start", "vpn", o44cd[2][0], o44cd[2][1], o44cd[2][2]);
789 add_vwstack("start", "vup", o44cd[1][0], o44cd[1][1], o44cd[1][2]);
790 add_vwstack("start", "window", -u, u, -v, v);
792 if (desiredObject == D_TOOL)
794 else
796 }
797}
798
808
810{
811 bool changed = false;
812 vpHomogeneousMatrix displacement = navigation(I, changed);
813
814 // if (displacement[2][3] != 0 /*|| rotation[0][3] != 0 || rotation[1][3] !=
815 // 0*/)
816 if (std::fabs(displacement[2][3]) >
817 std::numeric_limits<double>::epsilon() /*|| rotation[0][3] != 0 || rotation[1][3] != 0*/)
818 camMf2 = camMf2 * displacement;
819
820 f2Mf = camMf2.inverse() * camMf;
821
822 camMf = camMf2 * displacement * f2Mf;
823
824 double u;
825 double v;
826 // if(px_ext != 1 && py_ext != 1)
827 // we assume px_ext and py_ext > 0
828 if ((std::fabs(px_ext - 1.) > vpMath::maximum(px_ext, 1.) * std::numeric_limits<double>::epsilon()) &&
829 (std::fabs(py_ext - 1) > vpMath::maximum(py_ext, 1.) * std::numeric_limits<double>::epsilon())) {
830 u = static_cast<double>(I.getWidth()) / (2 * px_ext);
831 v = static_cast<double>(I.getHeight()) / (2 * py_ext);
832 }
833 else {
834 u = static_cast<double>(I.getWidth()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
835 v = static_cast<double>(I.getHeight()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
836 }
837
838 float w44o[4][4], w44cext[4][4], w44c[4][4], x, y, z;
839
840 vp2jlc_matrix(camMf.inverse(), w44cext);
841 vp2jlc_matrix(fMc, w44c);
842 vp2jlc_matrix(fMo, w44o);
843
844 add_vwstack("start", "cop", w44cext[3][0], w44cext[3][1], w44cext[3][2]);
845 x = w44cext[2][0] + w44cext[3][0];
846 y = w44cext[2][1] + w44cext[3][1];
847 z = w44cext[2][2] + w44cext[3][2];
848 add_vwstack("start", "vrp", x, y, z);
849 add_vwstack("start", "vpn", w44cext[2][0], w44cext[2][1], w44cext[2][2]);
850 add_vwstack("start", "vup", w44cext[1][0], w44cext[1][1], w44cext[1][2]);
851 add_vwstack("start", "window", -u, u, -v, v);
852 if ((object == CUBE) || (object == SPHERE)) {
853 add_vwstack("start", "type", PERSPECTIVE);
854 }
855
857 I = vpRGBa(255);
858
859 for (std::list<vpImageSimulator>::iterator it = objectImage.begin(); it != objectImage.end(); ++it) {
860 vpImageSimulator *imSim = &(*it);
861 imSim->setCameraPosition(rotz * camMf * fMo);
863 }
864
865 if (I.display != NULL)
867 }
868
869 if (displayObject)
870 display_scene(w44o, this->scene, I, curColor);
871
872 if (displayCamera)
873 display_scene(w44c, camera, I, camColor);
874
876 vpImagePoint iP;
877 vpImagePoint iP_1;
878 poseList.push_back(cMo);
879 fMoList.push_back(fMo);
880
881 int iter = 0;
882
883 if (changed || extCamChanged) {
884 cameraTrajectory.clear();
885 std::list<vpHomogeneousMatrix>::const_iterator iter_poseList = poseList.begin();
886 std::list<vpHomogeneousMatrix>::const_iterator iter_fMoList = fMoList.begin();
887
888 while ((iter_poseList != poseList.end()) && (iter_fMoList != fMoList.end())) {
889 iP = projectCameraTrajectory(I, *iter_poseList, *iter_fMoList);
890 cameraTrajectory.push_back(iP);
891 if (camTrajType == CT_LINE) {
892 if (iter != 0)
894 }
895 else if (camTrajType == CT_POINT)
897 ++iter_poseList;
898 ++iter_fMoList;
899 iter++;
900 iP_1 = iP;
901 }
902 extCamChanged = false;
903 }
904 else {
906 cameraTrajectory.push_back(iP);
907
908 for (std::list<vpImagePoint>::const_iterator it = cameraTrajectory.begin(); it != cameraTrajectory.end(); ++it) {
909 if (camTrajType == CT_LINE) {
910 if (iter != 0)
912 }
913 else if (camTrajType == CT_POINT)
915 iter++;
916 iP_1 = *it;
917 }
918 }
919
920 if (poseList.size() > nbrPtLimit) {
921 poseList.pop_front();
922 }
923 if (fMoList.size() > nbrPtLimit) {
924 fMoList.pop_front();
925 }
926 if (cameraTrajectory.size() > nbrPtLimit) {
927 cameraTrajectory.pop_front();
928 }
929 }
930}
931
944{
945 float w44o[4][4], w44cext[4][4], w44c[4][4], x, y, z;
946
947 vpHomogeneousMatrix camMft = rotz * cam_Mf;
948
949 double u;
950 double v;
951 // if(px_ext != 1 && py_ext != 1)
952 // we assume px_ext and py_ext > 0
953 if ((std::fabs(px_ext - 1.) > vpMath::maximum(px_ext, 1.) * std::numeric_limits<double>::epsilon()) &&
954 (std::fabs(py_ext - 1) > vpMath::maximum(py_ext, 1.) * std::numeric_limits<double>::epsilon())) {
955 u = static_cast<double>(I.getWidth()) / (2 * px_ext);
956 v = static_cast<double>(I.getHeight()) / (2 * py_ext);
957 }
958 else {
959 u = static_cast<double>(I.getWidth()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
960 v = static_cast<double>(I.getHeight()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
961 }
962
963 vp2jlc_matrix(camMft.inverse(), w44cext);
964 vp2jlc_matrix(fMo * cMo.inverse(), w44c);
965 vp2jlc_matrix(fMo, w44o);
966
967 add_vwstack("start", "cop", w44cext[3][0], w44cext[3][1], w44cext[3][2]);
968 x = w44cext[2][0] + w44cext[3][0];
969 y = w44cext[2][1] + w44cext[3][1];
970 z = w44cext[2][2] + w44cext[3][2];
971 add_vwstack("start", "vrp", x, y, z);
972 add_vwstack("start", "vpn", w44cext[2][0], w44cext[2][1], w44cext[2][2]);
973 add_vwstack("start", "vup", w44cext[1][0], w44cext[1][1], w44cext[1][2]);
974 add_vwstack("start", "window", -u, u, -v, v);
975
977 I = vpRGBa(255);
978
979 for (std::list<vpImageSimulator>::iterator it = objectImage.begin(); it != objectImage.end(); ++it) {
980 vpImageSimulator *imSim = &(*it);
981 imSim->setCameraPosition(rotz * cam_Mf * fMo);
983 }
984
985 if (I.display != NULL)
987 }
988
989 if (displayObject)
990 display_scene(w44o, this->scene, I, curColor);
991 if (displayCamera)
992 display_scene(w44c, camera, I, camColor);
993}
994
1004{
1005 if (!sceneInitialized)
1006 throw(vpException(vpException::notInitialized, "The scene has to be initialized"));
1007
1008 double u;
1009 double v;
1010 // if(px_int != 1 && py_int != 1)
1011 // we assume px_int and py_int > 0
1012 if ((std::fabs(px_int - 1.) > vpMath::maximum(px_int, 1.) * std::numeric_limits<double>::epsilon()) &&
1013 (std::fabs(py_int - 1) > vpMath::maximum(py_int, 1.) * std::numeric_limits<double>::epsilon())) {
1014 u = static_cast<double>(I.getWidth()) / (2 * px_int);
1015 v = static_cast<double>(I.getHeight()) / (2 * py_int);
1016 }
1017 else {
1018 u = static_cast<double>(I.getWidth()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
1019 v = static_cast<double>(I.getHeight()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
1020 }
1021
1022 float o44c[4][4], o44cd[4][4], x, y, z;
1023 Matrix id = IDENTITY_MATRIX;
1024
1025 vp2jlc_matrix(cMo.inverse(), o44c);
1026 vp2jlc_matrix(cdMo.inverse(), o44cd);
1027
1029 I = 255u;
1030
1031 for (std::list<vpImageSimulator>::iterator it = objectImage.begin(); it != objectImage.end(); ++it) {
1032 vpImageSimulator *imSim = &(*it);
1033 imSim->setCameraPosition(rotz * camMf * fMo);
1035 }
1036
1037 if (I.display != NULL)
1039 }
1040
1041 add_vwstack("start", "cop", o44c[3][0], o44c[3][1], o44c[3][2]);
1042 x = o44c[2][0] + o44c[3][0];
1043 y = o44c[2][1] + o44c[3][1];
1044 z = o44c[2][2] + o44c[3][2];
1045 add_vwstack("start", "vrp", x, y, z);
1046 add_vwstack("start", "vpn", o44c[2][0], o44c[2][1], o44c[2][2]);
1047 add_vwstack("start", "vup", o44c[1][0], o44c[1][1], o44c[1][2]);
1048 add_vwstack("start", "window", -u, u, -v, v);
1049 if (displayObject)
1050 display_scene(id, this->scene, I, curColor);
1051
1052 add_vwstack("start", "cop", o44cd[3][0], o44cd[3][1], o44cd[3][2]);
1053 x = o44cd[2][0] + o44cd[3][0];
1054 y = o44cd[2][1] + o44cd[3][1];
1055 z = o44cd[2][2] + o44cd[3][2];
1056 add_vwstack("start", "vrp", x, y, z);
1057 add_vwstack("start", "vpn", o44cd[2][0], o44cd[2][1], o44cd[2][2]);
1058 add_vwstack("start", "vup", o44cd[1][0], o44cd[1][1], o44cd[1][2]);
1059 add_vwstack("start", "window", -u, u, -v, v);
1061 if (desiredObject == D_TOOL)
1063 else
1065 }
1066}
1067
1077
1079{
1080 bool changed = false;
1081 vpHomogeneousMatrix displacement = navigation(I, changed);
1082
1083 // if (displacement[2][3] != 0 /*|| rotation[0][3] != 0 || rotation[1][3] !=
1084 // 0*/)
1085 if (std::fabs(displacement[2][3]) >
1086 std::numeric_limits<double>::epsilon() /*|| rotation[0][3] != 0 || rotation[1][3] != 0*/)
1087 camMf2 = camMf2 * displacement;
1088
1089 f2Mf = camMf2.inverse() * camMf;
1090
1091 camMf = camMf2 * displacement * f2Mf;
1092
1093 double u;
1094 double v;
1095 // if(px_ext != 1 && py_ext != 1)
1096 // we assume px_ext and py_ext > 0
1097 if ((std::fabs(px_ext - 1.) > vpMath::maximum(px_ext, 1.) * std::numeric_limits<double>::epsilon()) &&
1098 (std::fabs(py_ext - 1) > vpMath::maximum(py_ext, 1.) * std::numeric_limits<double>::epsilon())) {
1099 u = static_cast<double>(I.getWidth()) / (2 * px_ext);
1100 v = static_cast<double>(I.getHeight()) / (2 * py_ext);
1101 }
1102 else {
1103 u = static_cast<double>(I.getWidth()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
1104 v = static_cast<double>(I.getHeight()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
1105 }
1106
1107 float w44o[4][4], w44cext[4][4], w44c[4][4], x, y, z;
1108
1109 vp2jlc_matrix(camMf.inverse(), w44cext);
1110 vp2jlc_matrix(fMc, w44c);
1111 vp2jlc_matrix(fMo, w44o);
1112
1113 add_vwstack("start", "cop", w44cext[3][0], w44cext[3][1], w44cext[3][2]);
1114 x = w44cext[2][0] + w44cext[3][0];
1115 y = w44cext[2][1] + w44cext[3][1];
1116 z = w44cext[2][2] + w44cext[3][2];
1117 add_vwstack("start", "vrp", x, y, z);
1118 add_vwstack("start", "vpn", w44cext[2][0], w44cext[2][1], w44cext[2][2]);
1119 add_vwstack("start", "vup", w44cext[1][0], w44cext[1][1], w44cext[1][2]);
1120 add_vwstack("start", "window", -u, u, -v, v);
1121 if ((object == CUBE) || (object == SPHERE)) {
1122 add_vwstack("start", "type", PERSPECTIVE);
1123 }
1124
1126 I = 255u;
1127 for (std::list<vpImageSimulator>::iterator it = objectImage.begin(); it != objectImage.end(); ++it) {
1128 vpImageSimulator *imSim = &(*it);
1129 imSim->setCameraPosition(rotz * camMf * fMo);
1131 }
1132 if (I.display != NULL)
1134 }
1135
1136 if (displayObject)
1137 display_scene(w44o, this->scene, I, curColor);
1138
1139 if (displayCamera)
1140 display_scene(w44c, camera, I, camColor);
1141
1143 vpImagePoint iP;
1144 vpImagePoint iP_1;
1145 poseList.push_back(cMo);
1146 fMoList.push_back(fMo);
1147
1148 int iter = 0;
1149
1150 if (changed || extCamChanged) {
1151 cameraTrajectory.clear();
1152 std::list<vpHomogeneousMatrix>::const_iterator iter_poseList = poseList.begin();
1153 std::list<vpHomogeneousMatrix>::const_iterator iter_fMoList = fMoList.begin();
1154
1155 while ((iter_poseList != poseList.end()) && (iter_fMoList != fMoList.end())) {
1156 iP = projectCameraTrajectory(I, *iter_poseList, *iter_fMoList);
1157 cameraTrajectory.push_back(iP);
1158 // vpDisplay::displayPoint(I,cameraTrajectory.value(),vpColor::green);
1159 if (camTrajType == CT_LINE) {
1160 if (iter != 0)
1162 }
1163 else if (camTrajType == CT_POINT)
1165 ++iter_poseList;
1166 ++iter_fMoList;
1167 iter++;
1168 iP_1 = iP;
1169 }
1170 extCamChanged = false;
1171 }
1172 else {
1174 cameraTrajectory.push_back(iP);
1175
1176 for (std::list<vpImagePoint>::const_iterator it = cameraTrajectory.begin(); it != cameraTrajectory.end(); ++it) {
1177 if (camTrajType == CT_LINE) {
1178 if (iter != 0)
1180 }
1181 else if (camTrajType == CT_POINT)
1183 iter++;
1184 iP_1 = *it;
1185 }
1186 }
1187
1188 if (poseList.size() > nbrPtLimit) {
1189 poseList.pop_front();
1190 }
1191 if (fMoList.size() > nbrPtLimit) {
1192 fMoList.pop_front();
1193 }
1194 if (cameraTrajectory.size() > nbrPtLimit) {
1195 cameraTrajectory.pop_front();
1196 }
1197 }
1198}
1199
1212{
1213 float w44o[4][4], w44cext[4][4], w44c[4][4], x, y, z;
1214
1215 vpHomogeneousMatrix camMft = rotz * cam_Mf;
1216
1217 double u;
1218 double v;
1219 // if(px_ext != 1 && py_ext != 1)
1220 // we assume px_ext and py_ext > 0
1221 if ((std::fabs(px_ext - 1.) > vpMath::maximum(px_ext, 1.) * std::numeric_limits<double>::epsilon()) &&
1222 (std::fabs(py_ext - 1) > vpMath::maximum(py_ext, 1.) * std::numeric_limits<double>::epsilon())) {
1223 u = static_cast<double>(I.getWidth()) / (2 * px_ext);
1224 v = static_cast<double>(I.getHeight()) / (2 * py_ext);
1225 }
1226 else {
1227 u = static_cast<double>(I.getWidth()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
1228 v = static_cast<double>(I.getHeight()) / (vpMath::minimum(I.getWidth(), I.getHeight()));
1229 }
1230
1231 vp2jlc_matrix(camMft.inverse(), w44cext);
1232 vp2jlc_matrix(fMo * cMo.inverse(), w44c);
1233 vp2jlc_matrix(fMo, w44o);
1234
1235 add_vwstack("start", "cop", w44cext[3][0], w44cext[3][1], w44cext[3][2]);
1236 x = w44cext[2][0] + w44cext[3][0];
1237 y = w44cext[2][1] + w44cext[3][1];
1238 z = w44cext[2][2] + w44cext[3][2];
1239 add_vwstack("start", "vrp", x, y, z);
1240 add_vwstack("start", "vpn", w44cext[2][0], w44cext[2][1], w44cext[2][2]);
1241 add_vwstack("start", "vup", w44cext[1][0], w44cext[1][1], w44cext[1][2]);
1242 add_vwstack("start", "window", -u, u, -v, v);
1243
1245 I = 255u;
1246 for (std::list<vpImageSimulator>::iterator it = objectImage.begin(); it != objectImage.end(); ++it) {
1247 vpImageSimulator *imSim = &(*it);
1248 imSim->setCameraPosition(rotz * cam_Mf * fMo);
1250 }
1251 if (I.display != NULL)
1253 }
1254
1255 if (displayObject)
1256 display_scene(w44o, this->scene, I, curColor);
1257 if (displayCamera)
1258 display_scene(w44c, camera, I, camColor);
1259}
1260
1279 const std::list<vpHomogeneousMatrix> &list_cMo,
1280 const std::list<vpHomogeneousMatrix> &list_fMo,
1281 const vpHomogeneousMatrix &cMf)
1282{
1283 if (list_cMo.size() != list_fMo.size())
1284 throw(vpException(vpException::dimensionError, "The two lists must have the same size"));
1285
1286 vpImagePoint iP;
1287 vpImagePoint iP_1;
1288 int iter = 0;
1289
1290 std::list<vpHomogeneousMatrix>::const_iterator it_cMo = list_cMo.begin();
1291 std::list<vpHomogeneousMatrix>::const_iterator it_fMo = list_fMo.begin();
1292
1293 while ((it_cMo != list_cMo.end()) && (it_fMo != list_fMo.end())) {
1294 iP = projectCameraTrajectory(I, rotz * (*it_cMo), (*it_fMo), rotz * cMf);
1295 if (camTrajType == CT_LINE) {
1296 if (iter != 0)
1298 }
1299 else if (camTrajType == CT_POINT)
1301 ++it_cMo;
1302 ++it_fMo;
1303 iter++;
1304 iP_1 = iP;
1305 }
1306}
1307
1325void vpWireFrameSimulator::displayTrajectory(const vpImage<vpRGBa> &I, const std::list<vpHomogeneousMatrix> &list_cMo,
1326 const std::list<vpHomogeneousMatrix> &list_fMo,
1327 const vpHomogeneousMatrix &cMf)
1328{
1329 if (list_cMo.size() != list_fMo.size())
1330 throw(vpException(vpException::dimensionError, "The two lists must have the same size"));
1331
1332 vpImagePoint iP;
1333 vpImagePoint iP_1;
1334 int iter = 0;
1335
1336 std::list<vpHomogeneousMatrix>::const_iterator it_cMo = list_cMo.begin();
1337 std::list<vpHomogeneousMatrix>::const_iterator it_fMo = list_fMo.begin();
1338
1339 while ((it_cMo != list_cMo.end()) && (it_fMo != list_fMo.end())) {
1340 iP = projectCameraTrajectory(I, rotz * (*it_cMo), (*it_fMo), rotz * cMf);
1341 if (camTrajType == CT_LINE) {
1342 if (iter != 0)
1344 }
1345 else if (camTrajType == CT_POINT)
1347 ++it_cMo;
1348 ++it_fMo;
1349 iter++;
1350 iP_1 = iP;
1351 }
1352}
1353
1358{
1359 double width = vpMath::minimum(I.getWidth(), I.getHeight());
1360 vpImagePoint iP;
1361 vpImagePoint trash;
1362 bool clicked = false;
1363 bool clickedUp = false;
1365
1366 vpHomogeneousMatrix mov(0, 0, 0, 0, 0, 0);
1367 changed = false;
1368
1369 // if(!blocked) vpDisplay::getClickUp(I,trash, b,false);
1370
1371 if (!blocked)
1372 clicked = vpDisplay::getClick(I, trash, b, false);
1373
1374 if (blocked)
1375 clickedUp = vpDisplay::getClickUp(I, trash, b, false);
1376
1377 if (clicked) {
1378 if (b == vpMouseButton::button1)
1379 blockedr = true;
1380 if (b == vpMouseButton::button2)
1381 blockedz = true;
1382 if (b == vpMouseButton::button3)
1383 blockedt = true;
1384 blocked = true;
1385 }
1386 if (clickedUp) {
1387 if (b == vpMouseButton::button1) {
1388 old_iPr = vpImagePoint(-1, -1);
1389 blockedr = false;
1390 }
1391 if (b == vpMouseButton::button2) {
1392 old_iPz = vpImagePoint(-1, -1);
1393 blockedz = false;
1394 }
1395 if (b == vpMouseButton::button3) {
1396 old_iPt = vpImagePoint(-1, -1);
1397 blockedt = false;
1398 }
1399 if (!(blockedr || blockedz || blockedt)) {
1400 blocked = false;
1401 while (vpDisplay::getClick(I, trash, b, false)) {
1402 }
1403 }
1404 }
1405
1407
1408 if (old_iPr != vpImagePoint(-1, -1) && blockedr) {
1409 double diffi = iP.get_i() - old_iPr.get_i();
1410 double diffj = iP.get_j() - old_iPr.get_j();
1411 double anglei = diffi * 360 / width;
1412 double anglej = diffj * 360 / width;
1413 mov.buildFrom(0, 0, 0, vpMath::rad(-anglei), vpMath::rad(anglej), 0);
1414 changed = true;
1415 }
1416
1417 if (blockedr)
1418 old_iPr = iP;
1419
1420 if (old_iPz != vpImagePoint(-1, -1) && blockedz) {
1421 double diffi = iP.get_i() - old_iPz.get_i();
1422 mov.buildFrom(0, 0, diffi * 0.01, 0, 0, 0);
1423 changed = true;
1424 }
1425
1426 if (blockedz)
1427 old_iPz = iP;
1428
1429 if (old_iPt != vpImagePoint(-1, -1) && blockedt) {
1430 double diffi = iP.get_i() - old_iPt.get_i();
1431 double diffj = iP.get_j() - old_iPt.get_j();
1432 mov.buildFrom(diffj * 0.01, diffi * 0.01, 0, 0, 0, 0);
1433 changed = true;
1434 }
1435
1436 if (blockedt)
1437 old_iPt = iP;
1438
1439 return mov;
1440}
1441
1446{
1447 double width = vpMath::minimum(I.getWidth(), I.getHeight());
1448 vpImagePoint iP;
1449 vpImagePoint trash;
1450 bool clicked = false;
1451 bool clickedUp = false;
1453
1454 vpHomogeneousMatrix mov(0, 0, 0, 0, 0, 0);
1455 changed = false;
1456
1457 // if(!blocked) vpDisplay::getClickUp(I,trash, b,false);
1458
1459 if (!blocked)
1460 clicked = vpDisplay::getClick(I, trash, b, false);
1461
1462 if (blocked)
1463 clickedUp = vpDisplay::getClickUp(I, trash, b, false);
1464
1465 if (clicked) {
1466 if (b == vpMouseButton::button1)
1467 blockedr = true;
1468 if (b == vpMouseButton::button2)
1469 blockedz = true;
1470 if (b == vpMouseButton::button3)
1471 blockedt = true;
1472 blocked = true;
1473 }
1474 if (clickedUp) {
1475 if (b == vpMouseButton::button1) {
1476 old_iPr = vpImagePoint(-1, -1);
1477 blockedr = false;
1478 }
1479 if (b == vpMouseButton::button2) {
1480 old_iPz = vpImagePoint(-1, -1);
1481 blockedz = false;
1482 }
1483 if (b == vpMouseButton::button3) {
1484 old_iPt = vpImagePoint(-1, -1);
1485 blockedt = false;
1486 }
1487 if (!(blockedr || blockedz || blockedt)) {
1488 blocked = false;
1489 while (vpDisplay::getClick(I, trash, b, false)) {
1490 }
1491 }
1492 }
1493
1495
1496 // std::cout << "point : " << iP << std::endl;
1497
1498 if (old_iPr != vpImagePoint(-1, -1) && blockedr) {
1499 double diffi = iP.get_i() - old_iPr.get_i();
1500 double diffj = iP.get_j() - old_iPr.get_j();
1501 double anglei = diffi * 360 / width;
1502 double anglej = diffj * 360 / width;
1503 mov.buildFrom(0, 0, 0, vpMath::rad(-anglei), vpMath::rad(anglej), 0);
1504 changed = true;
1505 }
1506
1507 if (blockedr)
1508 old_iPr = iP;
1509
1510 if (old_iPz != vpImagePoint(-1, -1) && blockedz) {
1511 double diffi = iP.get_i() - old_iPz.get_i();
1512 mov.buildFrom(0, 0, diffi * 0.01, 0, 0, 0);
1513 changed = true;
1514 }
1515
1516 if (blockedz)
1517 old_iPz = iP;
1518
1519 if (old_iPt != vpImagePoint(-1, -1) && blockedt) {
1520 double diffi = iP.get_i() - old_iPt.get_i();
1521 double diffj = iP.get_j() - old_iPt.get_j();
1522 mov.buildFrom(diffj * 0.01, diffi * 0.01, 0, 0, 0, 0);
1523 changed = true;
1524 }
1525
1526 if (blockedt)
1527 old_iPt = iP;
1528
1529 return mov;
1530}
1531
1536 const vpHomogeneousMatrix &fMo_)
1537{
1538 vpPoint point;
1539 point.setWorldCoordinates(0, 0, 0);
1540
1541 point.track(rotz * (camMf * fMo_ * cMo_.inverse()));
1542
1543 vpImagePoint iP;
1544
1546
1547 return iP;
1548}
1549
1554 const vpHomogeneousMatrix &cMo_,
1555 const vpHomogeneousMatrix &fMo_)
1556{
1557 vpPoint point;
1558 point.setWorldCoordinates(0, 0, 0);
1559
1560 point.track(rotz * (camMf * fMo_ * cMo_.inverse()));
1561
1562 vpImagePoint iP;
1563
1565
1566 return iP;
1567}
1568
1573 const vpHomogeneousMatrix &fMo_,
1574 const vpHomogeneousMatrix &cMf)
1575{
1576 vpPoint point;
1577 point.setWorldCoordinates(0, 0, 0);
1578
1579 point.track(rotz * (cMf * fMo_ * cMo_.inverse()));
1580
1581 vpImagePoint iP;
1582
1584
1585 return iP;
1586}
1587
1592 const vpHomogeneousMatrix &cMo_,
1593 const vpHomogeneousMatrix &fMo_,
1594 const vpHomogeneousMatrix &cMf)
1595{
1596 vpPoint point;
1597 point.setWorldCoordinates(0, 0, 0);
1598
1599 point.track(rotz * (cMf * fMo_ * cMo_.inverse()));
1600
1601 vpImagePoint iP;
1602
1604
1605 return iP;
1606}
1607END_VISP_NAMESPACE
Class to define RGB colors available for display functionalities.
Definition vpColor.h:157
static const vpColor red
Definition vpColor.h:198
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static bool getClickUp(const vpImage< unsigned char > &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static bool getPointerPosition(const vpImage< unsigned char > &I, vpImagePoint &ip)
error that can be emitted by ViSP classes.
Definition vpException.h:60
@ notInitialized
Used to indicate that a parameter is not initialized.
Definition vpException.h:74
@ dimensionError
Bad dimension.
Definition vpException.h:71
@ memoryAllocationError
Memory allocation error.
Definition vpException.h:64
void track(const vpHomogeneousMatrix &cMo)
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix & buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
vpHomogeneousMatrix inverse() const
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
double get_j() const
double get_i() const
Class which enables to project an image in the 3D space and get the view of a virtual camera.
void getImage(vpImage< unsigned char > &I, const vpCameraParameters &cam)
void setCameraPosition(const vpHomogeneousMatrix &cMt)
Definition of the vpImage class member functions.
Definition vpImage.h:131
static std::vector< std::string > splitChain(const std::string &chain, const std::string &sep)
static bool checkDirectory(const std::string &dirname)
static std::string getenv(const std::string &env)
static double rad(double deg)
Definition vpMath.h:129
static Type maximum(const Type &a, const Type &b)
Definition vpMath.h:257
static Type minimum(const Type &a, const Type &b)
Definition vpMath.h:265
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition vpPoint.h:79
double get_y() const
Get the point y coordinate in the image plane.
Definition vpPoint.cpp:429
double get_x() const
Get the point x coordinate in the image plane.
Definition vpPoint.cpp:427
void setWorldCoordinates(double oX, double oY, double oZ)
Definition vpPoint.cpp:116
vpSceneDesiredObject desiredObject
vpHomogeneousMatrix camMf2
vpHomogeneousMatrix f2Mf
@ D_CIRCLE
The object displayed at the desired position is a circle.
@ D_TOOL
A cylindrical tool is attached to the camera.
vpHomogeneousMatrix refMo
vpCameraParameters getInternalCameraParameters(const vpImage< unsigned char > &I) const
void getInternalImage(vpImage< unsigned char > &I)
void initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desiredObject)
vpCameraTrajectoryDisplayType camTrajType
void display_scene(Matrix mat, Bound_scene &sc, const vpImage< vpRGBa > &I, const vpColor &color)
void displayTrajectory(const vpImage< unsigned char > &I, const std::list< vpHomogeneousMatrix > &list_cMo, const std::list< vpHomogeneousMatrix > &list_fMo, const vpHomogeneousMatrix &camMf)
vpCameraParameters getExternalCameraParameters(const vpImage< unsigned char > &I) const
vpHomogeneousMatrix fMo
vpHomogeneousMatrix camMf
vpHomogeneousMatrix fMc
std::list< vpImagePoint > cameraTrajectory
vpHomogeneousMatrix cMo
std::list< vpHomogeneousMatrix > fMoList
std::list< vpImageSimulator > objectImage
vpImagePoint projectCameraTrajectory(const vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo, const vpHomogeneousMatrix &fMo)
@ CIRCLE
A 10cm radius circle.
@ THREE_LINES
Three parallel lines with equation y=-5, y=0, y=5.
@ ROAD
Three parallel lines representing a road.
@ SPHERE
A 15cm radius sphere.
@ CUBE
A 12.5cm size cube.
@ TIRE
A tire represented by 2 circles with radius 10cm and 15cm.
@ CYLINDER
A cylinder of 80cm length and 10cm radius.
vpHomogeneousMatrix rotz
void getExternalImage(vpImage< unsigned char > &I)
vpHomogeneousMatrix cdMo
vpHomogeneousMatrix navigation(const vpImage< vpRGBa > &I, bool &changed)
std::list< vpHomogeneousMatrix > poseList
#define vpERROR_TRACE
Definition vpDebug.h:423