Skip to content
Snippets Groups Projects
Commit f0299c74 authored by Pathak, Ishaan's avatar Pathak, Ishaan Committed by Colbry, Dirk
Browse files

Pushing current progress on group Notebook.

parent 4be90fd1
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# <center> Video Image Data </center>
#### CMSE 495 Ford Group
This tutorial teaches the user how to input a video file, mp4 and convert each frame of the video into a jpeg image
%% Cell type:markdown id: tags:
<b> ADD </b> Instructions for setting up the environment and installing libraries needed to run the notebook. Ideally these instructions will work on Google Colabratory).
%% Cell type:markdown id: tags:
<b> ADD </b> Instructions for accessing and using the data or tool
%% Cell type:markdown id: tags:
<b> ADD </b> An overview of what data is are available in the data or tool
%% Cell type:markdown id: tags:
<b> ADD </b> An example question and visualization that that the data or tool can answer (this should be unique)
%% Cell type:code id: tags:
```
import cv2
import os
def video_to_frames(file_path, directory_path, greyscale = False):
'''This function will change a video file to a frames'''
#opening the video
vidcap = cv2.VideoCapture(file_path)
dirname = directory_path
os.makedirs(dirname, exist_ok=True)
#capturing a frame as well as a boolean value representing whether an image was properly opened
success,image = vidcap.read()
count = 0
while success:
#this is specifically for foam_segmented.avi
if greyscale:
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
#writing the image to a the directory path that was specified,
#if the path specified does not exist then it will be created
#this finctionality was added so that the images could be stored in a separate folder
cv2.imwrite(os.path.join(dirname, str(count)+".jpg"), image)
success,image = vidcap.read()
count += 1
#All the frames will be added in order
cv2.waitKey(1)
#releasing the threads
vidcap.release()
```
%% Cell type:markdown id: tags:
Example call for the function above
avi_frames('./ford_data/2D_xy.avi', "./frames/2D_xy",False)
%% Cell type:markdown id: tags:
<b> ADD </b> Proper references to any resources used to build the tutorial
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment