Tuesday, 9 November 2021

Face Landmark Annotation Tool

 import cv2

pts = []
count = 0
def click_event(event,x,y,flags,params):
    if event == cv2.EVENT_LBUTTONDOWN:
        pts.append([x,y])
        font = cv2.FONT_HERSHEY_SIMPLEX
        cv2.circle(img, (x,y), 2, (0,255,0))
        cv2.putText(img,str(len(pts)-1),(x,y),font,0.5,(255,0,0),1)
        print(pts)

        cv2.imshow('image',img)
    if event == cv2.EVENT_RBUTTONDOWN:
        pts.pop()

if __name__ =="__main__":
    img = cv2.imread('/home/ccng/a2e/face-analysis-sdk/build/bin/afanqi.jpg',1)

    cv2.imshow('image',img)

    cv2.setMouseCallback('image',click_event)

    cv2.waitKey(0)

    cv2.destroyAllWindows()