Example for generating a trianglemesh from an image , ThreeDOut
- Author
- MIP
#include <Utils/TriangleMesh.hh>
#include <Utils/ThreeDOut.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Image/ImageConvert.hh>
#include <Image/HomographyMapping.hh>
#include <iostream>
using namespace std;
using namespace BIAS;
void usage(char* name)
{
cout<<"usage:\n";
cout<<name<<" <depthmap> <texture> [outputFile]\n";
}
int main(int argc, char* argv[])
{
if(argc<2) {
usage(argv[0]);
return -1;
}
if(ImageIO::Load(argv[1], depthMap)!=0) {
cout<<"depth map could not be loaded!\n";
usage(argv[0]);
return -1;
}
ImageConvert::ConvertST(depthMap, source, ImageBase::ST_float);
H[0][0]=H[1][1]=0.5;
HMapper.
Map(source, enlarged);
if(ImageIO::Load(argv[2], texture)!=0) {
cout<<"texture could not be loaded!\n";
usage(argv[0]);
return -1;
}
cout<<"meshing..."; cout.flush();
cout<<"finished\n";
argv[2], false);
cout<<"Writing VRML to ";
if(argc>3) {
cout<<argv[3]<<"... ";cout.flush();
}
else {
cout<<"DenseTriangleMesh.wrl... ";cout.flush();
vrmlOut.
VRMLOut(
"DenseTriangleMesh.wrl");
}
cout<<"finished\n";
return 0;
}