00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef StereoEngine_H
00020 #define StereoEngine_H
00021
00022 #include "cv.h"
00023 #include "cxmisc.h"
00024 #include "highgui.h"
00025 #include <vector>
00026 #include <string>
00027 #include <algorithm>
00028 #include <stdio.h>
00029 #include <ctype.h>
00030 #include <iostream>
00031 #include "uvsim/sensing/Camera.h"
00032 #include <osg/StateAttribute>
00033 #include <osg/BlendFunc>
00034 #include "pthread.h"
00035 #include <osgViewer/Viewer>
00036
00037 namespace uvsim
00038 {
00039
00040 class StereoEngine
00041 {
00042 public:
00043 static const int winSize = 10;
00044 static const int maxCount = 20;
00045 static const double quality = 0.01;
00046 static const double minDistance = 10;
00047 pthread_t viewerThread;
00048 osgViewer::Viewer viewer;
00049
00050
00051 IplImage *leftImage, *rightImage, *leftGreyR, *rightGreyR,
00052 *leftGrey, *rightGrey, *eig, *temp, *threeD, *leftImageR;
00053 CvPoint2D32f *points[2];
00054 CvMat *Q, *F, *R1, *R2, *P1, *P2, *M1, *M2, *D1, *D2,
00055 *mx1, *my1, *mx2, *my2, *pair, *R, *T, *E, *disp, *vdisp, *img1r, *img2r, *realDisp;
00056
00057 CvStereoBMState *BMState;
00058
00059
00060 IplImage *frameL, *frameR;
00061
00062
00063
00064 int pointCount;
00065 CvSize imageSize;
00066 std::vector<std::string> imageNames[2];
00067 public:
00068 StereoEngine(IplImage *frameL, IplImage *frameR);
00069 virtual ~StereoEngine();
00070 void captureCalibrationImages(int number);
00071 static void stereoCalibrate(std::string imageList, int nx, int ny, int useUncalibrated);
00072 void findDisparity();
00073 void displayDisparity();
00074 IplImage* reprojectTo3d();
00075 void drawPointCloud();
00076 osg::StateSet* makeStateSet(float size);
00077 void loadMatrices();
00078 void capture();
00079 void drawPoints(int index);
00080 };
00081
00082 }
00083
00084 #endif
00085
00086