Detect Spots

This code snippet shows how to detect particles in an image with EasySpotDetector.

C++

#include <eVision/EasySpotDetector/ESpotDetector.h>
using namespace eVision;

// Image constructor
EImageBW8 srcImage;

// Spot detector constructor
ESpotDetector detector;

// Setup the particle detector parameters with adequate values
EParticleDetectionParameters detectionParams;
detectionParams.Polarity = ESpotPolarity_Black;
detectionParams.Threshold = 12;
detectionParams.MinSize = 5;
detectionParams.MaxSize = 50;
detectionParams.MinArea = 25;
detector.SetParticleDetectionParameters(detectionParams);

// Activate the particle detection
detector.SetEnableParticleDetection(true);

// Perform the detection and get the number of detected spots
int32_t nSpot = detector.Detect(srcImage);

// Finally, get the detected spots
std::vector<ESpot> spots = detector.GetSpots();

C#

using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();

// Spot detector constructor
ESpotDetector detector = new ESpotDetector();

// Setup the particle detector parameters with adequate values
EParticleDetectionParameters detectionParams;
detectionParams.Polarity = ESpotPolarity.Black;
detectionParams.Threshold = 12;
detectionParams.MinSize = 5;
detectionParams.MaxSize = 50;
detectionParams.MinArea = 25;
detector.ParticleDetectionParameters = detectionParams;

// Activate the particle detection
detector.EnableParticleDetection = true;

// Perform the detection and get the number of detected spots
uint nSpot = detector.Detect(srcImage);

// Finally, get the detected spots
ESpot[] spots = detector.Spots;

Python

import eVision

# Image constructor
srcImage = eVision.EImageBW8()

# QR code reader constructor
detector = eVision.ESpotDetector()

# Setup the particle detector parameters with adequate values
detectionParams = eVision.EParticleDetectionParameters()
detectionParams.Polarity = eVision.ESpotPolarity.Black
detectionParams.Threshold = 12
detectionParams.MinSize = 5
detectionParams.MaxSize = 50
detectionParams.MinArea = 25
detector.ParticleDetectionParameters = detectionParams

# Activate the particle detection
detector.EnableParticleDetection = True

# Perform the detection and get the number of detected spots
nSpot = detector.Detect(srcImage)

# Finally, get the detected spots
spots = detector.Spots