camera_parameters.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
34 #ifndef _CAMERA_PARAMETERS_CPP_
35 #define _CAMERA_PARAMETERS_CPP_
36 
37 #include "camera_parameters.h"
38 
47 int class_camera_parameters::set_intrinsic(double fx, double fy, double cx, double cy)
48 {
49  cv::Mat *M = &intrinsic;
50  M->at<double>(0,0) = fx; M->at<double>(0,1) = 0; M->at<double>(0,2) = cx; M->at<double>(0,3) = 0;
51  M->at<double>(1,0) = 0; M->at<double>(1,1) = fy; M->at<double>(1,2) = cy; M->at<double>(1,3) = 0;
52  M->at<double>(2,0) = 0; M->at<double>(2,1) = 0; M->at<double>(2,2) = 1; M->at<double>(2,3) = 0;
53 
54  return 1;};
55 
59 int class_camera_parameters::set_extrinsic(tf::StampedTransform* t)
60 {
61  camera_6dof_position.setRotation(t->getRotation());
62  camera_6dof_position.setOrigin(t->getOrigin());
63  tf::Matrix3x3 rot(t->getRotation());
64  set_extrinsic(rot[0][0], rot[0][1], rot[0][2], t->getOrigin().x(),
65  rot[1][0], rot[1][1], rot[1][2], t->getOrigin().y(),
66  rot[2][0], rot[2][1], rot[2][2], t->getOrigin().z());
67  return 1;}
68 
70 {
71  camera_6dof_position.setRotation(t->getRotation());
72  camera_6dof_position.setOrigin(t->getOrigin());
73  tf::Matrix3x3 rot(t->getRotation());
74  set_extrinsic(rot[0][0], rot[0][1], rot[0][2], t->getOrigin().x(),
75  rot[1][0], rot[1][1], rot[1][2], t->getOrigin().y(),
76  rot[2][0], rot[2][1], rot[2][2], t->getOrigin().z());
77  return 1;}
78 
79 
85 int class_camera_parameters::set_extrinsic(double p11, double p12, double p13, double p14,
86  double p21, double p22, double p23, double p24,
87  double p31, double p32, double p33, double p34)
88 {
89  cv::Mat *M = &extrinsic;
90  M->at<double>(0,0) = p11; M->at<double>(0,1) = p12; M->at<double>(0,2) = p13; M->at<double>(0,3) = p14;
91  M->at<double>(1,0) = p21; M->at<double>(1,1) = p22; M->at<double>(1,2) = p23; M->at<double>(1,3) = p24;
92  M->at<double>(2,0) = p31; M->at<double>(2,1) = p32; M->at<double>(2,2) = p33; M->at<double>(2,3) = p34;
93  M->at<double>(3,0) = 0; M->at<double>(3,1) = 0; M->at<double>(3,2) = 0; M->at<double>(3,3) = 1;
94 
96  return 1;};
97 
98 
99 
100 #endif
101 
tf::StampedTransform camera_6dof_position
Defines a class where the parameters of a camera are stored.
int set_extrinsic(double p11, double p12, double p13, double p14, double p21, double p22, double p23, double p24, double p31, double p32, double p33, double p34)
sets extrinsic parameters
int set_intrinsic(double fx, double fy, double cx, double cy)
sets intrinsic parameters from a 3x3 CvMat


polygon_primitives_extraction
Author(s): Miguel Oliveira
autogenerated on Mon Mar 2 2015 01:32:41