PCamera.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef PCamera_H_DEFINED
00039 #define PCamera_H_DEFINED
00040
00041
00042
00043 #include "Image/Image.H"
00044 #include "Image/ImageSet.H"
00045 #include "Image/Pixels.H"
00046 #include "Image/Layout.H"
00047 #include "Image/Point3D.H"
00048 #include "Image/VisualTracker.H"
00049 #include "plugins/SceneUnderstanding/Camera.H"
00050 #include "plugins/SceneUnderstanding/Ganglion.H"
00051 #include "Simulation/SimEvents.H"
00052 #include "Simulation/SimModule.H"
00053 #include "Media/MediaSimEvents.H"
00054 #include "Component/ModelOptionDef.H"
00055 #include "Component/OptionManager.H"
00056 #include "Component/ModelParam.H"
00057 #include "Devices/Visca.H"
00058 #include "GUI/ViewPort3D.H"
00059
00060 #include <vector>
00061 #include <string>
00062
00063 class PCamera : public SimModule
00064 {
00065 public:
00066
00067 struct Square
00068 {
00069 Point2D<int> p[4];
00070 };
00071
00072 PCamera(OptionManager& mgr, const std::string& descrName = "PCamera",
00073 const std::string& tagName = "PCamera");
00074
00075
00076 ~PCamera();
00077
00078 void evolve();
00079
00080 Layout<PixRGB<byte> > getDebugImage();
00081
00082 void calibrate(std::vector<CvPoint2D32f>& corners);
00083
00084 void displayExtrinsic(std::vector<CvPoint2D32f>& corners);
00085
00086 void projectPoints(std::vector<Point3D<float> >& points);
00087
00088 void projectGrid();
00089
00090 void findSquares(const Image<PixRGB<byte> >& in, CvMemStorage* storage,
00091 const int minarea, const int maxarea, const double mincos);
00092
00093 void getTransMat();
00094
00095
00096 protected:
00097
00098
00099 SIMCALLBACK_DECLARE(PCamera, SimEventInputFrame);
00100
00101
00102 SIMCALLBACK_DECLARE(PCamera, SimEventSaveOutput);
00103
00104
00105 SIMCALLBACK_DECLARE(PCamera, SimEventUserInput);
00106
00107 void onSimEventPTZToLoc(SimEventQueue& q,
00108 rutz::shared_ptr<SimEventUserInput>& e);
00109
00110
00111 OModelParam<bool> itsShowDebug;
00112 nub::soft_ref<Visca> itsCameraCtrl;
00113
00114 private:
00115 CvMemStorage* itsStorage;
00116 Image<PixRGB<byte> > itsCurrentImg;
00117 Image<PixRGB<byte> > itsRenderImg;
00118 ImageSet<float> itsPCameraCellsInput;
00119 Image<byte> itsDebugImg;
00120 std::vector<Square> itsSquares;
00121 CvMat* itsIntrinsicMatrix;
00122 CvMat* itsDistortionCoeffs;
00123 CvMat* itsCameraRotation;
00124 CvMat* itsCameraTranslation;
00125 std::vector<CvPoint2D32f> itsCorners;
00126 std::string itsCurrentObjName;
00127 ViewPort3D* itsVP;
00128
00129
00130 Point2D<int> itsCurrentTargetLoc;
00131 bool itsZoomOut;
00132
00133
00134 bool itsIntrinsicInit;
00135 bool itsSaveCorners;
00136 bool itsDrawGrid;
00137 bool itsChangeRot;
00138
00139 };
00140
00141
00142
00143
00144
00145
00146
00147 #endif //