Implement pytorch dataset for own collected data
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user