line.cpp
Go to the documentation of this file.
00001 /*
00002     <one line to give the library's name and an idea of what it does.>
00003     Copyright (C) <year>  <name of author>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2.1 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 */
00020 
00021 #include "line.h"
00022 
00023 using namespace V4R;
00024 Line2DHdl::Line2DHdl()
00025         : mpLine(NULL) {
00026 };
00027 Line2DHdl::Line2DHdl(Line2D<double> &r)
00028         : mpLine(NULL)
00029 {
00030     set(r);
00031 };
00032 Line2DHdl::Line2DHdl(double *p)
00033         : mpLine(NULL)
00034 {
00035     set(p);
00036 };
00037 
00038 void Line2DHdl::set(Line2D<double> &r) {
00039     mpLine = &r;
00040 };
00041 
00042 void Line2DHdl::set(double *p) {
00043     set(*((Line2D<double> *) p));
00044 };
00045 
00046 void Line2DHdl::normalize(cv::Mat &rLines) {
00047     if (rLines.cols != 3) {
00048         CV_Error( CV_StsUnsupportedFormat, "Line2DHdl::normalize columns size must be 3" ); 
00049         return;
00050     }
00051     if (rLines.type() == CV_64F) {
00052         Line2D<double> *pLine = (Line2D<double> *) rLines.data;
00053         for (int i = 0; i < rLines.rows; i++) {
00054             pLine[i].normalize();
00055         }
00056     } else {
00057         CV_Error( CV_StsUnsupportedFormat, "Line2DHdl::normalize type must be CV_64F" ); 
00058         return;
00059     }
00060 }
00061 
00062 Line2D<double> &Line2DHdl::operator ()() {
00063     return *mpLine;
00064 }
00065 Line2D<double> &Line2DHdl::operator ()(unsigned int idx) {
00066     return mpLine[idx];
00067 }
00068 
00069 cv::Vec<double,2> &Line2DHdl::normal() {
00070     return mNormal;
00071 }
00072 cv::Vec<double,2> &Line2DHdl::computeNormal() {
00073     mNormal[0] = -mpLine->eq_[0], mNormal[1] = -mpLine->eq_[1];
00074     return mNormal;
00075 }
00076 cv::Vec<double,2> &Line2DHdl::unit() {
00077     return mUnit;
00078 }
00079 cv::Vec<double,2> &Line2DHdl::computeUnit() {
00080     mUnit[0] = mpLine->eq_[1], mUnit[1] = -mpLine->eq_[0];
00081     return mUnit;
00082 }


v4r_laser_robot_calibration
Author(s):
autogenerated on Wed Aug 26 2015 16:42:08