Implement pytorch dataset for own collected data

This commit is contained in:
Victor Mylle
2023-02-27 13:34:26 +00:00
parent 97ede38e3a
commit 8e5957f4ff
7 changed files with 99 additions and 7 deletions

View File

@@ -1,12 +1,14 @@
import mediapipe as mp
import cv2
import time
from typing import Dict, List, Tuple
import numpy as np
import logging
import os
import time
from typing import Dict, List, Tuple
import cv2
import mediapipe as mp
import numpy as np
import pandas as pd
class KeypointExtractor:
def __init__(self, video_folder: str, cache_folder: str = "cache"):
self.mp_drawing = mp.solutions.drawing_utils
@@ -52,7 +54,18 @@ class KeypointExtractor:
keypoints_df = pd.DataFrame(columns=self.columns)
# extract frames from video so we extract 5 frames per second
frame_rate = int(cap.get(cv2.CAP_PROP_FPS))
frame_skip = frame_rate // 5
while cap.isOpened():
# skip frames
for _ in range(frame_skip):
success, image = cap.read()
if not success:
break
success, image = cap.read()
if not success:
break