face_net = net.face_detection() landmark_net = net.face_lanmark() face_reid_net = net.face_reid() body_net = myCV.Net("mo_mobilenet-ssd.xml", "mo_mobilenet-ssd.bin", (300, 300)) frame = cv2.imread('2.jpg') faces_data = {} img = frame.copy() cv2.imshow('Input', frame) cv2.waitKey(0) n = 0 # 15 = person id in mobilessd list bodies = myCV.detect(body_net, frame, 0.7, 15) for bxmin, bymin, bxmax, bymax in bodies: cv2.rectangle(img, (bxmin, bymin), (bxmax, bymax), (255, 255, 0), 2) bchip = frame[bymin:bymax, bxmin:bxmax] n += 1 cv2.imshow('Person{}'.format(n), bchip) cv2.waitKey(0) face = myCV.detect(face_net, bchip, 0.7) for fxmin, fymin, fxmax, fymax in face: fxmin += bxmin fymin += bymin fxmax += bxmin fymax += bymin
BODY_NET = net.mobilenet_ssd() # Dictionary for face descriptors face_database = {} frame = cv2.imread(args.img) cv2.imshow('Input', frame) cv2.waitKey(0) # Copy the input image for continuing processing img = frame.copy() n = 0 # Detect bodies from the input image # 15 = person id in mobilessd list bodies = myCV.detect(BODY_NET, frame, 0.7, 15) for bxmin, bymin, bxmax, bymax in bodies: cv2.rectangle(img, (bxmin, bymin), (bxmax, bymax), (255, 255, 0), 2) # Crop body area from frame bcrop = frame[bymin:bymax, bxmin:bxmax] n += 1 cv2.imshow('Person{}'.format(n), bcrop) cv2.waitKey(0) # Detect faces from the the body crop image face = myCV.detect(FACE_NET, bcrop, 0.7) for fxmin, fymin, fxmax, fymax in face: fxmin += bxmin fymin += bymin
# Dictionary for face descriptors face_database = {} while True: counter.stop() counter.start() grab, frame = STREAM.read() if not grab: raise Exception('Image not found') # Copy the input image for continuing processing img = frame.copy() # Detecting faces from the input image faces = myCV.detect(FACE_NET, frame, 0.7) for fxmin, fymin, fxmax, fymax in faces: cv2.rectangle(img, (fxmin, fymin), (fxmax, fymax), (255, 255, 0), 2) # Crop face area from frame fcrop = frame[fymin:fymax, fxmin:fxmax] # Search and draw facial landmarks dots = myCV.get_landmarks(LANDMARK_NET, fcrop, (fxmin, fymin)) for x, y in dots: cv2.circle(img, (x, y), 3, (255, 0, 255), -1) # Transfrom the face to improve recognition fcrop = myCV.face_transform(fcrop) # Getting facial descriptor
bodies_database = {} while True: counter.stop() counter.start() grab, frame = STREAM.read() if not grab: raise Exception('Frame not found') # Copy the input image for continuing processing img = frame.copy() # Detect bodies from the input image # 15 = person id in mobilessd list bodies = myCV.detect(BODY_NET, frame, 0.7, 15) for bxmin, bymin, bxmax, bymax in bodies: cv2.rectangle(img, (bxmin, bymin), (bxmax, bymax), (255, 255, 0), 2) # Crop body area from frame bcrop = frame[bymin:bymax, bxmin:bxmax] # Getting body descriptor body_features = myCV.get_descriptor(BODY_REID_NET, bcrop) # Searching the body in body_database ID, distance = myCV.object_in_database(body_features, bodies_database, 0.5) # If our database dont contain the body add it if not ID: