MeVisLab Resolution Independence API
FrameGrabber.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef FRAME_GRABBER_H
14#define FRAME_GRABBER_H
15
17
18#include "SoViewers.h"
19
21#define FRAMEGRABBER_MAX_BYTES 1024*1024*50
22
25#define FRAMEGRABBER_CROP 0xfffc
26
27class SoSFString;
28
29//=============================================================
31/*
32FrameGrabber is a helper class that handles the creation
33of a movie by storing GL frames from a passed SoQtRenderArea
34whenever requested. It stores the images in memory and writes
35them on disk when requested or when too much memory is consumed.
36It is used by \c SoRenderArea.
37
38
39*/
40//=============================================================
42{
43public:
46
48 void cleanup(bool deleteFiles);
49
52 void createAviWithBink(const char* filename,float framerate);
53
56
58 void stopRecording() { _isRecording = false; }
59
61 bool isRecording() { return _isRecording; }
62
64 void grabFrame(void* renderarea, int mode=GL_BACK);
65
68
70 void setMaximumBytes(long bytes) { _maxBytes = bytes; }
71
73 long getMaximumBytes() { return _maxBytes; }
74
76 int getDiskFrames() { return _diskCount; };
77
79 int getMemFrames() { return static_cast<int>(_frames.size()); };
80
82 void setStatusField(SoSFString* field, SoNode* owner) { _status = field; _statusNode = owner; };
83
85 void updateStatus(const char* string);
86
88 void writeCurrentFrameToDisk(const char* name, void* renderarea ,int mode);
89
91 MLuint8* grabGLFrame(void* renderarea , int& w, int& h, int mode = GL_BACK);
92
93 // returns the filename template (without image number & .tif)
94 std::string getFileNameTemplate();
95
96private:
98 void writeToFile(const char* name, MLuint8* data, int width, int height);
99
101 void createUniqueDirectory();
102
104 std::string intToString(int value);
105
107 int _uniqueDirCount;
108
110 int _diskCount;
112 int _bufferCount;
113
115 bool _dirCreated;
116
118 bool _isRecording;
119
121 std::string _tmpDir;
122
124 int _width,_height;
125
127 std::vector<MLuint8*> _frames;
128
130 long _maxBytes;
132 long _bytes;
133
135 SoSFString* _status;
137 SoNode* _statusNode;
138};
139
140#endif
#define SO_VIEWERS_CLASS_SPEC
Definition SoViewers.h:43
FrameGrabber class grabs GL frames for movie generation.
int getMemFrames()
get current mem frame number
MLuint8 * grabGLFrame(void *renderarea, int &w, int &h, int mode=GL_BACK)
returns new buffer with content of gl framebuffer
int getDiskFrames()
get current disk frame number
void createAviWithBink(const char *filename, float framerate)
create AVI out of stored frames (requieres binkconv.exe to be in the PATH)
void cleanup(bool deleteFiles)
cleanup memory, if deleteFiles is set, it also deletes all temporary files
void setMaximumBytes(long bytes)
set the maximum number of bytes stored in memory for movie frames
void stopRecording()
stop recording
void grabFrame(void *renderarea, int mode=GL_BACK)
grab a single gl frame, (mode is GL_FRONT or GL_BACK, front contains windows and mouse also)
void writeCurrentFrameToDisk(const char *name, void *renderarea, int mode)
grabs the current frame and writes to disk
void startRecording()
start recording at 0
long getMaximumBytes()
get the maximum number of bytes stored in memory for movie frames
std::string getFileNameTemplate()
void setStatusField(SoSFString *field, SoNode *owner)
set status field
bool isRecording()
flag if currently a record session is running
void updateStatus(const char *string)
update status
void writeToFiles()
write stored images to temp disk