Loading a Locator and Locating Objects on a New Image

This code snippet shows how to load a trained locator and how to locate objects on a new image.

C++

#include <eVision/EasyDeepLearning/EasyLocate/ELocator.h>
using namespace eVision;
using namespace eVision::EasyDeepLearning;

// Image constructor
EImageBW8 srcImage;

// Use the right type of ELocator / EInterestPointLocator, otherwise eVision will throw an error upon loading the file
// EInterestPointLocator locator;
ELocator locator;

// Load locator and image
locator.Load("locator_path");
srcImage.Load("image_path");

// Locate objects on image
ELocatorResult result = locator.Apply(srcImage);

// Iterate on results
for (ELocatorPredictedObject& object : result.GetDetectedObjects())
{
  float posX = object.GetPositionX();
  float posY = object.GetPositionY();
  std::string label = object.GetLabel();
  float probability = object.GetProbability();
}

C#

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

// Use the right type of ELocator / EInterestPointLocator, otherwise eVision will throw an error upon loading the file
// EInterestPointLocator locator = new EInterestPointLocator();
ELocator locator = new ELocator();

// Load locator and image
locator.Load("locator_path");
srcImage.Load("image_path");

// Locate objects on image
ELocatorResult result = locator.Apply(srcImage);

// Iterate on results
foreach (ELocatorPredictedObject obj in result.DetectedObjects)
{
  float posX = obj.PositionX;
  float posY = obj.PositionY;
  string label = obj.Label;
  float probability = obj.Probability;
}

Python

import eVision
from eVision import EasyDeepLearning as edl

# Image constructor
src_image = eVision.EImageBW8()

# Use the right type of ELocator / EInterestPointLocator, otherwise eVision will throw an error upon loading the file
# locator = edl.EInterestPointLocator()
locator = edl.ELocator()

# Load locator and image
locator.Load("locator_path")
src_image.Load("image_path")

# Locate objects on image
result = locator.Apply(src_image)

# Iterate on results
for object in result.DetectedObjects:
    posX = object.PositionX
    posY = object.PositionY
    label = object.Label
    probability = object.Probability