1 // Copyright (c) 2007, 2008 libmv authors. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to 5 // deal in the Software without restriction, including without limitation the 6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 // sell copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 // IN THE SOFTWARE. 20 21 #ifndef LIBMV_CORRESPONDENCE_FEATURE_H_ 22 #define LIBMV_CORRESPONDENCE_FEATURE_H_ 23 24 #include <opencv2/core.hpp> 25 26 #include "libmv/numeric/numeric.h" 27 28 namespace libmv 29 { 30 class Feature 31 { 32 public: 33 virtual ~Feature()34 ~Feature() {}; 35 }; 36 37 class PointFeature : public Feature { 38 public: 39 PointFeature(float xx=0.0f, float yy=0.0f) { 40 coords[0] = xx; 41 coords[1] = yy; 42 scale = 0.0; 43 orientation = 0.0; 44 } 45 46 PointFeature &operator=(const PointFeature &other) 47 { 48 if (this == &other) 49 return *this; 50 scale = other.scale; 51 orientation = other.orientation; 52 coords = other.coords; 53 return *this; 54 } 55 PointFeature(const cv::KeyPoint & keypoint)56 PointFeature(const cv::KeyPoint & keypoint) { 57 coords[0] = keypoint.pt.x; 58 coords[1] = keypoint.pt.y; 59 scale = keypoint.octave; 60 orientation = keypoint.angle; 61 } x()62 float x() const { return coords(0); } y()63 float y() const { return coords(1); } 64 65 Vec2f coords; // (x, y), i.e. (column, row). 66 float scale; // In pixels. 67 float orientation; // In radians. 68 }; 69 70 } // namespace libmv 71 72 #endif // LIBMV_CORRESPONDENCE_FEATURE_H_ 73