1

I am building a custom vision application with Microsoft's CustomVision.ai.

I am using this tutorial: https://learn.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/csharp-tutorial-od

At one point I need to:

When you tag images in object detection projects, you need to specify the region of each tagged object using normalized coordinates

And to do that I need to write the following code:

Dictionary<string, double[]> fileToRegionMap = new Dictionary<string, double[]>() {
// FileName, Left, Top, Width, Height
{"scissors_1", new double[] { 0.4007353, 0.194068655, 0.259803921, 0.6617647 } },
{"scissors_2", new double[] { 0.426470578, 0.185898721, 0.172794119, 0.5539216 } },
{"scissors_3", new double[] { 0.289215684, 0.259428144, 0.403186262, 0.421568632 } }
...

where the double is the object's normalized coordinates inside the image.

How can I get those coordinates from images? Is there a software I can use to create those coordinates and the add them to the code?

Georgia Kalyva
  • 737
  • 2
  • 9
  • 23
  • 1
    Take a look at this tutorial: [Object detection with Microsoft Custom Vision](https://www.henkboelman.com/object-detection-with-microsoft-custom-vision/) – Leon May 03 '19 at 13:36

1 Answers1

0

Normalized coordinates are coordinates that range from 0.0 to 1.0 (exclusive).

If you have an image with coordinates in the range

(X = 0..Width, Y = 0..Height)

transform the coordinates with

double x_normalized = X / Width;
double y_normalized = Y / Height;

This assumes that either the coordinate X or Y or the Width or Height is given as double or float. If they are given as int, use

double x_normalized = (double)X / Width;
double y_normalized = (double)Y / Height;

the same applies for a width or height of an object inside the image

double object_width_normalized = object_width / Width;
double object_height_normalized = object_height / Height;

Note, if the coordinates are given as int, usually they are in the range [0..Width - 1, 0..Height - 1, so that the division yields a value 0.0 <= value < 1.0.

Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188