Skip to content

Commit

Permalink
getting prepared for tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
InfantLab committed Mar 6, 2021
1 parent 38617e3 commit de49ded
Show file tree
Hide file tree
Showing 9 changed files with 283 additions and 841 deletions.
28 changes: 19 additions & 9 deletions Step0.GettingStarted.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@
"source": [
"### 0.0 - Jupyter notebook environment\n",
"\n",
"*If you can read this you are probably already running Jupyter. Congratulations!*\n",
"*If you can read this you are probably already running [Jupyter](https://jupyter.org/). Congratulations!*\n",
"\n",
"We recommend using the Anaconda Data Science platform (Python 3 version) \n",
"There's a [getting started guide](https://jupyter.readthedocs.io/en/latest/content-quickstart.html) at the [Jupyter documentation page](https://jupyter.readthedocs.io/en/latest/index.html)\n",
"\n",
"https://www.anaconda.com/distribution/\n"
"If you're impatient we recommend using the Anaconda Data Science platform (Python 3 version) \n",
"https://www.anaconda.com/distribution/\n",
"\n",
"and then running the command\n",
"```\n",
"conda install -c conda-forge jupyterlab\n",
"```\n",
"\n",
"These notebooks will run in the original Jupyter Notebook format or with the newer JupyterLab interface. We recommend the latter. "
]
},
{
Expand All @@ -37,14 +45,16 @@
"\n",
"Additionally, you need to download the trained neural-network models that OpenPose uses. To do this go to the `models` subdirectory of OpenPose directory, and double-click / run the `models.bat` script.\n",
"\n",
"The `openposedemo` bin/exe file can be run manually from the command line. It is worth trying this first so you understand what `openposedemo` is. See [this guide](https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/demo_overview.md) or open a terminal app or Windows Powershell, navigate to the openpose installation folder and then try this command\n",
"The `openposedemo` bin/exe file can be run manually from the command line. It is worth trying this first so you understand what `openposedemo` is. See [this guide](https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/demo_overview.md) or open a terminal app or Windows Powershell, navigate to the openpose installation folder and then try this command \n",
"\n",
"```\n",
":: Windows\n",
"bin\\OpenPoseDemo.exe --video examples\\media\\video.avi --write_json output\n",
"# Mac/Linux\n",
"./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_json output\n",
"```"
"```\n",
"\n",
"Changing the `examples\\media\\video.avi` to the path to another video on your machine will process that instead. "
]
},
{
Expand All @@ -55,14 +65,14 @@
"\n",
"There are a handful of python libraries that we use for things like image manipulation, file operations, maths and stats. Many are probably already installed by default such as `os, math, numpy, pandas, matplotlib`. Others need adding to our python environment. \n",
"\n",
"PyArrow is a useful extension for saving Pandas and NumPy data. We need it to move the large array created in Step 2 to Step 3. \n",
"For example, `PyArrow` is a useful extension for saving Pandas and NumPy data. We need it to move the large array created in Step 2 to Step 3. \n",
"\n",
"**If you are using conda then run the following command to install all the main libraries.**\n",
"```\n",
"conda install glob2 opencv pyarrow xlrd openpyxl\n",
"```\n",
"#### Troubleshooting\n",
"If when you run the code in Steps 1, 2 & 3 you might see an error like `ModuleNotFoundError: No module named 'glob'` this is because that python module needs to be installed on your computer. If you use Anaconda, the missing module can usually be installed with the command `conda install glob`."
"When you run the code in Steps 1, 2 & 3 you might see an error like `ModuleNotFoundError: No module named 'glob'` this is because that python module needs to be installed on your computer. If you use Anaconda, the missing module can usually be installed with the command `conda install glob`. You then need to restart the script with the problem by choosing `Restart kernel..` from the Kernel menu dropdown."
]
},
{
Expand Down Expand Up @@ -96,7 +106,7 @@
"source": [
"### 0.4 - JupyText \n",
"\n",
"The standard ipython notebook format (`mynotebook.ipynb`) is a single file that mixes together code, formatting commands and outputs both as the results of running code and embedded binaries (images, graphs). This makes it non-human readable and very hard to tell what changes from one improvement to the next. `Jupytext` solves this by creating a synchronised plain text version of the file saved as a plain `.py` file (`mynotebook.py`). These are useful for developers (as it helps you track differences between versions more easily) but can mostly be ignored by users. \n",
"The standard ipython notebook format (`mynotebook.ipynb`) is a single file that mixes together code, formatting commands and outputs both as the results of running code and embedded binaries (images, graphs). This makes it non-human readable and very hard to tell what changed from one version to the next. `Jupytext` solves this by creating a synchronised plain text version of the file saved as a plain `.py` file (`mynotebook.py`). These are useful for developers (as it helps you track differences between versions more easily) but can mostly be ignored by users. \n",
"\n",
"\n",
"Install JupyText by running\n",
Expand All @@ -108,7 +118,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 0.6 Notebook extensions (optional)\n",
"### 0.5 Notebook extensions (optional)\n",
"Installing Jupyter notebook extenstions provide some useful tools for navigating notebooks (e.g. table of contents) and other features.\n",
"\n",
"To install, run these commands in terminal window.\n",
Expand Down
23 changes: 16 additions & 7 deletions Step0.GettingStarted.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,49 @@

# ### 0.0 - Jupyter notebook environment
#
# *If you can read this you are probably already running Jupyter. Congratulations!*
# *If you can read this you are probably already running [Jupyter](https://jupyter.org/). Congratulations!*
#
# We recommend using the Anaconda Data Science platform (Python 3 version)
# There's a [getting started guide](https://jupyter.readthedocs.io/en/latest/content-quickstart.html) at the [Jupyter documentation page](https://jupyter.readthedocs.io/en/latest/index.html)
#
# If you're impatient we recommend using the Anaconda Data Science platform (Python 3 version)
# https://www.anaconda.com/distribution/
#
# and then running the command
# ```
# conda install -c conda-forge jupyterlab
# ```
#
# These notebooks will run in the original Jupyter Notebook format or with the newer JupyterLab interface. We recommend the latter.

# ### 0.1 - OpenPoseDemo application
#
# Next we need to download and install the [OpenPoseDemo](https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/demo_overview.md) executable.
#
# Additionally, you need to download the trained neural-network models that OpenPose uses. To do this go to the `models` subdirectory of OpenPose directory, and double-click / run the `models.bat` script.
#
# The `openposedemo` bin/exe file can be run manually from the command line. It is worth trying this first so you understand what `openposedemo` is. See [this guide](https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/demo_overview.md) or open a terminal app or Windows Powershell, navigate to the openpose installation folder and then try this command
# The `openposedemo` bin/exe file can be run manually from the command line. It is worth trying this first so you understand what `openposedemo` is. See [this guide](https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/demo_overview.md) or open a terminal app or Windows Powershell, navigate to the openpose installation folder and then try this command
#
# ```
# :: Windows
# bin\OpenPoseDemo.exe --video examples\media\video.avi --write_json output
# # Mac/Linux
# ./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_json output
# ```
#
# Changing the `examples\media\video.avi` to the path to another video on your machine will process that instead.

# ### 0.2 - Load python libraries
#
# There are a handful of python libraries that we use for things like image manipulation, file operations, maths and stats. Many are probably already installed by default such as `os, math, numpy, pandas, matplotlib`. Others need adding to our python environment.
#
# PyArrow is a useful extension for saving Pandas and NumPy data. We need it to move the large array created in Step 2 to Step 3.
# For example, `PyArrow` is a useful extension for saving Pandas and NumPy data. We need it to move the large array created in Step 2 to Step 3.
#
# **If you are using conda then run the following command to install all the main libraries.**
# ```
# conda install glob2 opencv pyarrow xlrd openpyxl
# ```
# #### Troubleshooting
# If when you run the code in Steps 1, 2 & 3 you might see an error like `ModuleNotFoundError: No module named 'glob'` this is because that python module needs to be installed on your computer. If you use Anaconda, the missing module can usually be installed with the command `conda install glob`.
# When you run the code in Steps 1, 2 & 3 you might see an error like `ModuleNotFoundError: No module named 'glob'` this is because that python module needs to be installed on your computer. If you use Anaconda, the missing module can usually be installed with the command `conda install glob`. You then need to restart the script with the problem by choosing `Restart kernel..` from the Kernel menu dropdown.

# ### 0.3 - iPyWidgets
#
Expand All @@ -82,14 +91,14 @@

# ### 0.4 - JupyText
#
# The standard ipython notebook format (`mynotebook.ipynb`) is a single file that mixes together code, formatting commands and outputs both as the results of running code and embedded binaries (images, graphs). This makes it non-human readable and very hard to tell what changes from one improvement to the next. `Jupytext` solves this by creating a synchronised plain text version of the file saved as a plain `.py` file (`mynotebook.py`). These are useful for developers (as it helps you track differences between versions more easily) but can mostly be ignored by users.
# The standard ipython notebook format (`mynotebook.ipynb`) is a single file that mixes together code, formatting commands and outputs both as the results of running code and embedded binaries (images, graphs). This makes it non-human readable and very hard to tell what changed from one version to the next. `Jupytext` solves this by creating a synchronised plain text version of the file saved as a plain `.py` file (`mynotebook.py`). These are useful for developers (as it helps you track differences between versions more easily) but can mostly be ignored by users.
#
#
# Install JupyText by running
#
# ```conda install -c conda-forge jupytext```

# ### 0.6 Notebook extensions (optional)
# ### 0.5 Notebook extensions (optional)
# Installing Jupyter notebook extenstions provide some useful tools for navigating notebooks (e.g. table of contents) and other features.
#
# To install, run these commands in terminal window.
Expand Down
52 changes: 19 additions & 33 deletions Step1.ProcessVideo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@
"outputs": [],
"source": [
"# location of openposedemo - THIS WILL BE DIFFERENT ON YOUR COMPUTER\n",
"# openposepath = \"C:\\\\Users\\\\cas\\\\openpose-1.7.0-binaries-win64-gpu-python3.7-flir-3d_recommended\\\\\"\n",
"# I've had problems with version 1.7.0 so i'm staying with version 1.5.0 for the moment.\n",
"openposepath = \"C:\\\\Users\\\\cas\\\\openpose-1.5.0-binaries-win64-gpu-python-flir-3d_recommended\\\\\"\n",
"#openposepath = \"C:\\\\Users\\\\caspar\\\\openpose-1.4.0-win64-cpu-binaries\\\\\"\n",
"\n",
"if sys.platform == \"win32\":\n",
" app = \"bin\\\\OpenPoseDemo.exe\"\n",
Expand Down Expand Up @@ -100,10 +101,10 @@
"metadata": {},
"outputs": [],
"source": [
"# where's the project folder? (with trailing slash)\n",
"#projectpath = os.getcwd() + \"\\\\..\\\\Sangath\"\n",
"projectpath = \"C:\\\\Users\\\\cas\\\\OneDrive - Goldsmiths College\\\\Projects\\\\Measuring Responsive Caregiving\\\\Sangath\"\n",
"videos_in = \"\\\\\\\\192.168.0.50\\\\Videos\\\\Obs Feeding videos _1.3.17\\\\\" \n",
"# where's the project data folder? (without trailing slash)\n",
"projectpath = \"C:\\\\Users\\\\cas\\\\OneDrive - Goldsmiths College\\\\Projects\\\\Measuring Responsive Caregiving\\\\VASCTutorial\"\n",
"#where are your video files? \n",
"videos_in = \"C:\\\\Users\\\\cas\\\\OneDrive - Goldsmiths College\\\\Projects\\\\Measuring Responsive Caregiving\\\\VASCTutorial\\\\demovideos\"\n",
"\n",
"# locations of videos and output\n",
"# videos_out = \"E:\\\\SpeakNSign\\\\\" + \"out\"\n",
Expand Down Expand Up @@ -152,20 +153,12 @@
" print(\"Creating new videos.json\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"videos_out"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### EITHER 1.4.2 Read an Excel file of videos\n",
"### EITHER\n",
"### 1.4.2.A Read an Excel file of videos\n",
"\n",
"We expect the first column of the spreadsheet to tell us the base name for each participant and columns 2 to 4 contains the full name and location of the videos.\n",
"\n",
Expand Down Expand Up @@ -246,11 +239,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Or 1.4.3 scanning all videos in particular folder \n",
"### Or \n",
"### 1.4.3.B scanning all videos in particular folder \n",
"\n",
"In which case we look at all videos in `videos_in` and it's subfolders. \n",
"\n",
"In which case we look at all videos in `videos_in` let the names of the files also provide the base names for each participant we create. \n",
"We let the names of the files also provide the base names for each participant we create. \n",
"\n",
"We will reference these files by the video names so myvid1.avi is found in `videos[\"myvid1\"]`.\n",
"We will reference these files by the video names in our `videos.json` data structure. So myvid1.avi is found in `videos[\"myvid1\"]`.\n",
"\n",
"However, in other cases we will allow for possibility of multiple camera angles so this defaults to `\"camera1\"`.\n",
"\n",
Expand All @@ -263,20 +259,10 @@
"metadata": {},
"outputs": [],
"source": [
"threegps = glob.glob(videos_in + \"./*/*.3gp\", recursive = True)\n",
"print(threegps)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#first get list of videos in the inbox\n",
"avis = glob.glob(videos_in + \"./*/*.avi\", recursive = True)\n",
"mp4s = glob.glob(videos_in + \"./*/*.mp4\", recursive = True)\n",
"threegps = glob.glob(videos_in + \"./*/*.3gp\", recursive = True)\n",
"#first get list of videos in the video folder and subfolders.\n",
"avis = glob.glob(videos_in + \"/**/*.avi\", recursive = True)\n",
"mp4s = glob.glob(videos_in + \"/**/*.mp4\", recursive = True)\n",
"threegps = glob.glob(videos_in + \"/**/*.3gp\", recursive = True)\n",
"\n",
"print(\"We found %d avis\" % len(avis))\n",
"print(\"We found %d mp4s\" % len(mp4s))\n",
Expand All @@ -301,7 +287,7 @@
" if vid in videos: \n",
" print(vid + \" already in videos.json\")\n",
" else:\n",
" print(\"Adding \" + vid \" to videos.json\"))\n",
" print(\"Adding \" + vid + \" to videos.json\")\n",
" videos[vid] = {} \n",
" cam = \"camera1\"\n",
" videos[vid][cam] = {} \n",
Expand Down
38 changes: 19 additions & 19 deletions Step1.ProcessVideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@

# +
# location of openposedemo - THIS WILL BE DIFFERENT ON YOUR COMPUTER
# openposepath = "C:\\Users\\cas\\openpose-1.7.0-binaries-win64-gpu-python3.7-flir-3d_recommended\\"
# I've had problems with version 1.7.0 so i'm staying with version 1.5.0 for the moment.
openposepath = "C:\\Users\\cas\\openpose-1.5.0-binaries-win64-gpu-python-flir-3d_recommended\\"
#openposepath = "C:\\Users\\caspar\\openpose-1.4.0-win64-cpu-binaries\\"

if sys.platform == "win32":
app = "bin\\OpenPoseDemo.exe"
Expand Down Expand Up @@ -78,10 +79,10 @@
# ```

# +
# where's the project folder? (with trailing slash)
#projectpath = os.getcwd() + "\\..\\Sangath"
projectpath = "C:\\Users\\cas\\OneDrive - Goldsmiths College\\Projects\\Measuring Responsive Caregiving\\Sangath"
videos_in = "\\\\192.168.0.50\\Videos\\Obs Feeding videos _1.3.17\\"
# where's the project data folder? (without trailing slash)
projectpath = "C:\\Users\\cas\\OneDrive - Goldsmiths College\\Projects\\Measuring Responsive Caregiving\\VASCTutorial"
#where are your video files?
videos_in = "C:\\Users\\cas\\OneDrive - Goldsmiths College\\Projects\\Measuring Responsive Caregiving\\VASCTutorial\\demovideos"

# locations of videos and output
# videos_out = "E:\\SpeakNSign\\" + "out"
Expand Down Expand Up @@ -118,9 +119,8 @@
videos = {}
print("Creating new videos.json")

videos_out

# ### EITHER 1.4.2 Read an Excel file of videos
# ### EITHER
# ### 1.4.2.A Read an Excel file of videos
#
# We expect the first column of the spreadsheet to tell us the base name for each participant and columns 2 to 4 contains the full name and location of the videos.
#
Expand Down Expand Up @@ -191,24 +191,24 @@
print(videos)
# -

# ### Or 1.4.3 scanning all videos in particular folder
# ### Or
# ### 1.4.3.B scanning all videos in particular folder
#
# In which case we look at all videos in `videos_in` and it's subfolders.
#
# In which case we look at all videos in `videos_in` let the names of the files also provide the base names for each participant we create.
# We let the names of the files also provide the base names for each participant we create.
#
# We will reference these files by the video names so myvid1.avi is found in `videos["myvid1"]`.
# We will reference these files by the video names in our `videos.json` data structure. So myvid1.avi is found in `videos["myvid1"]`.
#
# However, in other cases we will allow for possibility of multiple camera angles so this defaults to `"camera1"`.
#
# We set a flag `namesfromfiles = True`.

threegps = glob.glob(videos_in + "./*/*.3gp", recursive = True)
print(threegps)

# +
#first get list of videos in the inbox
avis = glob.glob(videos_in + "./*/*.avi", recursive = True)
mp4s = glob.glob(videos_in + "./*/*.mp4", recursive = True)
threegps = glob.glob(videos_in + "./*/*.3gp", recursive = True)
#first get list of videos in the video folder and subfolders.
avis = glob.glob(videos_in + "/**/*.avi", recursive = True)
mp4s = glob.glob(videos_in + "/**/*.mp4", recursive = True)
threegps = glob.glob(videos_in + "/**/*.3gp", recursive = True)

print("We found %d avis" % len(avis))
print("We found %d mp4s" % len(mp4s))
Expand All @@ -233,7 +233,7 @@
if vid in videos:
print(vid + " already in videos.json")
else:
print("Adding " + vid " to videos.json"))
print("Adding " + vid + " to videos.json")
videos[vid] = {}
cam = "camera1"
videos[vid][cam] = {}
Expand Down
Loading

0 comments on commit de49ded

Please sign in to comment.