ProjectedTextures
Prototype software for spacial augmented reality applications.
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Macros
ShaderLamps
src
Camera.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <opencv2\opencv.hpp>
4
#include <QThread>
5
#include <QSemaphore>
6
#include <QTime>
7
#include <QQueue>
8
#include <QImage>
9
#include <QMap>
10
#include <QMatrix4x4>
11
#include <QFile>
12
13
#include <ARToolKitPlus/TrackerSingleMarker.h>
14
15
using namespace
cv;
16
21
struct
Frame
{
22
Mat
content
;
23
QSemaphore*
accessCtrl
;
24
bool
mono
;
25
};
26
27
33
class
Camera
:
public
QThread
34
{
35
Q_OBJECT
36
37
public
:
46
Camera
(QString name,
int
frameWidth,
int
frameHeight,
int
targetFps,
int
bufferSize, QString calibrationFile);
47
virtual
~
Camera
(
void
);
48
void
stop();
49
void
stopAndDelete();
51
QString
getName
(){
return
name;}
52
Mat getFrameMat(
bool
grayscale=
false
);
54
QImage getFrameQImage(
bool
grayscale=
false
);
56
bool
isConnected
(){
return
connected;}
57
int
getFrameWidth
(){
return
frameWidth;}
58
int
getFrameHeight
(){
return
frameHeight;}
59
int
getFPS
(){
return
avgFPS;}
60
int
getTargetFPS
(){
return
targetFps;}
61
QString
getCalibrationFile
(){
return
calibrationFile;}
62
QMatrix4x4
getProjMat
(){
return
projMat;}
63
QMatrix4x4
getViewMat
(){
return
viewMat;}
66
protected
:
67
void
run();
68
virtual
void
grabFrame() = 0;
71
QString
name
;
72
QList<Frame>
frameBuffer
;
74
int
bufferSize
;
75
int
maxConcurrentReads
;
77
int
frameWidth
, frameHeight;
78
int
targetFps
;
79
int
curFrameIdx
;
80
QMutex
curFrameMutex
;
81
QMutex
stopMutex
;
82
volatile
bool
doStop
;
83
bool
connected
;
85
QString
calibrationFile
;
86
QMatrix4x4
projMat
;
88
QMatrix4x4
viewMat
;
91
void
submitFrame(Mat m,
bool
mono);
94
//calculate fps
95
QTime
t
;
96
int
captureTime
;
97
static
const
int
fpsQueueLength = 32;
98
QQueue<int>
fpsQueue
;
99
int
avgFPS
;
100
void
updateFPS(
int
timeElapsed);
101
102
QImage matToQImage(
const
Mat& mat);
104
public
slots:
105
void
setViewMatrix
(QMatrix4x4 viewMat){this->viewMat = viewMat;}
106
virtual
void
setExposure(
int
exposure) = 0;
107
virtual
void
setGain(
int
gain) = 0;
109
signals:
110
void
newFrame();
111
void
newFps(
int
fps);
112
};
113
Generated on Fri Feb 19 2016 11:04:41 for ProjectedTextures by
1.8.4