MeVisLab Resolution Independence API
Loading...
Searching...
No Matches
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
59 {
60 _isRecording = false;
61 }
62
65 {
66 return _isRecording;
67 }
68
70 void grabFrame(void* renderarea, int mode = GL_BACK);
71
74
76 void setMaximumBytes(long bytes)
77 {
78 _maxBytes = bytes;
79 }
80
83 {
84 return _maxBytes;
85 }
86
89 {
90 return _diskCount;
91 };
92
95 {
96 return static_cast<int>(_frames.size());
97 };
98
100 void setStatusField(SoSFString* field, SoNode* owner)
101 {
102 _status = field;
103 _statusNode = owner;
104 };
105
107 void updateStatus(const char* string);
108
110 void writeCurrentFrameToDisk(const char* name, void* renderarea, int mode);
111
113 MLuint8* grabGLFrame(void* renderarea, int& w, int& h, int mode = GL_BACK);
114
115 // returns the filename template (without image number & .tif)
116 std::string getFileNameTemplate();
117
118private:
120 void writeToFile(const char* name, MLuint8* data, int width, int height);
121
123 void createUniqueDirectory();
124
126 std::string intToString(int value);
127
129 int _uniqueDirCount;
130
132 int _diskCount;
134 int _bufferCount;
135
137 bool _dirCreated;
138
140 bool _isRecording;
141
143 std::string _tmpDir;
144
146 int _width, _height;
147
149 std::vector<MLuint8*> _frames;
150
152 long _maxBytes;
154 long _bytes;
155
157 SoSFString* _status;
159 SoNode* _statusNode;
160};
161
162#endif
#define SO_VIEWERS_CLASS_SPEC
Definition SoViewers.h:44
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)
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