26 #ifndef _BIASTHREEDOUT_HH_
27 #define _BIASTHREEDOUT_HH_
29 #include <bias_config.h>
36 #include <Base/Debug/Debug.hh>
37 #include <Base/Image/Image.hh>
38 #include <Base/Math/Vector3.hh>
39 #include <Base/Math/Vector4.hh>
40 #include <Base/Math/RGBA.hh>
41 #include <Base/Geometry/HomgPlane3D.hh>
42 #include <Base/Geometry/HomgPoint3D.hh>
43 #include <Geometry/PMatrix.hh>
44 #include <Geometry/Quadric3D.hh>
45 #include <Geometry/CovMatrix3x3.hh>
46 #include <Utils/PMatrix3DData.hh>
47 #include <Utils/TriangleMesh.hh>
48 #include <Geometry/Projection.hh>
49 #include <Geometry/ProjectionParametersBase.hh>
50 #include <Base/Geometry/PoseParametrization.hh>
52 #define GL_GLEXT_PROTOTYPES
54 #ifdef BIAS_HAVE_OPENGL
55 # include <Gui/biasgl.h>
57 # include <OpenGL/glu.h>
67 #define DEF_P_SCALE 1.0
70 #define ALPHA_TRANSPARENT 0
71 #define ALPHA_OPAQUE 255
79 #define BIAS_SELECTION_OFFSET_PMATRIX 200000
85 #define D_3DOUT_PDECOMP 0x00001000
95 const double scale=1.0) {
111 unsigned int width, height;
114 ratio = (double)width/(
double)height;
129 const double scale=1.0 ) {
130 unsigned int width, height;
132 ratio = (double)width/(
double)height;
143 const double scale=1.0) {
144 for(
unsigned int i=0; i<3; i++) {
145 H[i] = scale*R[i][0];
146 V[i] = scale*R[i][1];
147 A[i] = scale*R[i][2];
272 #ifdef BIAS_HAVE_OPENGL
322 #ifdef BIAS_HAVE_OPENGL
364 void SetParamsPointSize(
const double pointSize);
365 void SetParamsLineWidth(
const int lineWidth);
366 void SetParamsCameraScale(
double cameraScale);
368 void SetParamsDrawEllipse(
bool drawEllipse);
369 void SetParamsDrawCameraEllipse(
bool drawEllipse);
370 void SetParamsEllipsoidScale(
double ellipsoidScale);
371 void SetParamsWCSAxesLength(
double WCSAxesLength);
395 unsigned int AddText(
const std::string& thetext,
399 const double& thesize = -12.0,
428 const double& dConfidenceRegionScale = DEF_P_SCALE,
429 const bool cameraCov =
false);
437 const double& dConfidenceRegionScale = DEF_P_SCALE,
438 const bool cameraCov =
false);
464 const RGBAuc& colour = RGBAuc_WHITE_SEMI,
465 const double size = 1.0,
467 const bool wireframe =
true);
482 static void ComputePlaneCorners(
const HomgPlane3D& plane,
492 const unsigned int& width,
493 const unsigned int& height,
495 const double &dScale = DEF_P_SCALE,
496 const std::string& name =
"");
500 const unsigned int& width,
501 const unsigned int& height,
503 const double &dScale = DEF_P_SCALE,
504 const std::string& name =
"");
515 unsigned int Width,
unsigned int Height,
516 unsigned char* pData,
517 unsigned int channels = 1,
518 const std::string& name =
"",
519 bool billboard =
false)
522 return AddImage(UL, UR, LL, LR, Width, Height, pData, channels,
535 unsigned int Width,
unsigned int Height,
536 unsigned char* pData,
537 unsigned int channels = 1,
538 const std::string& name =
"",
539 bool billboard=
false);
554 const std::string& name=
"",
555 const std::string& textureOutputName =
"",
556 bool writeOutTexture =
true,
557 bool calcNormals =
false);
564 unsigned int AddProjection(
const Projection& p,
565 const RGBAuc& colorSelection =
567 const double radius = 0.1,
568 const double scale = 1.0,
569 const std::string& identifier =
"",
570 const int camera_type = -1);
574 const std::string& identifier)
576 return AddProjection(p,
586 const RGBAuc& colorSelection = RGBAuc_WHITE_OPAQUE,
587 const double radius = 0.1,
588 const double scale = 1.0,
589 const int camera_type = -1);
596 void UpdatePoint(
const unsigned int& PointIndex,
601 void UpdatePointColor(
const unsigned int& PointIndex,
605 void UpdatePoint(
const unsigned int& PointIndex,
610 void UpdatePMatrix(
const unsigned int& PIndex,
BIAS::PMatrix &P,
611 const unsigned int& width,
612 const unsigned int& height,
614 const double& dScale = DEF_P_SCALE);
617 void UpdatePMatrixColor(
const unsigned int& PIndex,
623 void UpdateLine(
const unsigned int& LineIndex,
631 void UpdateLine(
const unsigned int& LineIndex,
639 void UpdateEllipsoid(
const unsigned int& EIndex,
643 const double& dConfidenceRegionScale = DEF_P_SCALE);
648 void UpdateEllipsoid(
const unsigned int& EIndex,
652 const double& dConfidenceRegionScale = DEF_P_SCALE);
664 void RemovePoint(
const unsigned int& PointIndex);
668 void RemoveAllPoints();
672 void RemoveLine(
const unsigned int& LineIndex);
675 void RemoveAllLines();
679 void RemoveEllipsoid(
const unsigned int& EIndex);
683 void RemoveAllEllipsoids();
685 void RemoveAllCamEllipsoids();
689 void RemoveImage(
const unsigned int& EIndex);
693 void RemoveAllImages();
695 void RemoveAllIndexedFaceSets();
699 void RemovePMatrix(
int index);
703 void RemoveAllPMatrices();
709 #ifdef BIAS_HAVE_OPENGL
715 void OpenGLOutPoints();
721 void OpenGLOutPMatrices();
728 void OpenGLOutLines();
734 void OpenGLOutEllipsoids();
737 void OpenGLOutIndexedFaceSets();
743 void OpenGLOutImages(
const bool & disableBlending=
true);
757 #endif // BIAS_HAVE_OPENGL
774 virtual int WriteToFile(
const std::string &filename) {
775 return VRMLOut(filename);
780 int VRMLOut(
const std::string &sFilename);
784 int VRMLOut(
const std::string &sFilename,
const BIAS::RGBAuc &Color);
788 int VRMLOutPoints(std::ostream& vrml,
const BIAS::RGBAuc &Color);
791 int VRMLOutPoints(std::ostream& vrml);
795 int VRMLOutPMatrices(std::ostream& vrml,
const BIAS::RGBAuc &Color);
799 int VRMLOutPMatrices(std::ostream& vrml);
802 int VRMLOutPMatricesRoutine(std::ostream& VRMLFile,
807 double transparency=0.0,
808 bool CenterAsSphere=
false);
812 int VRMLOutLines(std::ostream& vrml,
const BIAS::RGBAuc &Color);
815 int VRMLOutLines(std::ostream& vrml);
819 int VRMLOutEllipsoids(std::ostream& vrml,
const BIAS::RGBAuc &Color);
823 int VRMLOutEllipsoids(std::ostream& vrml);
826 int VRMLOutImages(std::ostream& VRMLFile);
831 int VRMLOutIndexedFaceSets(std::ostream& VRMLFile);
835 int VRMLOutProjection(std::ostream& VRMLFile);
840 int VRMLOutProjectionView(std::ostream& VRMLFile);
843 int VRMLOutWriteHeader(std::ostream& vrml);
846 void VRMLOutWriteNavigationInfo(std::ostream& vrml);
850 void VRMLOutWriteViewpoint(std::ostream& vrml);
853 void VRMLOutWCS(std::ostream& vrml);
863 inline std::map< unsigned int, PMatrix3DData > & GetMapPMatrices()
865 return mapPMatrices_;
870 static double VRMLtransparency(
const unsigned char alpha);
877 void SetWriteViewpoints(
const bool & val);
882 void DrawSphere_(
double radius,
int lats,
int longs);
896 void PaintPyramid(std::ostream& VRMLFile,
897 double selectionRadius,
898 double r,
double g,
double b,
double transparency,
900 double ratio = 4.0/3.0,
902 const std::string& name =
"",
903 bool paint_lines =
false);
912 void PaintCone(std::ostream& VRMLFile,
913 double selectionRadius,
914 double r,
double g,
double b,
double transparency,
917 const std::string& name =
"");
920 #ifdef BIAS_HAVE_OPENGL
921 void OpenGLOutPMatrices_(
const BIAS::RGBAuc &Color,
bool UseOneColor);
923 #ifdef BIAS_HAVE_GLEW
924 bool glewInitialized_;
938 void VRMLOutViewPortPyramidal(std::ostream& VRMLFile,
939 double selectionRadius,
940 double r,
double g,
double b,
944 const std::string& name,
955 void VRMLOutViewPortConical(std::ostream& VRMLFile,
956 double selectionRadius,
957 double r,
double g,
double b,
960 const std::string& name,
967 void CoordinateSystem(std::ostream& VRMLFile,
968 double selectionRadius,
969 double r,
double g,
double b,
double axeslength,
971 const std::string& name =
"");
975 int VRMLOutPointsAsPointSet_(std::ostream &VRMLFile);
976 int VRMLOutPointsAsBoxes_(std::ostream &VRMLFile);
977 int VRMLOutPointsAsSpheres_(std::ostream &VRMLFile);
980 int VRMLOutPMatricesAsArrows_(std::ostream& vrml,
const BIAS::RGBAuc &Color);
981 int VRMLOutPMatricesAsMesh_(std::ostream& vrml,
const BIAS::RGBAuc &Color);
988 std::string CorrectDefString_(
const std::string& defstring);
994 std::map<unsigned int, PMatrix3DData > mapPMatrices_;
996 unsigned int NextPIndex_;
999 std::map<unsigned int, Image3DData> mapImages_;
1001 unsigned int NextImageIndex_;
1004 std::map<unsigned int, Point3DData> mapPoints_;
1006 unsigned int NextPointIndex_;
1009 std::map<unsigned int, Text3DData> mapTexts_;
1011 unsigned int NextTextIndex_;
1014 std::map<unsigned int, Line3DData> mapLines_;
1016 unsigned int NextLineIndex_;
1019 std::map<unsigned int, Ellipsoid3DData> mapEllipsoids_;
1021 unsigned int NextEllipsoidIndex_;
1024 std::map<unsigned int, Ellipsoid3DData> mapCamEllipsoids_;
1026 unsigned int NextCamEllipsoidIndex_;
1028 std::map<unsigned int, IndexedFaceSet> mapIndexedFaceSet_;
1029 unsigned int NextIndexedFaceSetIndex_;
1031 std::map<unsigned int, Projection3DData> mapProjection3D_;
1032 unsigned int NextProjection3DIndex_;
1034 bool WriteViewpoints_;
1036 std::vector<double> meanDraw;
Vector3< double > UR
upper right corner of image plane in wcs
virtual BIAS::Vector3< double > GetC() const
Get projection center.
BIAS::Image< unsigned char > texture
double dAngle
rotation in radians around RotAxes
GLsizei * facetIndicesCountArray
void Set(const BIAS::Projection &p, const double scale=1.0)
double s2
lengths of main axes
Vector3< double > LR
lower right corner of image plane in wcs
stores important data for drawing 3d text
BIAS::Vector3< double > End
Image3DData(const Image3DData &d)
Unified output of 3D entities via OpenGL or VRML.
void Set(const BIAS::PoseParametrization &p, const double scale=1.0)
stores data for drawing a the extrinisc parameters of a projection.
BIAS::Vector3< double > Point
BIAS::RGBAuc ColorOfSelection
std::string GetIdentifier() const
Return the identifier of the Projection such as a name.
unsigned int AddProjection(const Projection &p, const std::string &identifier)
interface for above
configuration struct for drawing styles of various 3d objects
BIAS::Vector3< double > RotAxis
rot to get 1st mainaxis from (1,0,0)
unsigned int AddImage(const Vector3< double > &UL, const Vector3< double > &UR, const Vector3< double > &LL, unsigned int Width, unsigned int Height, unsigned char *pData, unsigned int channels=1, const std::string &name="", bool billboard=false)
add a small rectangular image patch spanned by three 3d points small means really small (only a few p...
Vector3< double > bbmin
bounding box
int SetFromQuaternion(const Quaternion< ROTATION_MATRIX_TYPE > &q)
Set rotation matrix from a quaternion.
double WCSAxesLength
<=0 means no visual coordinate axes
Slim class bundeling pose parametrization and associated covariance matrix.
stores data for drawing a line
stores important data for drawing an el4000lipsoid
BIAS::Vector3< double > C
center of ellipsoid
stores important data for drawing a camera
Vector3< double > UL
upper left corner of image plane in wcs
std::vector< BIAS::Vector< int > > faceIndices
CameraDrawingStyle CameraStyle
bool DrawCameraUncertaintyEllipsoids
const ProjectionParametersBase * GetParameters(unsigned int cam=0) const
const parameter access function
bool DrawUncertaintyEllipsoids
This class hides the underlying projection model, like projection matrix, spherical camera...
stores datas for a textured plane
Create and represent a 3D triangle mesh.
std::vector< BIAS::Vector2< float > > texCoordSet
Vector3< double > LL
lower left corner of image plane in wcs
GLenum IndexedFaceSetPrimitiveMode
virtual BIAS::RMatrix GetR() const
Get orientation as rotation matrix R.
class for 3x3 covariance matrices
LineDrawingStyle LineStyle
std::vector< BIAS::Vector3< double > > vertexSet
BIAS::Vector3< double > Start
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
BIAS::Vector3< double > Position
void Set(const BIAS::Vector3< double > &C, const BIAS::RMatrixBase &R, const double scale=1.0)
virtual int GetImageSize(unsigned int &Width, unsigned int &Height) const
Obtain image dimensions.
Vector3< PP_TYPE > GetPosition() const
returns the position (first 3 entries) part of the pose parametrization vector
PointDrawingStyle
different styles when drawing points, e.g.
stores data for drawing a point
void Set(const BIAS::ProjectionParametersBase &p, const double scale=1.0)
Only use this if you have a single camera or a Projection with absolute Transformations of your camer...
stores data for drawing a indexed face set.
Implements a 3D rotation matrix.
int GetRotationAxisAngle(Vector3< ROTATION_MATRIX_TYPE > &axis, ROTATION_MATRIX_TYPE &angle) const
Calculates angle and rotation axis representation for this rotation matrix.
std::vector< BIAS::Vector4< unsigned char > > vertexColorSet
describes a projective 3D -> 2D mapping in homogenous coordinates
PointDrawingStyle PointStyle
Image< unsigned char > ImageData
data of texture image
Quaternion< PP_TYPE > GetOrientation() const
returns the quaternion (last 4 entries) part of the pose parametrization vector
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
Vector3< double > GetC(unsigned int cam=0) const
return Center of camera with index cam.
CameraDrawingStyle
different styles when drawing cameras, e.g.
GLfloat * TextureCoordArray
RMatrix GetR(unsigned int cam=0) const
return RMatrix of camera with index cam.
BIAS::Quaternion< double > Direction
A homogeneous plane (in P^3) All points X on the plane p fulfill p ' * X = 0.