Fawkes API  Fawkes Development Version
classifier.cpp
1 
2 /***************************************************************************
3  * classifier.cpp - Abstract class defining a classifier
4  *
5  * Created: Mon Dec 10 11:35:36 2007
6  * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <fvclassifiers/classifier.h>
25 #include <cstring>
26 #include <cstdlib>
27 
28 namespace firevision {
29 #if 0 /* just to make Emacs auto-indent happy */
30 }
31 #endif
32 
33 /** @class Classifier <fvclassifiers/classifier.h>
34  * Classifier to extract regions of interest.
35  * The classifier finds regions of interest (ROI) by some a priori knowledge
36  * like known colors or shapes. The list of ROIs returned by classify() _must_
37  * be disjunct, meaning that no ROIs overlap each other.
38  * Do appropriate merging or shrinking of the ROIs. See the ReallySimpleClassifier
39  * for an example.
40  * @author Tim Niemueller
41  *
42  * @fn std::list< ROI > * Classifier::classify() = 0
43  * Classify image.
44  * The current buffer is processed and scanned for the features the classifier
45  * has been written and initialized for. It returns a list of disjunct regions
46  * of interest.
47  * @return disjunct list of extracted regions of interest
48  */
49 
50 
51 /** Constructor.
52  * @param name classifier name
53  */
54 Classifier::Classifier(const char *name)
55 {
56  __name = strdup(name);
57  _src = NULL;
58  _width = 0;
59  _height = 0;
60 }
61 
62 
63 /** Destructor. */
65 {
66  free(__name);
67 }
68 
69 
70 /** Set source buffer.
71  * @param yuv422_planar a YUV422 planar buffer with the source image to
72  * classify. The classifier may NOT modify the image in any way. If that is
73  * required the classifier shall make a copy of the image.
74  * @param width width of buffer in pixels
75  * @param height height of buffer in pixels
76  */
77 void
78 Classifier::set_src_buffer(unsigned char *yuv422_planar, unsigned int width,
79  unsigned int height)
80 {
81  _src = yuv422_planar;
82  _width = width;
83  _height = height;
84 }
85 
86 
87 /** Get name of classifier.
88  * @return name of classifier.
89  */
90 const char *
92 {
93  return __name;
94 }
95 
96 } // end namespace firevision
Classifier(const char *name)
Constructor.
Definition: classifier.cpp:54
unsigned int _width
Width in pixels of _src buffer.
Definition: classifier.h:54
unsigned int _height
Height in pixels of _src buffer.
Definition: classifier.h:56
virtual ~Classifier()
Destructor.
Definition: classifier.cpp:64
virtual void set_src_buffer(unsigned char *yuv422_planar, unsigned int width, unsigned int height)
Set source buffer.
Definition: classifier.cpp:78
virtual const char * name() const
Get name of classifier.
Definition: classifier.cpp:91
unsigned char * _src
Source buffer, encoded as YUV422_PLANAR.
Definition: classifier.h:52