KSquare Utilities
DuplicateImages.h
Go to the documentation of this file.
1 #ifndef _DUPLICATEIMAGES_
2 #define _DUPLICATEIMAGES_
3 
4 /**
5  *@class KKMLL::DuplicateImages
6  *@author Kurt Kramer
7  *@brief Detects duplicate images in a given FeaureVectorList objects.
8  *@details Will derive a list of duplicate FeatureVector objects in a given list. It will
9  * use both the Image File Name and feature data to detect duplicates. A duplicate
10  * can be detected in two ways. If two or more entries have the same ExampleFileName
11  * or FeatureData.
12  *
13  * The simplest way to use this object is to create an instance with a FeatureVectorList
14  * object that you are concerned with. Then call the method DupExamples (), which will
15  * return the list of duplicates found via a structure called DuplicateImageList.
16  */
17 
18 
19 #include "RunLog.h"
20 #include "FeatureVector.h"
21 
22 
23 namespace KKMLL
24 {
27 
30 
31 
32  #ifndef _IMAGEFEATURESDATAINDEXED_
35  #endif
36 
37 
38  #ifndef _FEATUREVECTOR_
39  class FeatureVector;
41  class FeatureVectorList;
43  #endif
44 
45  #ifndef _IMAGEFEATURESNAMEINDEXED_
48  #endif
49 
50 
51 
52 
54  {
55  public:
56  /**
57  *@brief You would use this instance to search for duplicates in the list of 'examples'.
58  *@details You can still call 'AddExamples' and 'AddSingleExample';
59  */
60  DuplicateImages (FeatureVectorListPtr _examples,
61  RunLog& _log
62  );
63 
64 
65  DuplicateImages (FileDescPtr _fileDesc,
66  RunLog& _log
67  );
68 
69  ~DuplicateImages ();
70 
71 
72  /** @brief Will add all the examples; be careful of ownership. */
73  bool AddExamples (FeatureVectorListPtr examples);
74 
75  /**
76  *@brief Add one more FeatureVector to the list.
77  *@details Will add one more example to list and if it turns out to be a duplicate will
78  * return pointer to a "DuplicateImage" structure that will contain a list of
79  * all images that it is duplicate to. If no duplicate found will then return
80  * a NULL pointer.
81  *@param[in] example FeatureVecvtor that you want to add to the list.
82  */
83  DuplicateImagePtr AddSingleExample (FeatureVectorPtr example);
84 
85  DuplicateImageListPtr DupExamples () const {return dupExamples;}
86 
87  kkint32 DuplicateCount () const {return duplicateCount;}
88  kkint32 DuplicateDataCount () const {return duplicateDataCount;}
89  kkint32 DuplicateNameCount () const {return duplicateNameCount;}
90 
91  bool DuplicatesFound () const;
92 
93  bool ExampleInDetector (FeatureVectorPtr fv);
94 
95  FeatureVectorListPtr ListOfExamplesToDelete ();
96 
97  void PurgeDuplicates (FeatureVectorListPtr examples,
98  bool allowDupsInSameClass,
99  std::ostream* report
100  ); /**< if not equal NULL will list examples being purged. */
101 
102  void ReportDuplicates (std::ostream& o);
103 
104 
105  private:
106  void FindDuplicates (FeatureVectorListPtr examples); /**< Used to build duplicate list from current contents of examples. */
107 
108  kkint32 duplicateCount;
109  kkint32 duplicateDataCount;
110  kkint32 duplicateNameCount;
111  DuplicateImageListPtr dupExamples;
112  ImageFeaturesDataIndexedPtr featureDataTree;
113  FileDescPtr fileDesc;
114  RunLog& log;
116  };
117 
118 
120 
121 
122 
123 
125  {
126  public:
127  DuplicateImage (FileDescPtr _fileDesc,
128  FeatureVectorPtr _image1,
129  FeatureVectorPtr _image2,
130  RunLog& _log
131  );
132 
133  ~DuplicateImage ();
134 
135  void AddADuplicate (FeatureVectorPtr example);
136 
137  bool AllTheSameClass ();
138 
139  bool AlreadyHaveExample (FeatureVectorPtr example);
140 
141  const
142  FeatureVectorListPtr DuplicatedImages () {return &duplicatedImages;}
143 
144  FeatureVectorPtr FirstExampleAdded () {return firstImageAdded;}
145 
146  FeatureVectorPtr ExampleWithSmallestScanLine ();
147 
148  private:
149  FileDescPtr fileDesc;
150  FeatureVectorList duplicatedImages;
151  FeatureVectorPtr firstImageAdded;
152  };
153 
154 
155 
156 
157 
159 
160 
161 
162 
164  {
165  public:
166  DuplicateImageList (bool _owner);
167  ~DuplicateImageList ();
168 
169  DuplicateImagePtr LocateByImage (FeatureVectorPtr example);
170 
171  private:
172  };
173 
175 
176 } /* namespace KKMLL */
177 
178 #endif
__int32 kkint32
Definition: KKBaseTypes.h:88
DuplicateImages(FeatureVectorListPtr _examples, RunLog &_log)
You would use this instance to search for duplicates in the list of &#39;examples&#39;.
DuplicateImageList * DuplicateImageListPtr
bool AlreadyHaveExample(FeatureVectorPtr example)
DuplicateImagePtr LocateByImage(FeatureVectorPtr example)
DuplicateImage * DuplicateImagePtr
DuplicateImage(FileDescPtr _fileDesc, FeatureVectorPtr _image1, FeatureVectorPtr _image2, RunLog &_log)
bool AddExamples(FeatureVectorListPtr examples)
Will add all the examples; be careful of ownership.
void AddADuplicate(FeatureVectorPtr example)
FeatureVectorPtr FirstExampleAdded()
kkint32 DuplicateCount() const
DuplicateImages(FileDescPtr _fileDesc, RunLog &_log)
Container class for FeatureVector derived objects.
DuplicateImageListPtr DupExamples() const
void ReportDuplicates(std::ostream &o)
kkint32 DuplicateNameCount() const
ImageFeaturesNameIndexed * ImageFeaturesNameIndexedPtr
FeatureVectorPtr ExampleWithSmallestScanLine()
FileDesc * FileDescPtr
ImageFeaturesDataIndexed * ImageFeaturesDataIndexedPtr
void PurgeDuplicates(FeatureVectorListPtr examples, bool allowDupsInSameClass, std::ostream *report)
Delete duplicate examples from FeatureVectorList structure provided in constructor.
DuplicateImagePtr AddSingleExample(FeatureVectorPtr example)
Add one more FeatureVector to the list.
bool ExampleInDetector(FeatureVectorPtr fv)
Detects duplicate images in a given FeaureVectorList objects.
Used for logging messages.
Definition: RunLog.h:49
void EncodeProblem(const struct svm_paramater &param, struct svm_problem &prob_in, struct svm_problem &prob_out)
kkint32 DuplicateDataCount() const
FeatureVectorListPtr ListOfExamplesToDelete()
const FeatureVectorListPtr DuplicatedImages()
DuplicateImages * DuplicateImagesPtr