PinholeCameraModel.cpp
Go to the documentation of this file.
00001 #include "PinholeCameraModel.hpp"
00002 
00003 namespace virtual_camera {
00004 
00005 std::string PinholeCameraModel::getIndentifier() {
00006         return "pinhole";
00007 }
00008 
00009 
00010 TableV3Ptr PinholeCameraModel::createPointCloud(
00011                 const VirtualCameraParametersPtr & params) {
00012         const int & width = params->viewportWidth;
00013         const int & height = params->viewportHeight;
00014         const double & distance = params->approxDistance;
00015         TableV3Ptr ret = TableV3Ptr(new TableV3(boost::extents[height][width]));
00016         double hFovRad = angles::from_degrees(params->horizontalFov);
00017         double vFovRad = angles::from_degrees(params->verticalFov);
00018         double hLength = 2*distance*std::tan(hFovRad/2);
00019         double vLength = 2*distance*std::tan(vFovRad/2);
00020         double hStep = hLength/width;
00021         double vStep = vLength/height;
00022 
00023         for (int y=0; y<height; y++) {
00024                 double yPos = (y-height/2)*vStep;
00025                 for (int x=0; x<width; x++) {
00026                         double xPos = (x-width/2)*hStep;
00027                         tf::Vector3 & pt = (*(ret))[y][x];
00028                         pt[0] = xPos;
00029                         pt[1] = yPos;
00030                         pt[2] = distance;
00031                 }
00032         }
00033         return ret;
00034 }
00035 
00036 
00037 }
00038 
00039 
00040 
 All Classes Namespaces Files Functions Variables Typedefs Defines


virtual_camera
Author(s): Jan Brabec; maintained by Tomas Petricek / petrito1@cmp.felk.cvut
autogenerated on Tue Dec 10 2013 14:58:11