-
Notifications
You must be signed in to change notification settings - Fork 2
/
vpStereoCamera.h
125 lines (95 loc) · 2.66 KB
/
vpStereoCamera.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "stdafx.h"
#ifndef __VPSTEREOCAMERA_H__
#define __VPSTEREOCAMERA_H__
using namespace cv;
#define DEF_WIDTH 1600
#define DEF_HEIGHT 1200
//#define DEF_WIDTH 800
//#define DEF_HEIGHT 600
#define DEF_FPS 30
class vpStereoCamera
{
public:
bool init(); // returns whether successfully found cameras
bool init(int w, int h); // override for resolution set
// public so we can reload when done calibrating
void loadCalibration(); // load our calibration data
// check for new data, return true if new image for both cameras
bool pollCamera();
// get pointer to images (that is not meant to be changed)
const cv::Mat getImageLeft()
{ return imgLeft; }
const cv::Mat getImageRight()
{ return imgRight; }
// get pointer to converted grayscale images (that is not meant to be changed)
const cv::Mat getGrayLeft()
{ return imgGrayLeft; }
const cv::Mat getGrayRight()
{ return imgGrayRight; }
// project and unproject points to/from screen
void project(const vector<Point3f>& worldPoints, bool isLeft, vector<Point2f>& coords);
// note that this one is a ray from a particular camera position
void unproject(const vector<Point2f>& coords, bool isLeft, vector<Point3f>& worldPoints);
// transform from left-to-right coordinate system and vice versa
Point3f LtoR(Point3f pt);
Point3f RtoL(Point3f pt);
// get right camera pos
Point3f RPos()
{ return rCamPos; }
// set verbosity level
void setVerbose(bool _verbose)
{
this->verbose = _verbose;
VI.setVerbose(_verbose);
}
// show the camera settings window
void showSettingsLeft()
{ VI.showSettingsWindow(deviceLeft); }
void showSettingsRight()
{ VI.showSettingsWindow(deviceRight); }
vpStereoCamera() : newDataLeft(false), newDataRight(false)
{
verbose = true;
VI.setVerbose(true);
}
~vpStereoCamera();
private:
// internal videoInput object
videoInput VI;
// device numbers
int deviceLeft;
int deviceRight;
// camera dimensions
int width;
int height;
// and number of pixels
int imgSize;
// camera projection and distortion data, loaded from file
cv::Mat intrinsic_L;
cv::Mat intrinsic_R;
cv::Mat distortion_L;
cv::Mat distortion_R;
// rotation and translation info. identity for left camera.
cv::Mat rot_L;
cv::Mat rot_R;
cv::Mat rotV_L;
cv::Mat rotV_R;
cv::Mat trans_L;
cv::Mat trans_R;
// position of right camera, in left's frame
Point3f rCamPos;
// internal buffer
unsigned char* buffer;
// internal IplImages
cv::Mat imgLeft;
cv::Mat imgRight;
// grayscale IplImages
cv::Mat imgGrayLeft;
cv::Mat imgGrayRight;
// which cameras have we received new data for
bool newDataLeft;
bool newDataRight;
// display debug info in console/log
bool verbose;
};
#endif