Search code examples
google-cloud-platformgoogle-cloud-automl

Google Cloud AutoML Object Detection export CSV object positions


I've labelled objects on images with Google Cloud AutoML label tool. Than I've exported csv file. Here is the output:

TRAIN,gs://optik-vcm/optikic/80-2020-03-19T11:58:25.819Z.jpg,kenarcizgi,0.92590326,0.035908595,0.9589712,0.035908595,0.9589712,0.9020675,0.92590326,0.9020675

On the beauty, it's like that:

TRAIN
gs://optik-vcm/optikic/80-2020-03-19T11:58:25.819Z.jpg
kenarcizgi
0.92590326
0.035908595
0.9589712
0.035908595
0.9589712
0.9020675
0.92590326
0.9020675

I know first three columns.

I'll increase the images count by making data augmentation. I'll use OpenCV in Python for that. But I need coordinates of objects on the image.

How can I convert these decimals to pixel coordinations? Or is there any calculation for that?


Solution

  • These are called a NormalizedVertex.

    A vertex represents a 2D point in the image. The normalized vertex coordinates are between 0 to 1 fractions relative to the original plane (image, video). E.g. if the plane (e.g. whole image) would have size 10 x 20 then a point with normalized coordinates (0.1, 0.3) would be at the position (1, 6) on that plane.

    To get a pixel coordinate, you can multiply that number by your input width or length as appropriate.


    The entire reference for the CSV formatting explains the following (truncated) makes up each row (one row per bounding box or per image):

    • TRAIN - Which set to assign the content in this row to
    • gs://optik-vcm/... - Google Cloud Storage URI
    • kenarcizgi - A label that identifies how the object is categorized
    • A bounding box for an object in the image:
      • x_relative_min, y_relative_min, x_relative_max, y_relative_min, x_relative_max, y_relative_max, x_relative_min, y_relative_max