Skip to content

Commit

Permalink
Step 2 - largely done
Browse files Browse the repository at this point in the history
A mostly working version of step 2!
  • Loading branch information
InfantLab committed Mar 14, 2020
1 parent b910d12 commit 745ded3
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 237 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.ipynb_checkpoints/vasc-checkpoint.py
.ipynb_checkpoints/videos-checkpoint.json
__pycache__/vasc.cpython-37.pyc
.ipynb_checkpoints/Step3.AnalyseData.R-checkpoint.ipynb
2 changes: 1 addition & 1 deletion Step0.GettingStarted.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"\n",
"We also install `iPyWidgets` & `iPyCanvas` in order to use buttons and sliders and images in Jupyter notebooks (these are used in Step 2). \n",
"```\n",
"conda install -c conda-forgeipywidgets \n",
"conda install -c conda-forge ipywidgets \n",
"conda install -c conda-forge ipycanvas\n",
"```\n",
"To make these work with the newer Jupyter Lab we also need to install the widgets lab extension, like so:\n",
Expand Down
501 changes: 269 additions & 232 deletions Step2.OrganiseData.ipynb

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions vasc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# support functions

import cv2
import numpy as np

# OpenPose has two main body models COCO with 18 points and BODY-25 with 25.
# The default (and better model) is BODY-25. Here we provide the labelling for
Expand Down Expand Up @@ -93,10 +94,12 @@ def xyc (coords):
return xs,ys,cs

xs, ys, cs = xyc(list(range(nPoints)))
xys = xs + ys

#same for head
head = [0, 15, 16, 17, 18]
headx, heady, headc = xyc(head)

headxys = headx + heady


def video_to_frames(input_loc, output_loc):
Expand Down Expand Up @@ -183,10 +186,10 @@ def diffKeypoints(keypoints1,keypoints2,indices):
"""
out = []
for i in indices:
if keypoints1[i]>0 and keypoints2[i]:
out.append(keypoints1[i] - keypoints2[i])
if keypoints1[i]>0 and keypoints2[i]>0:
out.append(abs(keypoints1[i] - keypoints2[i]))
else:
out.append(None)
out.append(np.nan)
return out

def getframeimage(videopath,framenumber):
Expand Down Expand Up @@ -221,6 +224,14 @@ def drawLines(frame, framekeypoints, people):
cv2.line(frame, (A[0], A[1]), (B[0], B[1]), pointcolors[i], 2, cv2.LINE_AA)

def drawBodyCG(frame, framekeypoints, people):
"""Function to draw centre of gravity for the points of a wireframe
Args:
frame: the image we are drawing to
framekeypoints: the keypoints array.
people: how many people are there?
Returns:
diff per index (if any i)
"""
font = cv2.FONT_HERSHEY_SIMPLEX
fontScale = 1.0
for p in range(people):
Expand Down

0 comments on commit 745ded3

Please sign in to comment.