FernImageDetector.h
Go to the documentation of this file.
1 /*
2  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
3  *
4  * Copyright 2007-2012 VTT Technical Research Centre of Finland
5  *
6  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
7  * <http://www.vtt.fi/multimedia/alvar.html>
8  *
9  * ALVAR is free software; you can redistribute it and/or modify it under the
10  * terms of the GNU Lesser General Public License as published by the Free
11  * Software Foundation; either version 2.1 of the License, or (at your option)
12  * any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
17  * for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with ALVAR; if not, see
21  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
22  */
23 
24 #ifndef FERNIMAGEDETECTOR_H
25 #define FERNIMAGEDETECTOR_H
26 
33 #include <map>
34 #include <vector>
35 #include <iostream>
36 #include <fstream>
37 
38 #include "cv.h"
39 #include "highgui.h"
40 #include "cvaux.h"
41 
42 #include "Camera.h"
43 #include "EC.h"
44 
45 using namespace cv;
46 
47 namespace alvar{
48 
52 class FernClassifierWrapper : public FernClassifier
53 {
54 public:
56  FernClassifierWrapper(const FileNode &fileNode);
57  FernClassifierWrapper(const vector<vector<Point2f> > &points,
58  const vector<Mat> &referenceImages,
59  const vector<vector<int> > &labels = vector<vector<int> >(),
60  int _nclasses = 0,
61  int _patchSize = PATCH_SIZE,
62  int _signatureSize = DEFAULT_SIGNATURE_SIZE,
63  int _nstructs = DEFAULT_STRUCTS,
64  int _structSize = DEFAULT_STRUCT_SIZE,
65  int _nviews = DEFAULT_VIEWS,
66  int _compressionMethod = COMPRESSION_NONE,
67  const PatchGenerator &patchGenerator = PatchGenerator());
68  virtual ~FernClassifierWrapper();
69 
70  virtual void readBinary(std::fstream &stream);
71  virtual void writeBinary(std::fstream &stream) const;
72 };
73 
78 {
79 public:
80  FernImageDetector(const bool visualize = false);
82 
83  void imagePoints(vector<CvPoint2D64f> &points);
84  void modelPoints(vector<CvPoint3D64f> &points, bool normalize = true);
85 
86  cv::Size size();
87  cv::Mat homography();
88  double inlierRatio();
89 
90  void train(const std::string &filename);
91  void train(Mat &image);
92  void findFeatures(Mat &image, bool planeAssumption = true);
93 
94  bool read(const std::string &filename, const bool binary = true);
95  bool write(const std::string &filename, const bool binary = true);
96 
97 private:
98  PatchGenerator mPatchGenerator;
99  LDetector mLDetector;
100  std::vector<FernClassifierWrapper> mClassifier;
101 
102  vector<KeyPoint> mKeyPoints;
103  vector<cv::Point2f> mImagePoints;
104  vector<cv::Point2f> mModelPoints;
105 
107  std::vector<Mat> mObjects;
108  cv::Size mSize;
110  cv::Mat mHomography;
111  double mInlierRatio;
112 };
113 
114 } // namespace alvar
115 
116 #endif
Main ALVAR namespace.
Definition: Alvar.h:174
filename
This file implements a camera used for projecting points and computing homographies.
std::vector< Mat > mObjects
int visualize
Image detector based on a Fern classifier.
#define PATCH_SIZE
unsigned char * image
Definition: GlutViewer.cpp:155
std::vector< FernClassifierWrapper > mClassifier
TFSIMD_FORCE_INLINE Vector3 & normalize()
vector< cv::Point2f > mModelPoints
vector< KeyPoint > mKeyPoints
#define ALVAR_EXPORT
Definition: Alvar.h:168
PatchGenerator mPatchGenerator
This file implements a collection of External Container (EC) versions of many ALVAR classes...
vector< cv::Point2f > mImagePoints
FernClassifier subclass that implements binary reading and writting.


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Thu Jun 6 2019 19:27:23