Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not an issue. Asking for suggestions. How to generate bounding boxes for our dataset ? #22

Open
satendra929 opened this issue May 18, 2018 · 0 comments

Comments

@satendra929
Copy link

satendra929 commented May 18, 2018

Is there a quick way to generate bounding boxes for our own dataset ? Is there any alternative to doing it manually ?
I followed a simple approach of writing a python script to split the images into fixed size blocks and taking user input to classify

#annotation file
file = open("annotations.txt","w")
#code to split images into blocks and annotate
for filename in os.listdir("."):
    frame_small = cv2.imread(filename)
    gray = cv2.cvtColor(frame_small, cv2.COLOR_BGR2GRAY)
    shape = frame_small.shape
    height = shape[0]
    width = shape[1]
    h = 0
    w = 0
    found = False
    while (h+80 <= height) and found == False :
        while (w+105 <= width) and found == False :
            roi_gray = gray[h:h+80, w:w+105]
            cv2.imshow((str)(filename)+"split"+(str)(h)+","+(str)(w)+"--"+(str)(h+80)+","+(str)(w+105), roi_gray)
            waitkey_return = cv2.waitKey(0) 
            if waitkey_return == ord("f") :
                print ("Classified Face")
                file.write("images_local/"+(str)(filename)+","+(str)(w)+","+(str)(h)+","+(str)(w+105)
                           +","+(str)(h+80)+",Face\n")
            elif waitkey_return == ord("g") :
                print ("Classified Gesture")
                file.write("images_local/"+(str)(filename)+","+(str)(w)+","+(str)(h)+","+(str)(w+105)
                           +","+(str)(h+80)+",Gesture\n")
            else :
                print ("Classified DontCare")
            cv2.destroyAllWindows()
            w+=105
        w = 0
        h+=80
file.close()

Is there a better and faster approach ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant