utility.h

00001 /*
00002 
00003     This file is part of the FAST-ER machine learning system.
00004     Copyright (C) 2008  Edward Rosten and Los Alamos National Laboratory
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License along
00017     with this program; if not, write to the Free Software Foundation, Inc.,
00018     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00019 */
00020 #ifndef INC_UTILITY_H
00021 #define INC_UTILITY_H
00022 
00023 #include <cvd/image_ref.h>
00024 #include <tag/array.h>
00025 #include <TooN/TooN.h>
00026 
00027 /// Convert a float array into an image co-ordinate. Numbers are rounded
00028 /// @param v The array to convert
00029 /// @ingroup gUtility
00030 inline CVD::ImageRef ir_rounded(const tag::array<float, 2>& v)
00031 {
00032     return CVD::ImageRef(
00033   static_cast<int>(v[0] > 0.0 ? v[0] + 0.5 : v[0] - 0.5),
00034   static_cast<int>(v[1] > 0.0 ? v[1] + 0.5 : v[1] - 0.5));
00035 }
00036 
00037 ///Convert an array<float, 2> in to a Vector<2>
00038 ///@param f The input array
00039 ///@return The output Vector<2>
00040 inline TooN::Vector<2> Vec(const tag::array<float, 2>& f)
00041 {
00042         return (TooN::make_Vector, f[0], f[1]);
00043 }
00044 
00045 #endif

Generated on Mon Mar 2 12:47:12 2009 for FAST-ER by  doxygen 1.5.3