1 #include "Image/SphericalDepthPanorama.hh"
2 #include <Base/Image/ImageConvert.hh>
3 #include <Base/Image/ImageIO.hh>
4 #include <Filter/Rescale.hh>
5 #include "Utils/ThreeDOut.hh"
6 #include <bias_config.h>
15 bFirstPoseSet_ =
false;
16 pSphericalProj_ = NULL;
17 bTextureFilled_ =
false;
18 pInitialProj_ = initialProjection_;
19 if (pInitialProj_ != NULL) {
21 pSphericalProj_->GetParameters()->GetImageSize(panoramaWidth_,panoramaHeight_);
22 panorama_.Init(panoramaWidth_,panoramaHeight_,1);
23 panoramaHitCount_.Init(panoramaWidth_,panoramaHeight_,1);
24 panoramaHitCount_.FillImageWithConstValue(0.0);
25 panoramaTexture_.Init(panoramaWidth_,panoramaHeight_,1);
28 pSphericalProj_->GetParameters()->SetQC(pInitialProj_->GetQ(),
29 pInitialProj_->GetC());
30 bFirstPoseSet_ =
true;
40 delete pSphericalProj_;
41 pSphericalProj_ = NULL;
52 pSphericalProj_->GetParameters()->GetImageSize(panoramaWidth_,panoramaHeight_);
53 panorama_.Init(panoramaWidth_,panoramaHeight_,1);
54 panoramaHitCount_.Init(panoramaWidth_,panoramaHeight_,1);
55 panoramaHitCount_.FillImageWithConstValue(0.0);
56 panoramaTexture_.Init(panoramaWidth_,panoramaHeight_,1);
59 pSphericalProj_->GetParameters()->SetQC(p.
GetQ(),
61 bFirstPoseSet_ =
true;
67 float **idaP = panorama_.GetImageDataArray();
68 float **idaPHC = panoramaHitCount_.GetImageDataArray();
69 unsigned char ** idaTex = panoramaTexture_.GetImageDataArray();
78 for(
int x=0;x<width;x++){
79 for(
int y=0;y<height;y++){
80 depthValue = ida[y][x];
81 if (depthValue > 0.0) {
85 bTextureFilled_ =
true;
87 if(idaPHC[y][x] == 0.0){
88 idaP[y][x]=depthValue;
93 (idaP[y][x] * idaPHC[y][x]+depthValue)/(idaPHC[y][x]+1);
157 texture = panoramaTexture_;
174 if(pSphericalProj_ != NULL){
177 BIAS::Image<float> depthDownSampled_(panoramaWidth_ / factor, panoramaHeight_ / factor);
179 pRescaleFilter_.
SetFactor((
float)factor);
181 pRescaleFilter_.
Filter(panorama_, depthDownSampled_);
182 int width = depthDownSampled_.
GetWidth();
183 int height = depthDownSampled_.
GetHeight();
191 for (
int x=0;x<width;x++) {
192 for (
int y=0;y<height;y++) {
193 if (idaD[y][x] < 10.0)
195 float minDepth_ = idaD[y][x];
196 float maxDepth_ = idaD[y][x];
197 for (
int xw=x-1;xw<=x+1;xw+=1) {
198 for (
int yw=y-1;yw<=y+1;yw+=1) {
199 if (xw >= 0 && yw >= 0 && xw < width && yw < height) {
200 if (idaD[yw][xw] > maxDepth_)
201 maxDepth_ = idaD[yw][xw];
202 if (idaD[yw][xw] < minDepth_)
203 minDepth_ = idaD[yw][xw];
207 if (maxDepth_ - minDepth_ < 1000.0)
208 idaF[y][x] = idaD[y][x];
211 depthDownSampled_ = filteredDepthMap_;
216 #ifdef BIAS_HAVE_XML2
217 proj.
XMLWrite(
"Panorama_Projection.xml");
219 BIASERR(
"Could not save because of missing XML support in BIAS.");
223 proj.
Rescale(1.0f/
float(factor));
240 if(pSphericalProj_ != NULL){
243 panoramaWidth_,panoramaHeight_);
int GetPanorama(BIAS::Image< float > &image, BIAS::Image< unsigned char > &texture)
int GenerateDenseMesh(const BIAS::Image< float > &DenseDepthMap, const BIAS::Image< unsigned char > &Texture)
Calculate a triangle mesh from dense depth map without PMatrix.
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
int ScaleShiftBetween(double Min, double Max)
scales and shifts image so afterwards every pixel has a value between Min and Max ...
void SetLowPassType(int lpt)
Sets the lowpass filter by a lowpass filter type.
void Rescale(float ratio, unsigned int cam=0)
adapt internal params to resampled image
Down-, Upsampling routines and Resize.
unsigned int GetWidth() const
BIAS::Quaternion< double > GetQ(unsigned int cam=0) const
return rotation quaternion of camera with index cam if cam>0 this is a relative pose in the coordinat...
This class hides the underlying projection model, like projection matrix, spherical camera...
int ProcessSphericalProjection(BIAS::Image< float > &depthMap, BIAS::Projection &p, BIAS::Image< unsigned char > *texture=NULL)
Call Process to update the measurement.
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
int XMLWrite(const std::string &Filename, int CompressionLevel=0, bool AutoAddCompressionSuffix=true, std::string encoding="UTF-8") const
call this to add the class to a new xml tree and write it to the file Filename.
Create and represent a 3D triangle mesh.
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
scales the src to dst using the downsampling factor from SetFactor()
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.
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
~SphericalDepthPanorama()
Destructor.
(8bit) unsigned char image storage type
int GetTriangleMesh(BIAS::TriangleMesh &mesh)
Vector3< double > GetC(unsigned int cam=0) const
return Center of camera with index cam.
SphericalDepthPanorama(Projection *initialProjection_=NULL)
Constructor with default params.
void SetFactor(double factor)
the downsampling factor
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase