KSquare Utilities
KKMLL::DuplicateImage Class Reference

#include <DuplicateImages.h>

Public Member Functions

 DuplicateImage (FileDescPtr _fileDesc, FeatureVectorPtr _image1, FeatureVectorPtr _image2, RunLog &_log)
 
 ~DuplicateImage ()
 
void AddADuplicate (FeatureVectorPtr example)
 
bool AllTheSameClass ()
 
bool AlreadyHaveExample (FeatureVectorPtr example)
 
const FeatureVectorListPtr DuplicatedImages ()
 
FeatureVectorPtr ExampleWithSmallestScanLine ()
 
FeatureVectorPtr FirstExampleAdded ()
 

Detailed Description

Definition at line 124 of file DuplicateImages.h.

Constructor & Destructor Documentation

DuplicateImage::DuplicateImage ( FileDescPtr  _fileDesc,
FeatureVectorPtr  _image1,
FeatureVectorPtr  _image2,
RunLog _log 
)
Parameters
_image1image1, will be the one that we was already in the index structures.

Definition at line 369 of file DuplicateImages.cpp.

References DuplicateImage().

Referenced by KKMLL::DuplicateImages::AddSingleExample(), and DuplicateImage().

373  :
374  fileDesc (_fileDesc),
375  duplicatedImages (_fileDesc, false),
376  firstImageAdded (_image1)
377 {
378  duplicatedImages.PushOnBack (_image1);
379  duplicatedImages.PushOnBack (_image2);
380 }
void PushOnBack(FeatureVectorPtr image)
Overloading the PushOnBack function in KKQueue so we can monitor the Version and Sort Order...
DuplicateImage::~DuplicateImage ( )

Definition at line 383 of file DuplicateImages.cpp.

384 {
385 }

Member Function Documentation

void DuplicateImage::AddADuplicate ( FeatureVectorPtr  example)

Definition at line 388 of file DuplicateImages.cpp.

Referenced by KKMLL::DuplicateImages::AddSingleExample().

389 {
390  duplicatedImages.PushOnBack (example);
391 } /* AddADuplicate */
void PushOnBack(FeatureVectorPtr image)
Overloading the PushOnBack function in KKQueue so we can monitor the Version and Sort Order...
bool DuplicateImage::AllTheSameClass ( )

Definition at line 397 of file DuplicateImages.cpp.

Referenced by KKMLL::DuplicateImages::ListOfExamplesToDelete(), and KKMLL::DuplicateImages::PurgeDuplicates().

398 {
399  bool allTheSameClass = true;
400 
401  MLClassPtr mlClass = duplicatedImages.IdxToPtr (0)->MLClass ();
402 
403  FeatureVectorList::iterator iIDX = duplicatedImages.begin ();
404 
405  while ((iIDX != duplicatedImages.end ()) && (allTheSameClass))
406  {
407  allTheSameClass = (*iIDX)->MLClass () == mlClass;
408  iIDX++;
409  }
410 
411  return allTheSameClass;
412 } /* AllTheSameClass */
std::vector< FeatureVector * >::iterator iterator
Definition: KKQueue.h:88
Represents a "Class" in the Machine Learning Sense.
Definition: MLClass.h:52
EntryPtr IdxToPtr(kkuint32 idx) const
Definition: KKQueue.h:732
void MLClass(MLClassPtr _mlClass)
Assign a class to this example.
Definition: FeatureVector.h:74
bool DuplicateImage::AlreadyHaveExample ( FeatureVectorPtr  example)

Definition at line 418 of file DuplicateImages.cpp.

Referenced by KKMLL::DuplicateImageList::LocateByImage().

419 {
420  return (duplicatedImages.PtrToIdx (example) >= 0);
421 }
kkint32 PtrToIdx(EntryConstPtr _entry) const
Definition: KKQueue.h:761
const FeatureVectorListPtr KKMLL::DuplicateImage::DuplicatedImages ( )
inline

Definition at line 142 of file DuplicateImages.h.

Referenced by KKMLL::DuplicateImages::ListOfExamplesToDelete(), and KKMLL::DuplicateImages::PurgeDuplicates().

142 {return &duplicatedImages;}
FeatureVectorPtr DuplicateImage::ExampleWithSmallestScanLine ( )

Definition at line 426 of file DuplicateImages.cpp.

References KKB::KKStr::Concat(), KKMLL::FeatureVector::ExampleFileName(), KKB::KKStr::LocateLastOccurrence(), KKB::KKStr::operator==(), KKB::osGetRootName(), KKB::KKStr::SubStrPart(), and KKB::KKStr::Upper().

Referenced by KKMLL::DuplicateImages::ListOfExamplesToDelete(), and KKMLL::DuplicateImages::PurgeDuplicates().

427 {
428  kkint32 smallestScanLine = 99999999;
429  FeatureVectorPtr imageWithSmallestScanLine = NULL;
430 
431 
432  for (FeatureVectorList::iterator iIDX = duplicatedImages.begin (); iIDX != duplicatedImages.end (); iIDX++)
433  {
434  FeatureVectorPtr i = *iIDX;
435  // First lets derive scan line from example file name
436 
437  KKStr rootName = osGetRootName (i->ExampleFileName ());
438  rootName.Upper ();
439 
440  kkint32 scanLine = 9999999;
441 
442  if (rootName.SubStrPart (0, 4) == "FRAME")
443  {
444  // Scan line will be last seq number in name.
445  kkint32 x = rootName.LocateLastOccurrence ('_');
446  if (x > 0)
447  {
448  KKStr scanLineStr = rootName.SubStrPart (x + 1);
449  scanLine = atoi (scanLineStr.Str ());
450  }
451  }
452  else
453  {
454  // Scan should be 2nd to last seq number in name.
455  kkint32 x = rootName.LocateLastOccurrence ('_');
456  if (x > 0)
457  {
458  KKStr workStr = rootName.SubStrPart (0, x - 1);
459  kkint32 x = workStr.LocateLastOccurrence ('_');
460  KKStr scanLineStr = workStr.SubStrPart (x + 1);
461  scanLine = atoi (scanLineStr.Str ());
462  }
463  }
464 
465  if ((scanLine < smallestScanLine) ||
466  (imageWithSmallestScanLine == NULL)
467  )
468  {
469  smallestScanLine = scanLine;
470  imageWithSmallestScanLine = i;
471  }
472  }
473 
474  return imageWithSmallestScanLine;
475 } /* ImageWithSmallestScalLine */
void ExampleFileName(const KKStr &_exampleFileName)
Name of source of feature vector, ex: file name of image that the feature vector was computed from...
Definition: FeatureVector.h:75
std::vector< FeatureVector * >::iterator iterator
Definition: KKQueue.h:88
__int32 kkint32
Definition: KKBaseTypes.h:88
void Upper()
Converts all characters in string to their Upper case equivalents via &#39;toupper&#39;.
Definition: KKStr.cpp:2461
kkint32 LocateLastOccurrence(char ch) const
Returns index of last occurrence of &#39;ch&#39; otherwise -1.
Definition: KKStr.cpp:2118
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
Represents a Feature Vector of a single example, labeled or unlabeled.
Definition: FeatureVector.h:59
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
KKStr osGetRootName(const KKStr &fullFileName)
FeatureVectorPtr KKMLL::DuplicateImage::FirstExampleAdded ( )
inline

Definition at line 144 of file DuplicateImages.h.

144 {return firstImageAdded;}

The documentation for this class was generated from the following files: