ImageMatcher< Tag, Allocator > Struct Template Reference
The ImageMatcher structure provides fast algorithm of searching of similar images. More...
Data Structures | |
| struct | Hash |
| The Hash structure is used for fast image matching. More... | |
| struct | Result |
| The Result structure is a result of matching current image and images added before to ImageMatcher. More... | |
Public Types | |
| enum | HashType { Hash16x16 , Hash32x32 , Hash64x64 } |
| typedef Simd::View< Allocator > | View |
| typedef std::shared_ptr< Hash > | HashPtr |
| typedef std::vector< Result > | Results |
Public Member Functions | |
| bool | Empty () const |
| size_t | Size () const |
| bool | Init (double threshold=0.05, HashType type=Hash16x16, size_t number=0, bool normalized=false) |
| HashPtr | Create (const View &view, const Tag &tag) |
| bool | Find (const HashPtr &hash, Results &results) |
| void | Add (const HashPtr &hash) |
| void | Skip (const HashPtr &hash) |
Detailed Description
template<class Tag, template< class > class Allocator>
struct Simd::ImageMatcher< Tag, Allocator >
The ImageMatcher structure provides fast algorithm of searching of similar images.
Using example (the filter removes duplicates from the list):
#include "Simd/SimdImageMatcher.hpp"
typedef Simd::ImageMatcher<size_t, Simd::Allocator> ImageMatcher;
typedef std::shared_ptr<View> ViewPtr;
typedef std::vector<ViewPtr> ViewPtrs;
void FilterDuplicates(const ViewPtrs & src, double threshold, ViewPtrs & dst)
{
ImageMatcher matcher;
matcher.Init(threshold, ImageMatcher::Hash16x16, src.size());
for (size_t i = 0; i < src.size(); ++i)
{
ImageMatcher::HashPtr hash = matcher.Create(*src[i], i);
ImageMatcher::Results results;
if (!matcher.Find(hash, results))
{
matcher.Add(hash);
dst.push_back(src[i]);
}
}
}
Member Typedef Documentation
◆ View
| typedef Simd::View<Allocator> View |
An image type definition.
◆ HashPtr
◆ Results
Member Enumeration Documentation
◆ HashType
| enum HashType |
Describes size of reduced image used in image Hash.
| Enumerator | |
|---|---|
| Hash16x16 | 16x16 reduced image size. |
| Hash32x32 | 32x32 reduced image size. |
| Hash64x64 | 32x32 reduced image size. |
Member Function Documentation
◆ Empty()
| bool Empty | ( | ) | const |
Signalizes true if ImageMatcher is initialized.
- Returns
- true if ImageMatcher is initialized.
◆ Size()
| size_t Size | ( | ) | const |
Gets total number of images added to ImageMatcher.
- Returns
- total number of images added to ImageMatcher.
◆ Init()
| bool Init | ( | double | threshold = 0.05, |
| HashType | type = Hash16x16, |
||
| size_t | number = 0, |
||
| bool | normalized = false |
||
| ) |
Initializes ImageMatcher for search.
- Parameters
-
[in] threshold - a maximal mean squared difference for similar images. By default it is equal to 0.05. [in] type - a type of Hash used for matching. By default it is equal to ImageMatcher::Hash16x16. [in] number - an estimated total number of images used for matching. By default it is equal to 0. [in] normalized - a flag signalized that images have normalized histogram. By default it is false.
- Returns
- the result of the operation.
◆ Create()
Creates hash for given image.
- Parameters
-
[in] view - an input image. [in] tag - a tag of arbitrary type.
- Returns
- the smart pointer to Hash for image matching.
◆ Find()
Finds all similar images earlier added to ImageMatcher for given image.
- Parameters
-
[in] hash - a smart pointer to hash of the image. [out] results - a list of found similar images.
- Returns
- true if similar images were found.
◆ Add()
| void Add | ( | const HashPtr & | hash | ) |
Adds given image to ImageMatcher.
- Parameters
-
[in] hash - a smart pointer to hash of the image.
◆ Skip()
| void Skip | ( | const HashPtr & | hash | ) |
Skips searching of the image in ImageMatcher.
- Parameters
-
[in] hash - a smart pointer to hash of the image.
