Beispiel #1
0
def VidToMatrix(file, label, format, name):
    cap = cv2.VideoCapture(file)
    frames = []
    ret = True
    ret, frame = cap.read()
    all_frames = []
    frame_counter = 0
    while (ret):
        frame_counter = frame_counter + 1
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        if format == 1:
            gray = gray[40:380, 23:363]
        elif format == 2:
            gray = gray[0:340, 0:340]
            gray = np.pad(gray, ((0, 0), (0, 4)), 'constant')
        elif format == 3:
            gray = gray[0:340, 20:360]
        elif format == 4:
            gray = gray[0:340, 23:363]

        frames.append(gray)
        if frame_counter % 150 == 0:
            all_frames.append(Feature(frames, name, label))
            frames = []
        ret, frame = cap.read()

    cap.release()
    print(len(all_frames))
    return all_frames
Beispiel #2
0
def get_kotlin_features():
    features_dir = path.join(os.path.dirname(__file__), "kotlin-features")
    features = []
    for feature_meta in yaml.load(open(path.join(features_dir, "kotlin-features.yml"))):
        file_path = path.join(features_dir, feature_meta['content_file'])
        with open(file_path) as f:
            content = f.read().decode('utf-8')
            content = content.replace("\r\n", "\n")
            if file_path.endswith(".md"):
                content = jinja_aware_markdown(content, pages)
            features.append(Feature(content, feature_meta))
    return features
Beispiel #3
0
def get_kotlin_features():
    features_dir = path.join(os.path.dirname(__file__), "kotlin-features")
    features = []
    for feature_meta in yaml.load(open(path.join(features_dir, "kotlin-features.yml"))):
        file_path = path.join(features_dir, feature_meta['content_file'])
        with open(file_path, encoding='utf-8') as f:
            content = f.read()
            content = content.replace("\r\n", "\n")
            if file_path.endswith(".md"):
                html_content = BeautifulSoup(jinja_aware_markdown(content, pages), 'html.parser')
                content = process_code_blocks(html_content)
            features.append(Feature(content, feature_meta))
    return features