X-Boost  2.3.8
ImageClassifier.h
Go to the documentation of this file.
1 /* XBoost: Ada-Boost and Friends on Haar/ICF/HOG Features, Library and ToolBox
2  *
3  * Copyright (c) 2008-2014 Paolo Medici <medici@ce.unipr.it>
4  * Copyright (c) 2013-2014 Luca Castangia <l.caio@ce.unipr.it>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 #ifndef _IMAGE_CLASSIFIER_H
23 #define _IMAGE_CLASSIFIER_H
24 
25 #include <vector>
26 #include <iostream>
27 #include "Types.h"
28 #include "Image.h"
29 
36 class ImageClassifier {
38 
39 private:
41  int width,height;
42 public:
43 
44  virtual ~ImageClassifier();
45 
48  ImageClassifier(std::istream & in) {
49  in >> width >> height;
50  }
51 
52  ImageClassifier(int w,int h) : width(w), height(w) {
53  }
54 
57  return size(width,height);
58  }
59 
61  virtual std::string getSignature() const = 0;
62 
67  virtual void setImage(const unsigned char *ptr, long stride, unsigned int width, unsigned int height) = 0;
68 
70  void setImage(const ImageHandle & src)
71  {
72  setImage(src.data, src.stride, src.width, src.height);
73  }
74 
77  virtual float operator() (int x0, int y0) const = 0;
78 
81  virtual void Process (double *out, int x0, int y0, int n, int step=1) const = 0;
82 
85  virtual void Release() = 0;
86 };
87 
88 #endif
ImageClassifier(std::istream &in)
Definition: ImageClassifier.h:48
Types involved in boosting.
"Binary" Classifier, virtual class
Definition: ImageClassifier.h:37
Definition: Image.h:35
virtual float operator()(int x0, int y0) const =0
virtual void Process(double *out, int x0, int y0, int n, int step=1) const =0
virtual std::string getSignature() const =0
return the classifier signature
image/size TODO namespace
Definition: Types.h:39
long stride
line stride, the delta offset, in bytes, between two different scanline
Definition: Image.h:41
size GetClassifierGeometry() const
return the [current] classifier geometry
Definition: ImageClassifier.h:56
method to hold an image
virtual void Release()=0
unsigned int width
image geometry
Definition: Image.h:39
virtual void setImage(const unsigned char *ptr, long stride, unsigned int width, unsigned int height)=0
unsigned char * data
initial address of the first pixel. It must be cast to correct format (uint8, uint16, rgb, etc etc)
Definition: Image.h:43
void setImage(const ImageHandle &src)
setImage for the following operator() and Process
Definition: ImageClassifier.h:70