classifier.cpp
00001 00002 /*************************************************************************** 00003 * classifier.cpp - Abstract class defining a classifier 00004 * 00005 * Created: Mon Dec 10 11:35:36 2007 00006 * Copyright 2005-2007 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #include <classifiers/classifier.h> 00025 #include <cstring> 00026 #include <cstdlib> 00027 00028 /** @class Classifier <classifiers/classifier.h> 00029 * Classifier to extract regions of interest. 00030 * The classifier finds regions of interest (ROI) by some a priori knowledge 00031 * like known colors or shapes. The list of ROIs returned by classify() _must_ 00032 * be disjunct, meaning that no ROIs overlap each other. 00033 * Do appropriate merging or shrinking of the ROIs. See the ReallySimpleClassifier 00034 * for an example. 00035 * @author Tim Niemueller 00036 * 00037 * @fn std::list< ROI > * Classifier::classify() = 0 00038 * Classify image. 00039 * The current buffer is processed and scanned for the features the classifier 00040 * has been written and initialized for. It returns a list of disjunct regions 00041 * of interest. 00042 * @return disjunct list of extracted regions of interest 00043 */ 00044 00045 00046 /** Constructor. 00047 * @param name classifier name 00048 */ 00049 Classifier::Classifier(const char *name) 00050 { 00051 __name = strdup(name); 00052 _src = NULL; 00053 _width = 0; 00054 _height = 0; 00055 } 00056 00057 00058 /** Destructor. */ 00059 Classifier::~Classifier() 00060 { 00061 free(__name); 00062 } 00063 00064 00065 /** Set source buffer. 00066 * @param yuv422_planar a YUV422 planar buffer with the source image to 00067 * classify. The classifier may NOT modify the image in any way. If that is 00068 * required the classifier shall make a copy of the image. 00069 * @param width width of buffer in pixels 00070 * @param height height of buffer in pixels 00071 */ 00072 void 00073 Classifier::set_src_buffer(unsigned char *yuv422_planar, unsigned int width, 00074 unsigned int height) 00075 { 00076 _src = yuv422_planar; 00077 _width = width; 00078 _height = height; 00079 } 00080 00081 00082 /** Get name of classifier. 00083 * @return name of classifier. 00084 */ 00085 const char * 00086 Classifier::name() const 00087 { 00088 return __name; 00089 }

