43 #include <Base/Image/ImageConvert.hh>
45 #include <OpenGLFramework/RenderingContext/glfPBuffer.hh>
46 #include <OpenGLFramework/SpecializedBatches/MultipleDepthWarp.hh>
47 #include <OpenGLFramework/Base/glfException.hh>
49 #include <Utils/Param.hh>
50 #include <Utils/IOUtils.hh>
51 #include <Base/Image/ImageIO.hh>
52 #include <Base/Image/Image.hh>
53 #include <Image/Camera.hh>
54 #include <Filter/Gauss.hh>
55 #include <Base/Debug/TimeMeasure.hh>
56 #include <OpenGLFramework/SpecializedBatches/DisparityInterpolator.hh>
57 #include <OpenGLFramework/SpecializedBatches/SeparabelBoxFilter.hh>
58 #include <Filter/Rescale.hh>
59 #include <Filter/Median.hh>
61 #include <Gui/biasgl.h>
68 unsigned int width, height;
71 cout << ppp->
GetK() << endl;
74 HomgPoint2D rightBottom((
double)width-0.5, (
double) height - 0.5,1);
80 d1 = (d1 / d1[2]) * distFromCam;
87 d2 = (d2 / d2[2]) * distFromCam;
95 cout << ppp->
GetK() << endl;
100 int main(
int argc,
char* argv[]) {
103 string* firstDepthImageName = params.
AddParamString(
"firstDepthImage",
104 "image of first source camera",
"",
'f');
105 string* secondDepthImageName = params.
AddParamString(
"secondDepthImage",
106 "image of second source camera",
"",
's');
113 string* textureForTheFirstSourceProj = params.
AddParamString(
"projectiveTexture",
114 "texture for the first source proj",
"",
'p');
117 "projection with params of target perspective cam",
"",
't');
118 string* firstSourceProjName = params.
AddParamString(
"firstSourceProj",
119 "projection with params of first source cam",
"",
'a');
120 string* secondSourceProjName = params.
AddParamString(
"secondSourceProj",
121 "projection with params of second source cam",
"",
'b');
130 if (!IOUtils::ParseCommandLineEvalHelp(params, argc, argv))
133 vector<ProjectionParametersPerspectiveDepth> pmdParams;
135 vector<Projection> sourceProjs;
138 if ((*firstSourceProjName).compare(
"")!=0) {
140 if (sourceProjs.back().Load(*firstSourceProjName) != 0) {
141 BIASERR(
"Could not load source tof projection: "<<*firstSourceProjName);
146 if ((*secondSourceProjName).compare(
"")!=0) {
148 if (sourceProjs.back().Load(*secondSourceProjName) != 0) {
149 BIASERR(
"Could not load source tof projection: "<<*secondSourceProjName);
154 if (targetProj.
Load(*targetProjName) != 0) {
155 BIASERR(
"Could not load target tof projection:"<<*targetProjName);
160 if ((*firstDepthImageName).compare(
"")!=0) {
161 if (ImageIO::Load(*firstDepthImageName, firstDepthMap)) {
162 BIASERR(
"Could not load first depth map :"<< *firstDepthImageName);
166 if ((*secondDepthImageName).compare(
"")!=0) {
167 if (ImageIO::Load(*secondDepthImageName, secondDepthMap)) {
168 BIASERR(
"Could not load second depth map :"<< *secondDepthImageName);
175 if ((*textureForTheFirstSourceProj).compare(
"")!=0) {
176 if (ImageIO::Load(*textureForTheFirstSourceProj, projTexture)) {
177 BIASERR(
"Could not load second depth map :"<< *textureForTheFirstSourceProj);
190 ppp->
Rescale((
unsigned int)960, (
unsigned int) 540);
199 source0_ppp->
Rescale((
unsigned int) 960, (
unsigned int) 540);
202 BIASERR(
"target parameters are not from type perspective");
212 gaussFilter.
Filter(firstDepthMap,tmpDepthMap);
213 firstDepthMap = tmpDepthMap;
238 mpmdWarp.
Init(*ppp, sourceProjs);
257 cout <<
"frame rate = " << (1000.0 / (tm.
GetRealTime() / 1000000.0)) << endl;
268 ((*textures)[0])->CopyToImage(warpedColor);
270 ImageIO::Save(
"colorImage1.png",warpedColor);
virtual BIAS::Vector3< double > GetC() const
Get projection center.
int SetProjectiveTextureCam(const ProjectionParametersPerspective &textureCam)
sets the parameters for the camera for projective texturing this camera will be used to project the t...
void Print(std::ostream &os=std::cout) const
int SetIntrinsics(double minPhi, double maxPhi, double minTheta, double maxTheta, double angleStep, double aspectratio=1.0)
Method calculates K-Matrix and image size from specified angles.
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
virtual int Load(const std::string &filename)
convenience wrapper which tries to read different formats
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
void SetHalfWinSize(const int hws, bool AdjustSigma=true)
define the half win size of the kernel, if AdjustSigma is true sigma is computed according to the cut...
double * AddParamDouble(const std::string &name, const std::string &help, double deflt=0.0, double min=-DBL_MAX, double max=DBL_MAX, char cmdshort=0, int Group=GRP_NOSHOW)
void SetDispForDistance(const float &dist_from_cam, const float &disp)
if disparity output is required, then points with the distance (dist_from_cam) will get disparity (di...
int SetupNViewsWarp(const double &distToScreen, const double &zoom, const double &shift, unsigned int numberOfViews, unsigned int centralViewIndex, bool separate=true)
Exception class used for run-time errors in the OpenGLFramework.
virtual void Destroy()
Uninitializes the rendering context.
int UploadDepthMap(Image< float > &depthMap, unsigned int index)
uploads the given depthMap to the gpu as texture depthMap is a depth map from source camera i ...
const std::string & GetMessageString() const
Returns the description of the error including the file name and line number where the error occured...
const ProjectionParametersBase * GetParameters(unsigned int cam=0) const
const parameter access function
This class hides the underlying projection model, like projection matrix, spherical camera...
void SetZNearAndZFar(const float &zNear, const float &zFar)
this function sets near and far clipping planes for the target camera default parameters defined in t...
GLX pbuffer rendering context.
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
sets gauss kernel if params changed and calls convolution or fast grey implementation if possible ...
virtual int GetImageSize(unsigned int &Width, unsigned int &Height) const
Obtain image dimensions.
double GetRealTime() const
return real time (=wall time clock) in usec JW For Win32: real-time is measured differently from user...
virtual BIAS::KMatrix GetK() const
void SetWarpType(WARPING_TYPE type)
virtual void Init(const glfRenderingContextConfig &config)
Initializes the rendering context with the given configuration.
This class Param provides generic support for parameters.
int Init(const ProjectionParametersPerspective &targetCam, std::vector< Projection > &sourceCameras, bool createDepthMaps=true)
void SetDepthScaleBeforeWarping(float scale)
void SetDiscardAngle(float degree)
void UseProjectiveTexturing(bool enable)
enable or disables use of projective texturing
int Flip()
flips the image vertically (row order is inverted) In place function return 0 in case of success...
std::vector< glfTexture2D * > * GetResultTexturesFromNViewWarp()
void UploadProjectiveTexture(const Image< unsigned char > &projectiveTexture)
uploads the image which will be used for projective texturing of the scene to the corresponding textu...
virtual void UnProjectLocal(const HomgPoint2D &pos, Vector3< double > &pointOnRay, Vector3< double > &direction, bool IgnoreDistortion=false) const
calculates the viewing ray from the camera center (in the camera coordinate system) which belongs to ...
virtual void Rescale(double ratio, const double offset=0.0)
Adapt internal parameters to resampled image.
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)
Configuration for a rendering context.
virtual void SetC(const BIAS::Vector3< double > &C)
Set projection center.
class TimeMeasure contains functions for timing real time and cpu time.