LFLineSegment.h

00001 /*
00002 Copyright 2010, Ming-Yu Liu
00003 
00004 All Rights Reserved 
00005 
00006 Permission to use, copy, modify, and distribute this software and 
00007 its documentation for any non-commercial purpose is hereby granted 
00008 without fee, provided that the above copyright notice appear in 
00009 all copies and that both that copyright notice and this permission 
00010 notice appear in supporting documentation, and that the name of 
00011 the author not be used in advertising or publicity pertaining to 
00012 distribution of the software without specific, written prior 
00013 permission. 
00014 
00015 THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
00016 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
00017 ANY PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 
00018 ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
00019 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 
00020 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 
00021 OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 
00022 
00023 Lior Elazary: Modified to work with the INVT
00024 */
00025 
00026 
00027 
00028 #pragma once
00029 #include <stdio.h>
00030 #define _USE_MATH_DEFINES
00031 #include <math.h>
00032 #undef  _USE_MATH_DEFINES
00033 
00034 #include <opencv/cxcore.h>
00035 
00036 
00037 class LFLineSegment
00038 {
00039 public:
00040         LFLineSegment()
00041   {
00042     sx_ = 0;
00043     sy_ = 0;
00044     ex_ = 0;
00045     ey_ = 0;
00046     normal_.x =0;
00047     normal_.y =0;
00048     nSupport_ = 0;
00049     weight_ = 0;
00050   
00051   };
00052         ~LFLineSegment() {
00053 
00054   };
00055 
00056         double sx_,sy_,ex_,ey_;
00057         int nSupport_;
00058         double len_;
00059   double weight_;
00060         CvPoint2D64f normal_;
00061 
00062         inline LFLineSegment& operator=(const LFLineSegment &rhs);
00063 
00064         // For qsort function
00065         inline static int Compare(const void *l1,const void *l2);
00066         inline static int LineSegmentCompare( LFLineSegment &l1, LFLineSegment &l2);
00067 
00068 
00069         void Read(FILE* fin);   
00070         void Center(double *center);
00071         void Translate(double *vec);
00072         
00073         double Theta();
00074 
00075         void Rotate(double theta);
00076         void Scale(double s);
00077         double Length();
00078 
00079 };
00080 
00081 inline int LFLineSegment::LineSegmentCompare( LFLineSegment &l1, LFLineSegment &l2 )
00082 {
00083         if( l1.len_ > l2.len_ )
00084                 return -1;
00085         else if( l1.len_ == l2.len_ )
00086                 return 0;
00087         else
00088                 return 1;
00089 };
00090 
00091 inline int LFLineSegment::Compare(const void *l1,const void *l2 )
00092 {
00093         return LineSegmentCompare( *(LFLineSegment*)l1, *(LFLineSegment*)l2 );
00094 
00095 };
00096 
00097 inline LFLineSegment& LFLineSegment::operator=(const LFLineSegment &rhs)
00098 {
00099         sx_ = rhs.sx_;
00100         sy_ = rhs.sy_;
00101         ex_ = rhs.ex_;
00102         ey_ = rhs.ey_;
00103         len_ = rhs.len_;
00104         weight_ = rhs.weight_;
00105 
00106         nSupport_ = rhs.nSupport_;
00107         normal_ = rhs.normal_;
00108         return (*this);
00109 }
Generated on Sun May 8 08:41:09 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3