libeblearntools
|
00001 /*************************************************************************** 00002 * Copyright (C) 2009 by Pierre Sermanet * 00003 * pierre.sermanet@gmail.com * 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Redistribution under a license not approved by the Open Source 00014 * Initiative (http://www.opensource.org) must display the 00015 * following acknowledgement in all advertising material: 00016 * This product includes software developed at the Courant 00017 * Institute of Mathematical Sciences (http://cims.nyu.edu). 00018 * * The names of the authors may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00023 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00024 * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY 00025 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00026 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00027 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00028 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00029 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 ***************************************************************************/ 00032 00033 #ifndef PASCALBG_DATASET_H_ 00034 #define PASCALBG_DATASET_H_ 00035 00036 #include "dataset.h" 00037 #include "xml_utils.h" 00038 00039 namespace ebl { 00040 00043 template <class Tdata> class pascalbg_dataset : public pascal_dataset<Tdata> { 00044 public: 00045 00047 // constructors 00048 00054 pascalbg_dataset(const char *name, const char *inroot, const char *outdir, 00055 uint max_folders = 1, bool ignore_diff = true, 00056 bool ignore_trunc = false, bool ignore_occl = false, 00057 const char *annotations = NULL, const char *tmpout = NULL); 00058 00060 virtual ~pascalbg_dataset(); 00061 00063 // data 00064 00066 virtual bool extract(); 00067 00068 protected: 00069 00070 #ifdef __BOOST__ // disable some derived methods if BOOST not available 00071 #ifdef __XML__ // disable some derived methods if XML not available 00072 00074 // internal methods 00075 00077 virtual bool process_xml(const string &xmlfile); 00078 00080 virtual rect<int> get_object(Node* onode); 00081 00083 virtual void process_image(idx<ubyte> &img, vector<rect<int> >& bboxes, 00084 const string &image_filename); 00085 00089 void save_patches(idx<ubyte> &img, const string &image_filename, 00090 vector<rect<int> > &patch_bboxes, 00091 vector<rect<int> > &objs_bboxes, const string &outdir, 00092 uint max_folders, const string &filename); 00093 00094 void display_patch(midx<Tdata> &patch, idx<Tdata> &img, 00095 const string &image_filename, 00096 const string &cname, 00097 rect<int> &pbbox, rect<int> &r, 00098 vector<rect<int> > &objs_bboxes, 00099 vector<rect<int> > &patch_bboxes); 00100 00101 #endif /* __BOOST__ */ 00102 #endif /* __XML__ */ 00103 00104 protected: 00105 uint max_folders; // maximum number of patch directories 00106 // base class members to be used /////////////////////////////// 00107 using pascal_dataset<Tdata>::annroot; 00108 using pascal_dataset<Tdata>::imgroot; 00109 using dataset<Tdata>::inroot; 00110 using dataset<Tdata>::display_extraction; 00111 using dataset<Tdata>::display_result; 00112 using dataset<Tdata>::outdims; 00113 using dataset<Tdata>::outdir; 00114 using dataset<Tdata>::sleep_display; 00115 using dataset<Tdata>::sleep_delay; 00116 using dataset<Tdata>::print_stats; 00117 using dataset<Tdata>::data_cnt; 00118 using dataset<Tdata>::extension; 00119 using dataset<Tdata>::scales; 00120 using dataset<Tdata>::max_data; 00121 using dataset<Tdata>::max_data_set; 00122 using dataset<Tdata>::useparts; 00123 using dataset<Tdata>::usepartsonly; 00124 using dataset<Tdata>::exclude; 00125 using dataset<Tdata>::include; 00126 using dataset<Tdata>::usepose; 00127 using dataset<Tdata>::save_mode; 00128 using dataset<Tdata>::original_bbox; 00129 using dataset<Tdata>::add_errors; 00130 using pascal_dataset<Tdata>::ignore_difficult; 00131 using pascal_dataset<Tdata>::ignore_truncated; 00132 using pascal_dataset<Tdata>::ignore_occluded; 00133 using dataset<Tdata>::xtimer; 00134 using dataset<Tdata>::processed_cnt; 00135 using dataset<Tdata>::fovea; 00136 using dataset<Tdata>::images_list; 00137 using dataset<Tdata>::outtmp; 00138 }; 00139 00140 } // end namespace ebl 00141 00142 #include "pascalbg_dataset.hpp" 00143 00144 #endif /* PASCALBG_DATASET_H_ */