Пример #1
0
    def test():
        import os
        import sys
        lib_path = os.path.abspath('../utilization/')
        sys.path.append(lib_path)

        from dir_processing import DirProcessing
        from file_op import FileOp

        LSF.build_dictionary()
        landmarks_urls = DirProcessing.get_all_landmarks_urls_from_sequence('87','4')

        test_one_sequence = True
        if test_one_sequence:
            video = LSF.lsf_from_sequence(landmarks_urls)
            print video.landmarks_urls

        test_one_landmark = False
        if test_one_landmark:
            landmarks = FileOp.read_landmarks_file(landmarks_urls[11])
            landmarks_neural = FileOp.read_landmarks_file(landmarks_urls[0])
            lsf_document = LSF.lsf(landmarks, landmarks_neural)
            landmark = landmarks[35,:]
            landmark_neural = landmarks_neural[35, :]
            word = LSF.compute_word(35, landmark, landmark_neural)
            print landmark, landmark_neural, word
    def draw_landmarks_on_sequence(img_urls):
        from dir_processing import DirProcessing
        landmarks_urls = []
        for i in xrange(0, len(img_urls)):
            img_url = img_urls[i]
            landmarks_url = DirProcessing.generate_landmarks_url_from_img_url(img_url)
            landmarks_urls.append(landmarks_url)

        from file_op import FileOp
        for i in xrange(0, len(img_urls)):
            img_url = img_urls[i]
            landmarks_url = landmarks_urls[i]
            img = FileOp.read_img_file(img_url)
            landmarks = FileOp.read_landmarks_file(landmarks_url)

            for i in xrange(0, landmarks.shape[0]):   # for every point
                loc = landmarks[i, :]
                x = int(round(loc[0]))
                y = int(round(loc[1]))
                cv2.circle(img, (x, y), 1, 255)
            
            print img_url
            cv2.imshow('image', img)

            k = cv2.waitKey(0)
            if k == 27:     # Esc key to stop
                break
        
        cv2.destroyAllWindows()
    def draw_landmarks_on_img(img_url, drawtext=False):
        from dir_processing import DirProcessing
        landmarks_url = DirProcessing.generate_landmarks_url_from_img_url(img_url)

        from file_op import FileOp
        img = FileOp.read_img_file(img_url)
        landmarks = FileOp.read_landmarks_file(landmarks_url)

        for i in xrange(0, landmarks.shape[0]):   # for every point
            loc = landmarks[i, :]
            x = int(round(loc[0]))
            y = int(round(loc[1]))
            cv2.circle(img, (x, y), 2, 255)

            if drawtext:
                cv2.putText(img, str(i), (x,y), cv2.FONT_HERSHEY_SIMPLEX, 0.25, 255)

        cv2.imshow('image',img)
        cv2.waitKey(0)
        cv2.destroyAllWindows()