Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub | SourceForge
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;
    image.Load("../../data/image/face/lena.pgm");

    ContourDetector contourDetector;

    contourDetector.Init(image.Size());

    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));
    }
    image.Save("result.pgm");

    return 0;
}

Member Typedef Documentation

◆ Allocator

typedef A<uint8_t> Allocator

Allocator type definition.

◆ View

typedef Simd::View<A> View

An image type definition.

◆ Size

typedef Simd::Point<ptrdiff_t> Size

An image size type definition.

◆ Point

typedef Simd::Point<ptrdiff_t> Point

A point type definition.

◆ Rect

typedef Rectangle<ptrdiff_t> Rect

A rectangle type definition.

◆ Contour

typedef std::vector<Point> Contour

A contour type definition.

◆ Contours

typedef std::vector<Contour> Contours

A vector of contours type definition.

Member Function Documentation

◆ Init()

void Init ( Size  size)

Prepares ContourDetector structure to work with image of given size.

Parameters
[in]size- a size of input image.

◆ Detect()

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.

Parameters
[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.
Returns
a result of this operation.