Simd Library Documentation.

Home | Release Notes | Download | Documentation | Forum | SourceForge | GitHub
ShiftDetector< A > Struct Template Reference

ShiftDetector structure provides shift detection of given region at the image. More...

Public Types

enum  TextureType {
  TextureGray,
  TextureGrad
}
 
enum  DifferenceType {
  AbsDifference,
  SquaredDifference
}
 
typedef A< uint8_t > Allocator
 
typedef Simd::View< A > View
 
typedef Simd::Point< ptrdiff_t > Point
 
typedef Simd::Point< double > FPoint
 
typedef Rectangle< ptrdiff_t > Rect
 

Public Member Functions

void InitBuffers (const Point &frameSize, size_t levelCount, TextureType textureType=TextureGray, DifferenceType differenceType=AbsDifference)
 
void SetBackground (const View &background)
 
bool Estimate (const View &current, const Rect &region, const Point &maxShift, double hiddenAreaPenalty=0)
 
bool Estimate (const View &current, const Rect &region, int maxShift, double hiddenAreaPenalty=0)
 
Point Shift () const
 
FPoint ProximateShift () const
 
double Stability () const
 
double Correlation () const
 

Detailed Description

template<template< class > class A>
struct Simd::ShiftDetector< A >

ShiftDetector structure provides shift detection of given region at the image.

Using example:

#include "Simd/SimdShift.hpp"
#include <iostream>

int main()
{
    typedef Simd::ShiftDetector<Simd::Allocator> ShiftDetector;

    ShiftDetector::View background;
    background.Load("../../data/image/face/lena.pgm");

    ShiftDetector detector;

    detector.InitBuffers(background.Size(), 4);

    detector.SetBackground(background);

    ShiftDetector::Rect region(64, 64, 192, 192);

    ShiftDetector::View current = background.Region(region.Shifted(10, 10));

    if (detector.Estimate(current, region, 32))
        std::cout << "Shift = (" << detector.Shift().x << ", " << detector.Shift().y << "). " << std::endl;
    else
        std::cout << "Can't find shift for current image!" << std::endl;

    return 0;
}

Member Typedef Documentation

typedef A<uint8_t> Allocator

Allocator type definition.

typedef Simd::View<A> View

An image type definition.

typedef Simd::Point<ptrdiff_t> Point

A point with integer coordinates.

typedef Simd::Point<double> FPoint

A point with float point coordinates.

typedef Rectangle<ptrdiff_t> Rect

A rectangle type definition.

Member Function Documentation

void InitBuffers ( const Point frameSize,
size_t  levelCount,
TextureType  textureType = TextureGray,
DifferenceType  differenceType = AbsDifference 
)

Initializes internal buffers of ShiftDetector structure. It allows it to work with image of given size.

Parameters
[in]frameSize- a size of background image.
[in]levelCount- number of levels in the internal image pyramids used to find shift.
[in]textureType- type of textures used to detect shift.
[in]differenceType- type of correlation functions used to detect shift.
void SetBackground ( const View background)

Sets a background image. Size of background image must be equal to frameSize (see function ShiftDetector::InitBuffers).

Parameters
[in]background- background image.
bool Estimate ( const View current,
const Rect region,
const Point maxShift,
double  hiddenAreaPenalty = 0 
)

Estimates shift of current image relative to background image.

Parameters
[in]current- current image.
[in]region- a region at the background where the algorithm start to search current image. Estimated shift is taken relative of the region.
[in]maxShift- a 2D-point which characterizes maximal possible shift of the region (along X and Y axes).
[in]hiddenAreaPenalty- a parameter used to restrict searching of the shift at the border of background image.
Returns
a result of shift estimation.
bool Estimate ( const View current,
const Rect region,
int  maxShift,
double  hiddenAreaPenalty = 0 
)

Estimates shift of current image relative to background image.

Parameters
[in]current- current image.
[in]region- a region at the background where the algorithm start to search current image. Estimated shift is taken relative of the region.
[in]maxShift- a maximal distance which characterizes maximal possible shift of the region.
[in]hiddenAreaPenalty- a parameter used to restrict searching of the shift at the border of background image.
Returns
a result of shift estimation.
Point Shift ( ) const

Gets estimated integer shift of current image relative to background image.

Returns
estimated integer shift.
FPoint ProximateShift ( ) const

Gets proximate (with sub-pixel accuracy) shift of current image relative to background image.

Returns
proximate shift with sub-pixel accuracy.
double Stability ( ) const

Gets a value which characterizes stability (reliability) of found shift.

Returns
stability (reliability) of found shift.
double Correlation ( ) const

Gets the best correlation of background and current image.

Returns
the best correlation of background and current image.