Search code examples
pythontensorflowobject-detection

how to get the coordinate? (tensorflow label model object detection)


HI all could someone please help me?

I want to know the rectangle coordinate

(left up and right dow) I reference this https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10/blob/master/Object_detection_webcam.py

is it need to use the 'boxes'? and how let tensorflow know which is the rectangle coordinate?

is the following right? and is it need to be int? x_left = 1280*(np.squeeze(boxes[0,0,1]))

y_left = 640 *(np.squeeze(boxes[0,0,0]))

x_right = 1280*(np.squeeze(boxes[0,0,3]))

y_right = 640 *(np.squeeze(boxes[0,0,2])) ------------------------------------------------------------------is it need to be int?

x_left = int(round(x_left))

y_left = int(round(y_left))

x_right= int(round(x_right))

y_right= #int(round(y_right))

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here


Solution

  • boxes is an array of normalized coordinates. The length of the boxes array is equal to the number of detection. For index i,

    boxes[i]=[x_left, y_left, x_right, y_right],
    

    where x_left, y_left, x_right, y_right are in the interval [0,1].

    If the image fed to the model was of height H and width W, the coordinates of the box are

    x_left = int(W*x_left)
    y_left = int(H*y_left)
    x_right = int(W*x_right)
    y_right = int(H*y_right).