Simd Library Documentation.

Home | Release Notes | Download | Documentation | Forum | SourceForge | GitHub

The Detection structure provides object detection with using of HAAR and LBP cascade classifiers. More...

Data Structures

struct  Object
 The Object structure describes detected object. More...

Public Types

typedef A< uint8_t > Allocator
typedef Simd::View< A > View
typedef Simd::Point< ptrdiff_t > Size
typedef std::vector< SizeSizes
typedef Simd::Rectangle< ptrdiff_t > Rect
typedef std::vector< RectRects
typedef int Tag
typedef std::vector< ObjectObjects

Public Member Functions

 Detection ()
 ~Detection ()
bool Load (const std::string &path, Tag tag=UNDEFINED_OBJECT_TAG)
bool Init (const Size &imageSize, double scaleFactor=1.1, const Size &sizeMin=Size(0, 0), const Size &sizeMax=Size(INT_MAX, INT_MAX), const View &roi=View(), ptrdiff_t threadNumber=-1)
bool Detect (const View &src, Objects &objects, int groupSizeMin=3, double sizeDifferenceMax=0.2, bool motionMask=false, const Rects &motionRegions=Rects())

Static Public Attributes

static const Tag UNDEFINED_OBJECT_TAG = -1

Detailed Description

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

The Detection structure provides object detection with using of HAAR and LBP cascade classifiers.

Using example:

#include "Simd/SimdDetection.hpp"
#include "Simd/SimdDrawing.hpp"

int main()
    typedef Simd::Detection<Simd::Allocator> Detection;

    Detection::View image;

    Detection detection;



    Detection::Objects objects;
    detection.Detect(image, objects);

    for (size_t i = 0; i < objects.size(); ++i)
        Simd::DrawRectangle(image, objects[i].rect, uint8_t(255));


    return 0;   
This is wrapper around low-level Object Detection API.

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> Size

An image size type definition.

typedef std::vector<Size> Sizes

A vector of image sizes type definition.

typedef Simd::Rectangle<ptrdiff_t> Rect

A rectangle type definition.

typedef std::vector<Rect> Rects

A vector of rectangles type definition.

typedef int Tag

A tag type definition.

typedef std::vector<Object> Objects

A vector of objects type defenition.

Constructor & Destructor Documentation

Detection ( )

Creates a new empty Detection structure.

~Detection ( )

A Detection destructor.

Member Function Documentation

bool Load ( const std::string &  path,

Loads from file classifier cascade. Supports OpenCV HAAR and LBP cascades type. You can call this function more than once if you want to use several object detectors at the same time.

Tree based cascades and old cascade formats are not supported!
[in]path- a path to cascade.
[in]tag- an user defined tag. This tag will be inserted in output Object structure.
a result of this operation.
bool Init ( const Size imageSize,
double  scaleFactor = 1.1,
const Size sizeMin = Size(0, 0),
const Size sizeMax = Size(INT_MAX, INT_MAX),
const View roi = View(),
ptrdiff_t  threadNumber = -1 

Prepares Detection structure to work with image of given size.

[in]imageSize- a size of input image.
[in]scaleFactor- a scale factor. To detect objects of different sizes the algorithm uses many scaled image. This parameter defines size difference between neighboring images. This parameter strongly affects to performance.
[in]sizeMin- a minimal size of detected objects. This parameter strongly affects to performance.
[in]sizeMax- a maximal size of detected objects.
[in]roi- a 8-bit image mask which defines Region Of Interest. User can restricts detection region with using this mask. The mask affects to the center of detected object.
[in]threadNumber- a number of work threads. It useful for multi core CPU. Use value -1 to auto choose of thread number.
a result of this operation.
bool Detect ( const View src,
Objects objects,
int  groupSizeMin = 3,
double  sizeDifferenceMax = 0.2,
bool  motionMask = false,
const Rects motionRegions = Rects() 

Detects objects at given image.

[in]src- a input image.
[out]objects- detected objects.
[in]groupSizeMin- a minimal weight (number of elementary detections) of detected image.
[in]sizeDifferenceMax- a parameter to group elementary detections.
[in]motionMask- an using of motion detection flag. Useful for dynamical restriction of detection region to addition to ROI.
[in]motionRegions- a set of rectangles (motion regions) to restrict detection region to addition to ROI. The regions affect to the center of detected object.
a result of this operation.

Field Documentation


The undefined object tag.