rykov8 / ssd_keras

Port of Single Shot MultiBox Detector to Keras
MIT License
1.1k stars 553 forks source link

How to Store Coordinates only once? #146

Open fdkssdks opened 6 years ago

fdkssdks commented 6 years ago

Hello, I am interested to know if there's a way to store the coordinates of the detected object only once?

So, when the detection is running it keeps on detecting the object and keeps on appending the coordinate of the same objects again and again(I am using CSV file to write the coordinates). Though there's a slight delta in the coordinates that doesn't matter for now since the object is stationary.

This is what I've now.

    for box in y_pred_thresh[0]:
        # Transform the predicted bounding boxes for the 300x300 image to the original image dimensions.
        xmin = box[2] * 300 / img_width
        ymin = box[3] * 300 / img_height
        xmax = box[4] * 300 / img_width
        ymax = box[5] * 300 / img_height
        cv2.rectangle(smallFrame, (int(xmin),int(ymin)),(int(xmax),int(ymax)),(0,250,0), thickness=1,lineType=8)
        xcenter=((xmin+xmax)/2) #For center X
        ycenter=((ymin+ymax)/2) #For center Y
        csv.write(round(xcenter)+ ' , ' + round(ycenter))
        csv.write('\n')
        csv.close()
        cv2.waitKey(0)
    return (y_pred_thresh)          

Any help is appreciated. Thanks

* Operating System Ubuntu 16.04
* Which commit of this repository you're on: Latest
* Keras version: 2.2.0
* TensorFlow version: 1.9.0

If someone knows what kind of coordinates do we get? Is it pixel coordinate or something else? How can I convert it to Robot Coordinate that is in X Y Z?