00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #include <QV3DCanvas>
00026
00027 QV3DPolylineF cameraWireModel(const QVEuclideanMapping3 &E3, const double base_side_length, const double height)
00028 {
00029 QV3DPolylineF p;
00030 p << QV3DPointF(0,0,0);
00031 p << QV3DPointF(-base_side_length, -base_side_length, height);
00032 p << QV3DPointF(-base_side_length, base_side_length, height);
00033 p << QV3DPointF(0,0,0);
00034
00035 p << QV3DPointF(-base_side_length, base_side_length, height);
00036 p << QV3DPointF(base_side_length, base_side_length, height);
00037 p << QV3DPointF(0,0,0);
00038 p << QV3DPointF(base_side_length, base_side_length, height);
00039 p << QV3DPointF(base_side_length, -base_side_length, height);
00040 p << QV3DPointF(0,0,0);
00041
00042 p << QV3DPointF(base_side_length, -base_side_length, height);
00043 p << QV3DPointF(-base_side_length, -base_side_length, height);
00044 p << QV3DPointF(0,0,0);
00045
00046 const QVEuclideanMapping3 E3inv = E3.inverse();
00047
00048 QV3DPolylineF result;
00049 foreach(QV3DPointF point, p)
00050 result << E3inv.apply(point);
00051
00052 return result;
00053 }
00054
00055 class SfMViewer: public QV3DCanvas
00056 {
00057 public:
00058 QList<QV3DPointF> points3D;
00059 QList<QVCameraPose> cameras;
00060
00061 void setPoints3D(const QList<QV3DPointF> &p3D)
00062 {
00063 points3D = p3D;
00064 }
00065
00066 void setCameras(const QList<QVCameraPose> &cams)
00067 {
00068 cameras = cams;
00069 }
00070
00071 SfMViewer(const QList<QVCameraPose> &cameras, const QList<QV3DPointF> &points3D, const QString &name = QString()):
00072 QV3DCanvas(name, 0.5, true),
00073 points3D(points3D), cameras(cameras)
00074 {
00075 }
00076
00077 void display()
00078 {
00079
00080 glEnable(GL_COLOR_MATERIAL);
00081 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
00082
00083 glShadeModel(GL_FLAT);
00084
00085
00086 draw2(points3D, 0.025);
00087
00088
00089 QV3DPolylineF centers;
00090 foreach(QVCameraPose cameraPose, cameras)
00091 {
00092 const QV3DPolylineF polyline = cameraWireModel(cameraPose, 0.15, 0.3);
00093 draw(polyline, Qt::red);
00094 centers << cameraPose.getCenter();
00095 }
00096 draw(centers, Qt::yellow);
00097 }
00098
00099 void draw2(const QList<QV3DPointF> &qv3DPointList, const double size)
00100 {
00101 glBegin(GL_POINTS);
00102
00103 glPointSize(size);
00104 int i = 0;
00105
00106 foreach(QV3DPointF point, qv3DPointList)
00107 {
00108 qglColor(QColor(196,196,196));
00109 glVertex3f(point.x(), point.y(), point.z());
00110 i++;
00111 }
00112 glEnd();
00113 }
00114
00115 };
00116