Exemplo n.º 1
0
def enrichEmbed(img1,img2,img3):
    img1_location = api.human_locations(img1)
    img2_location = api.human_locations(img2)
    img3_location = api.human_locations(img3)

    img_1_human = api.crop_human(img1, img1_location)
    img_2_human = api.crop_human(img2, img2_location)
    img_3_human = api.crop_human(img3, img3_location)

    human_1_1 = img_1_human[0]
    # plt.imshow(human_1_1)

    human_1_2 = img_2_human[0]
    # plt.imshow(human_1_2)

    # human 1 photo 2
    human_1_3 = img_3_human[0]
    # plt.imshow(human_1_3)


    human_1_1_vector = api.human_vector(human_1_1)
    human_1_2_vector = api.human_vector(human_1_2)
    human_1_3_vector = api.human_vector(human_1_3)

    return (human_1_1_vector +human_1_2_vector +human_1_3_vector )/3
def video_reid(path):
    arr = []
    cap = cv2.VideoCapture(path)
    frame_height = int(cap.get(4))
    frame_width = int(cap.get(3))
    fps = int(cap.get(5))
    fourcc = cv2.VideoWriter_fourcc(*'VP80')
    base = os.path.basename(path)
    filename = os.path.splitext(base)[0]
    out = cv2.VideoWriter('../Output_Videos/' + filename + '.webm', fourcc,
                          fps, (frame_width, frame_height))
    videoOn = True
    while (videoOn):
        ret, frame = cap.read()
        if (ret == False):
            break
        img_location = api.human_locations(frame)
        img_human = api.crop_human(frame, img_location)
        for j in range(len(img_human)):
            frame = draw_box(frame, img_location[j],
                             find(img_human[j], '../Identity_Gallery/new'))
        out.write(frame)
    cap.release()
    out.release()
    print('end')
    return 'F://Output_Videos//' + filename + '.webm'
    def video_reid(self, path):

        arr = []
        cap = cv2.VideoCapture(path)
        frame_height = int(cap.get(4))
        frame_width = int(cap.get(3))
        fps = int(cap.get(5))
        fourcc = cv2.VideoWriter_fourcc(*'VP80')
        base = os.path.basename(path)
        filename = os.path.splitext(base)[0]
        out = cv2.VideoWriter('../Output_Videos/' + filename + '.webm', fourcc,
                              fps, (frame_width, frame_height))
        videoOn = True
        past_ppl = '../Identity_Gallery/3person'
        while (videoOn):
            ret, frame = cap.read()
            if (ret == False):
                break
            arr = []
            img_location = api.human_locations(frame)
            img_human = api.crop_human(frame, img_location)
            for j in range(len(img_human)):
                arr.append(self.find(img_human[j], past_ppl))
            frame = self.draw_boxes(frame, img_location, arr)
            cv2.imshow('Video', frame)
            if cv2.waitKey(1) & 0xFF == ord('q'):
                break
            out.write(frame)
        cap.release()
        out.release()
        cv2.destroyAllWindows()
        print('end')
        return 'F://Output_Videos//' + filename + '.webm'
Exemplo n.º 4
0
def image_reid(path):
    arr = []
    img = cv2.imread(path)
    img_location = api.human_locations(img)
    img_human = api.crop_human(img, img_location)
    for j in range(len(img_human)):
        folder_number = find(img_human[j])
        print(folder_number)
        arr.append(folder_number)
    cv2.imshow('frame', draw_boxes(img, img_location, arr))
    cv2.waitKey(0)
Exemplo n.º 5
0
def video_reid(path, name, past_ppl):
    arr = []
    cap = cv2.VideoCapture(path + name)
    frame_height = int(cap.get(4))
    frame_width = int(cap.get(3))
    fps = int(cap.get(5))
    fourcc = cv2.VideoWriter_fourcc(*'MP4V')
    out = cv2.VideoWriter('../Output_Videos/' + name, fourcc, fps,
                          (frame_width, frame_height))
    videoOn = True
    while (videoOn):
        ret, frame = cap.read()
        if (ret == False):
            break
        img_location = api.human_locations(frame)
        img_human = api.crop_human(frame, img_location)
        arr = []
        for j in range(len(img_human)):
            arr.append(find(img_human[j], past_ppl))
        frame = draw_boxes(frame, img_location, arr)
        out.write(frame)
    cap.release()
    out.release()
    print('end')
Exemplo n.º 6
0
#plt.ion()
# get_ipython().run_line_magic('matplotlib', 'inline')

# # Find human location by using MobilenetSSD

# In[2]:

img1 = cv2.imread('test/test1.png')[:, :, ::-1]
img2 = cv2.imread('test/test2.png')[:, :, ::-1]
img3 = cv2.imread('test/test3.png')[:, :, ::-1]

img1_location = api.human_locations(img1)
img2_location = api.human_locations(img2)
img3_location = api.human_locations(img3)

img_1_human = api.crop_human(img1, img1_location)
img_2_human = api.crop_human(img2, img2_location)
img_3_human = api.crop_human(img3, img3_location)

# In[3]:

# human 1 photo 1
human_1_1 = img_1_human[0]
plt.imshow(human_1_1)

# In[4]:

# human 1 photo 2
human_1_2 = img_2_human[0]
plt.imshow(human_1_2)