Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data pre-processing #2

Open
priyansh1221 opened this issue Jul 15, 2023 · 1 comment
Open

Data pre-processing #2

priyansh1221 opened this issue Jul 15, 2023 · 1 comment

Comments

@priyansh1221
Copy link

Hello sir,
I'm getting difficulties in data pre-processing as the dataset is in png format and we are working on video. Please help me load data, pre-processing it, and preview it as a video or gif.
Thanks

@kaledhoshme123
Copy link
Owner

Hi @priyansh1221

  • I will give you help on how you should go about reading the videos.
  • The following example shows the mechanism by which a single video is read and the results are stored in an array.
  • You should extend the work of the script so that you can read all the videos included in the dataset, in addition to the mechanism that you can skip a specified number of frames in order to read all videos of the same length (with the same number of frames), and you can do this by reading more about VideoCapture
    Good luck
import cv2
video_file_path = ''
image_height = 60
image_width = 60
video_reader = cv2.VideoCapture(video_file_path)
success, frame = video_reader.read()
previous = frame.copy()
frames_queue = []
while video_reader.isOpened():
    ok, frame = video_reader.read()
    if not ok:
        break
    diff = cv2.absdiff(frame, previous)
    f = cv2.resize(diff, (image_height, image_width))
    f = cv2.cvtColor(f, cv2.COLOR_BGR2GRAY)
    previous = frame.copy()
    normalized_frame = f / 255
    frames_queue.append(normalized_frame)
video_reader.release()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants