Simd Library Documentation.

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

ContourDetector structure provides detection of contours at the image. More...

Public Types

typedef A< uint8_t > Allocator
typedef Simd::View< A > View
typedef Simd::Point< ptrdiff_t > Size
typedef Simd::Point< ptrdiff_t > Point
typedef Rectangle< ptrdiff_t > Rect
typedef std::vector< PointContour
typedef std::vector< ContourContours

Public Member Functions

void Init (Size size)
bool Detect (const View &src, Contours &contours, const View &mask=View(), uint8_t indexMin=3, const Rect &roi=Rect(), int gradientThreshold=40, int anchorThreshold=0, int anchorScanInterval=2, int minSegmentLength=2)

Detailed Description

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

ContourDetector structure provides detection of contours at the image.

Using example:

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

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

    ContourDetector::View image;

    ContourDetector contourDetector;


    ContourDetector::Contours contours;
    contourDetector.Detect(image, contours);

    for (size_t i = 0; i < contours.size(); ++i)
        for (size_t j = 1; j < contours[i].size(); ++j)
            Simd::DrawLine(image, contours[i][j - 1], contours[i][j], uint8_t(255));

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

An image size type definition.

typedef Simd::Point<ptrdiff_t> Point

A point type definition.

typedef Rectangle<ptrdiff_t> Rect

A rectangle type definition.

typedef std::vector<Point> Contour

A contour type definition.

typedef std::vector<Contour> Contours

A vector of contours type definition.

Member Function Documentation

void Init ( Size  size)

Prepares ContourDetector structure to work with image of given size.

[in]size- a size of input image.
bool Detect ( const View src,
Contours contours,
const View mask = View(),
uint8_t  indexMin = 3,
const Rect roi = Rect(),
int  gradientThreshold = 40,
int  anchorThreshold = 0,
int  anchorScanInterval = 2,
int  minSegmentLength = 2 

Detects contours at given image.

[in]src- a input image.
[out]contours- detected contours.
[in]mask- an image with the mask. It is used to restrict region of contours detection. By default it is not used.
[in]indexMin- a minimal index in the mask. By default is equal 3.
[in]roi- Region Of Interest. This is Another way to restrict region of contours detection. By default it is not used.
[in]gradientThreshold- a gradient threshold for contour detection. If this parameter is negative it will be estimated automatically. By default is equal to 40.
[in]anchorThreshold- a anchor threshold for contour detection. By default is equal to 0.
[in]anchorScanInterval- the anchor scan interval. This parameter affects to performance. By default is equal to 2.
[in]minSegmentLength- the minimal length of detected contour. By default is equal to 2.
a result of this operation.