diff --git a/Video-Image-Data-Tutorial/Ford_Video_Analysis.ipynb b/Video-Image-Data-Tutorial/Ford_Video_Analysis.ipynb index 90f8144c64ad0b94ace759a25ef7c5c8fe5d0e67..c65289a81d9fb1e5b632d9795fcad66fcf22e60c 100644 --- a/Video-Image-Data-Tutorial/Ford_Video_Analysis.ipynb +++ b/Video-Image-Data-Tutorial/Ford_Video_Analysis.ipynb @@ -1,44 +1,31 @@ { - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "name": "Ford_Video_Analysis.ipynb", - "provenance": [], - "collapsed_sections": [] - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, "cells": [ { "cell_type": "markdown", + "metadata": { + "id": "OqSmFS3lZj9Y" + }, "source": [ "# <center> Video Image Data </center>\n", "#### CMSE 495 Ford Group\n", "\n", "This tutorial teaches the user how to input a video file, such a mp4 and convert each frame of the video into a jpeg image using python, primarily in a Jupyter notebook." - ], - "metadata": { - "id": "OqSmFS3lZj9Y" - } + ] }, { "cell_type": "markdown", - "source": [ - "[](https://colab.research.google.com/github/pathakis/DataTools_Tutorial_Demo/blob/main/Video-Image-Data-Tutorial/Ford_Video_Analysis.ipynb)" - ], "metadata": { "id": "uey1neRTkRwd" - } + }, + "source": [ + "[](https://colab.research.google.com/github/pathakis/DataTools_Tutorial_Demo/blob/main/Video-Image-Data-Tutorial/Ford_Video_Analysis.ipynb)" + ] }, { "cell_type": "markdown", + "metadata": { + "id": "GQIJxk_kdjT1" + }, "source": [ "<b> Environment Setup (Makefile):</b>\n", "- Use the command 'make innit' automatically set up the environment for you.\n", @@ -61,33 +48,35 @@ "<b> Usage Instructions:</b>\n", "\n", "- The example call shows the format in which this func may be used.\n" - ], - "metadata": { - "id": "GQIJxk_kdjT1" - } + ] }, { "cell_type": "markdown", - "source": [ - "This process uses 2 packages called [os](https://docs.python.org/3/library/os.html) and [cv2](https://pypi.org/project/opencv-python/). Os provides miscellaneous operating system interfaces such as opening and reading the files." - ], "metadata": { "id": "f0aUW4PLdobE" - } + }, + "source": [ + "This process uses 2 packages called [os](https://docs.python.org/3/library/os.html) and [cv2](https://pypi.org/project/opencv-python/). Os provides miscellaneous operating system interfaces such as opening and reading the files." + ] }, { "cell_type": "code", - "source": [ - "# !pip install opencv-python" - ], + "execution_count": null, "metadata": { "id": "JGkN_k3BgXV8" }, - "execution_count": null, - "outputs": [] + "outputs": [], + "source": [ + "# !pip install opencv-python" + ] }, { "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "PCbpVR-HZzmt" + }, + "outputs": [], "source": [ "import cv2\n", "import os\n", @@ -128,28 +117,29 @@ " \n", " #releasing the threads\n", " vidcap.release()\n" - ], - "metadata": { - "id": "PCbpVR-HZzmt" - }, - "execution_count": null, - "outputs": [] + ] }, { + "attachments": {}, "cell_type": "markdown", + "metadata": { + "id": "hBfLcvMhh6v7" + }, "source": [ "DEMO FOR THE **avi_to_frames** \n", "\n", - "1. To download a sample avi file that you want to work with, use the following code `urllib.request.urlretrieve('https://www.engr.colostate.edu/me/facil/dynamics/files/drop.avi', 'testing.mp4')` \n", + "1. To download a sample avi file that you want to work with, use the following code `urllib.request.urlretrieve('https://file-examples.com/wp-content/uploads/2018/04/file_example_AVI_480_750kB.avi', 'testing.mp4')` \n", "\n", "2. After the video has been downloaded `avi_frames(./testing.mp4, path_to_where_you_want_the_frames, False)` this will create a folder with frames from the video." - ], - "metadata": { - "id": "hBfLcvMhh6v7" - } + ] }, { "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "-N-hJD11jJjo" + }, + "outputs": [], "source": [ "# Making a Video From Frames\n", "def frames_to_video(directory_path, fps, width, height):\n", @@ -163,15 +153,13 @@ "\n", " cv2.destroyAllWindows()\n", " video.release()" - ], - "metadata": { - "id": "-N-hJD11jJjo" - }, - "execution_count": null, - "outputs": [] + ] }, { "cell_type": "markdown", + "metadata": { + "id": "sIhvc4DplLkE" + }, "source": [ "DEMO FOR THE **frames_to_video** \n", "\n", @@ -180,46 +168,66 @@ "2. Run the following command (**make the necessary changes in the function call**)`frames_to_video(where_the_frames_are, fps, width, height)`\n", "\n", "3. The video will show up in the current directory." - ], - "metadata": { - "id": "sIhvc4DplLkE" - } + ] }, { "cell_type": "markdown", - "source": [ - "**The code below will put the image arrays into a list.** This snippet of code utilizes glob but packages like os can also be used." - ], "metadata": { "id": "bnfzxPNJeZVS" - } + }, + "source": [ + "**The code below will put the image arrays into a list.** This snippet of code utilizes glob but packages like os can also be used." + ] }, { "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "mLbqPW7SeJd-" + }, + "outputs": [], "source": [ "path = glob.glob(\"./*.jpg\")\n", "images = []\n", "for img in path:\n", " n = cv2.imread(img)\n", " images.append(n)" - ], - "metadata": { - "id": "mLbqPW7SeJd-" - }, - "execution_count": null, - "outputs": [] + ] }, { "cell_type": "markdown", + "metadata": { + "id": "GIq-_h4wdxWM" + }, "source": [ "<b> References:</b>\n", "- [Managing Environments](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)\n", "- [Open CV in python](https://pypi.org/project/opencv-python/)\n", "- [Colab Button](https://www.youtube.com/watch?v=RoGZIbwzG5w)" - ], - "metadata": { - "id": "GIq-_h4wdxWM" + ] + } + ], + "metadata": { + "colab": { + "collapsed_sections": [], + "name": "Ford_Video_Analysis.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "base", + "language": "python", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.9.15" + }, + "vscode": { + "interpreter": { + "hash": "4f3567101b31d35f97cf2856951ebbba1e09a3f852422478e736adda2bb3beee" } } - ] -} \ No newline at end of file + }, + "nbformat": 4, + "nbformat_minor": 0 +}