1 #include <Base/Common/BIASpragma.hh>
2 #include <bias_config.h>
8 #include <Base/Image/ImageBase.hh>
9 #include <Base/Image/ImageIO.hh>
10 #include <Geometry/Projection.hh>
11 #include <Utils/TriangleMesh.hh>
12 #include <Utils/ThreeDOut.hh>
13 #include <Base/Image/ImageConvert.hh>
14 #include <Base/Math/Vector3.hh>
15 #include <Filter/Gauss.hh>
17 #ifdef BIAS_HAVE_OPENSCENEGRAPH
18 #include <GLviewer/ThreeDOutOpenSceneGraph.hh>
25 void usage(
int argc,
char* argv[]);
26 void GenerateCheckerboard(
int size,
int xCorners,
int yCorners);
27 void GenerateIntensityTestCheckerboard(
int size,
int xCorners,
int yCorners,
float maxDev);
36 int main (
int argc,
char *argv[])
43 bool intensity =
false;
46 int cols = atoi(argv[1]);
47 int rows = atoi(argv[2]);
48 int size = atoi(argv[3]);
50 if(argc > 4) intensity = bool(atoi(argv[4]) != 0);
51 if(argc > 5) maxDev = atof(argv[5]);
55 cout<<
"Intensity with MaxDev:"<<maxDev<<endl;
56 GenerateIntensityTestCheckerboard(size,cols, rows, maxDev);
59 cout<<
"Standard:"<<endl;
60 GenerateCheckerboard(size,cols, rows);
64 void usage(
int argc,
char* argv[])
66 cout<<
"This program will create a checkerboard model and write it to a file checkerboard.wrl. "<<
67 "If OpenSceneGraph support is activated in BIAS it will also write corresponding files with "<<
68 "suffixes .ive, .3ds .osg\n";
69 cout<<
"ATTENTION: The ThreeDOut.AddImage() method has a bug therefore the textures in models .ive, .3ds and "<<
70 ".osg models are wrong. (ischiller 29/06/2011).\n\n";
71 cout<<
"Usage:"<<argv[0]<<
" cols rows size [intensityVariable] [maxDeviation]\n"<<endl;
74 void GenerateCheckerboard(
int size,
int xCorners,
int yCorners){
79 unsigned int factor = 20;
87 black.
Init(factor,factor,1);
89 white.
Init(factor,factor,1);
94 unsigned newWidth=(unsigned)((xCorners+1)*factor);
95 unsigned newHeight=(unsigned)((yCorners+1)*factor);
97 image.
Init(newWidth,newHeight,1);
99 bool topLeftBlack =
true;
100 bool isBlack = topLeftBlack;
102 for(
int y=0;y < yCorners+1; y++){
103 for(
int x= 0;x< xCorners+1 ; x++){
105 if((y % 2) == 0 && x == 0)
106 isBlack = topLeftBlack;
108 isBlack = !topLeftBlack;
132 unsigned xSize = (unsigned)rint(image.
GetWidth());
133 unsigned ySize = (unsigned)rint(image.
GetHeight());
134 threedout.
AddImage(ul, ur,ll,lr,xSize ,ySize,pData,1,
"cb",
false);
136 threedout.
VRMLOut(
"checkerboard.wrl");
137 #ifdef BIAS_HAVE_OPENSCENEGRAPH
139 t3dOSG.
AddImage(ul, ur,ll,lr,xSize ,ySize,pData,1,
"cb",
false);
147 void GenerateIntensityTestCheckerboard(
int size,
int xCorners,
int yCorners,
float maxDev)
154 unsigned int factor = 20;
162 black.
Init(factor,factor,1);
164 grey80.
Init(factor,factor,1);
166 grey60.
Init(factor,factor,1);
168 grey40.
Init(factor,factor,1);
170 grey20.
Init(factor,factor,1);
172 white.
Init(factor,factor,1);
176 if(maxDev<=0) maxDev =0.0;
177 blackD.
Init(factor,factor,1);
179 grey80D.
Init(factor,factor,1);
181 grey60D.
Init(factor,factor,1);
183 grey40D.
Init(factor,factor,1);
185 grey20D.
Init(factor,factor,1);
187 whiteD.
Init(factor,factor,1);
191 unsigned newWidth=(unsigned)((xCorners+1)*factor);
192 unsigned newHeight=(unsigned)((yCorners+1)*factor);
194 image.
Init(newWidth,newHeight,1);
195 imageD.
Init(newWidth,newHeight,1);
197 bool topLeftBlack =
true;
198 bool isBlack = topLeftBlack;
199 unsigned blackCounter=0;
200 for(
int y=0;y < yCorners+1; y++){
201 for(
int x= 0;x< xCorners+1 ; x++){
203 if((y % 2) == 0 && x == 0){
204 isBlack = topLeftBlack;
207 isBlack = !topLeftBlack;
220 if( y!=0 && y!=yCorners && x != 0 && x!=xCorners){
221 switch(blackCounter){
243 BIASERR(
"blackCounter out of bounds");
246 if(blackCounter == 5)
278 unsigned xSize = (unsigned)rint(image.
GetWidth());
279 unsigned ySize = (unsigned)rint(image.
GetHeight());
281 threedout.
AddImage(ul, ur,ll,lr,xSize ,ySize,pData,1,
"cb",
false);
282 threedout.
VRMLOut(
"checkerboard_distorted.wrl");
284 #ifdef BIAS_HAVE_OPENSCENEGRAPH
286 t3dOSG.
AddImage(ul, ur,ll,lr,xSize ,ySize,pData,1,
"cb",
false);
void Release()
reimplemented from ImageBase
int VRMLOut(const std::string &sFilename)
flush all 3d objects to a vrml file with name sFilename, this is the function most users would call ...
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
int OpenSceneGraphOut(const std::string &filename) const
save ThreeDOut object as OpenSceneGraph saves an Open Scene Graph and the needed textures ...
Unified output of 3D entities via OpenGL or VRML.
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...
unsigned int GetWidth() const
unsigned int GetHeight() const
void FillImageWithConstValue(StorageType Value)
fill grey images
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
a class for exporting ThreeDOut objects to OSG scene graphs
class Vector3 contains a Vector of fixed dim.
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
int Paste2ROI(const ImageBase &Image)
paste Image to current ROI
int SetROICorners(unsigned int UpperLeftX, unsigned int UpperLeftY, unsigned int LowerRightX, unsigned int LowerRightY)