36 #include <OpenGLFramework/Base/glfFramebufferObject.hh>
37 #include <OpenGLFramework/SpecializedBatches/PlainPerPixelProcessing.hh>
38 #include <OpenGLFramework/RenderingContext/glfPBuffer.hh>
40 #include <Utils/Param.hh>
41 #include <Base/Image/ImageIO.hh>
42 #include <Base/Image/Image.hh>
43 #include <Utils/IOUtils.hh>
44 #include <Base/Common/FileHandling.hh>
54 bool InitTemporalWindow(
const vector<string>& filenames,
56 int& firstValidIndex,
int& lastValidIndex,
57 list<glfTexture2D*>& textureList);
58 bool ShiftWindow(
const vector<string>& filenames,
60 list<glfTexture2D*>& textureList);
62 void ClearList(list<glfTexture2D*>& textureList);
65 int main(
int argc,
char* argv[]) {
69 string* shaderFile = params.
AddParamString(
"shader",
"shader to be loaded");
70 string* outputPrefix = params.
AddParamString(
"outputPrefix",
"",
"",
'o');
71 string* inputFileNameList = params.
AddParamString(
"inputFileNameList",
74 int* temporalWindowHalfSize =
75 params.
AddParamInt(
"tempHW",
"half win size of the temporal window", 0, 0);
83 if(inputFileNameList->size() == 0 ) {
84 BIASERR(
"some input image list is required!");
87 vector<string> filenames;
89 BIASERR(
"error parsing image list!");
98 list<glfTexture2D*> textureList;
117 int firstValidIndex, lastValidIndex;
120 if(! InitTemporalWindow(filenames,
121 *temporalWindowHalfSize,
122 firstValidIndex, lastValidIndex,
127 unsigned int width = textureList.front()->GetWidth();
128 unsigned int height = textureList.front()->GetHeight();
133 outputTexture.
Allocate(width, height, GL_RGB);
144 gpuProcess.SetRenderTarget(&fbo);
145 gpuProcess.SetOutputSize(width, height);
146 gpuProcess.SetFragmentShaderFromFile(*shaderFile);
150 int i = firstValidIndex;
153 gpuProcess.SetTextures(textureList);
154 gpuProcess.Execute();
156 string path, base, suffix;
158 ImageIO::Save(path+(*outputPrefix)+base+suffix, outputImage);
159 cout<<
" -> "<< filenames[i] <<endl;
161 if(!ShiftWindow(filenames, i, textureList) )
165 }
while(i<lastValidIndex);
168 ClearList(textureList);
173 ClearList(textureList);
178 ClearList(textureList);
193 bool InitTemporalWindow(
const vector<string>& filenames,
195 int& firstValidIndex,
int& lastValidIndex,
196 list<glfTexture2D*>& textureList)
200 const int winElements = halfWinSize*2+1;
201 const int allElements =
static_cast<int>(filenames.size());
202 if( winElements > allElements ) {
203 BIASERR(
"temporal window and number of filenames do not fit!");
206 firstValidIndex = halfWinSize;
207 lastValidIndex = allElements - 1 - halfWinSize;
212 for(
int i=0; i<winElements; i++) {
214 BIASERR(
"error loadin image "<<filenames[i]);
218 textureList.front()->Create();
219 textureList.front()->Set();
220 textureList.front()->UploadImage(tmpImg);
227 bool ShiftWindow(
const vector<string>& filenames,
229 list<glfTexture2D*>& textureList)
233 BIASERR(
"error loadin image "<<filenames[currentIndex]);
239 textureList.front()->Create();
240 textureList.front()->Set();
241 textureList.front()->UploadImage(tmpImg);
242 delete textureList.back();
243 textureList.pop_back();
248 void ClearList(list<glfTexture2D*>& textureList) {
249 list<glfTexture2D*>::iterator it=textureList.begin();
250 for(;it!=textureList.end(); it++) {
void Allocate(int width, int height, GLenum internalFormat, int mipmap=0)
Creates a texture with undefined content.
void AttachTexture(const glfTexture &texture, GLenum attachmentPoint, int attachedMipMapLevel=0, int zSlice=0, GLenum cubeMapSide=0)
Attaches a texture to an attachment point which can be.
void Create()
Creates the texture but does not upload any data yet.
void CopyToImage(ImageBase &image, int mipmap=0)
Copies the pixels of a mipmap of the texture to a BIAS::ImageBase.
Exception class used for run-time errors in the OpenGLFramework.
virtual void Destroy()
Uninitializes the rendering context.
const std::string & GetMessageString() const
Returns the description of the error including the file name and line number where the error occured...
void CheckComplete() const
Checks whether the framebuffer object is supported in its current state.
static void SplitName(const std::string &fullname, std::string &dir, std::string &base, std::string &suffix)
Split full path into:
GLX pbuffer rendering context.
Class rendering quad and executing a fragment shader.
static int ParseListFile(const std::string &ListFileName, std::vector< std::string > &LinesInFile)
Extracts lines from passed file.
static bool ParseCommandLineEvalHelp(Param ¶ms, int argc, char *argv[])
parses the command line, adds parameter "help"
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.
virtual void Init(const glfRenderingContextConfig &config)
Initializes the rendering context with the given configuration.
This class Param provides generic support for parameters.
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
void Set(GLenum minFilter=GL_NEAREST, GLenum magFilter=GL_NEAREST, GLenum wrapS=GL_CLAMP, GLenum wrapT=GL_CLAMP, GLint textureNr=GL_TEXTURE0)
Convenience wrapper.
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
void ClearColorBuffer(float red=0.0f, float green=0.0f, float blue=0.0f, float alpha=0.0f)
Clears the color buffer of the render target with the given color.
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.
void Create()
Creates the framebuffer object.