microsoft/AI-For-Beginners

Public

mirrored fromhttps://github.com/microsoft/AI-For-BeginnersAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
40a2d0aa719511ca9dc29827f8ccd08a83cc2e96

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

lessons/4-ComputerVision/06-IntroCV/lab/MovementDetection.ipynb

97lines · modecode

1{
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "metadata": {},
6 "source": [
7 "## Palm Movement Detection using Optical Flow\n",
8 "\n",
9 "This lab is part of [AI for Beginners Curriculum](http://aka.ms/ai-beginners).\n",
10 "\n",
11 "Consider [this video](palm-movement.mp4), in which a person's palm moves left/right/up/down on the stable background.\n",
12 "\n",
13 "<img src=\"../images/palm-movement.png\" width=\"30%\" alt=\"Palm Movement Frame\"/>\n",
14 "\n",
15 "**Your goal** would be to use Optical Flow to determine, which parts of video contain up/down/left/right movements. \n",
16 "\n",
17 "Start by getting video frames as described in the lecture:"
18 ]
19 },
20 {
21 "cell_type": "code",
22 "execution_count": null,
23 "metadata": {},
24 "outputs": [],
25 "source": [
26 "# Code here"
27 ]
28 },
29 {
30 "cell_type": "markdown",
31 "metadata": {},
32 "source": [
33 "Now, calculate dense optical flow frames as described in the lecture, and convert dense optical flow to polar coordinates: "
34 ]
35 },
36 {
37 "cell_type": "code",
38 "execution_count": null,
39 "metadata": {},
40 "outputs": [],
41 "source": [
42 "# Code here"
43 ]
44 },
45 {
46 "cell_type": "markdown",
47 "metadata": {},
48 "source": [
49 "Build histogram of directions for each of the optical flow frame. A histogram shows how many vectors fall under certain bin, and it should separate out different directions of movement on the frame.\n",
50 "\n",
51 "> You may also want to zero out all vectors whose magnitude is below certain threshold. This will get rid of small extra movements in the video, such as eyes and head.\n",
52 "\n",
53 "Plot the histograms for some of the frames."
54 ]
55 },
56 {
57 "cell_type": "code",
58 "execution_count": null,
59 "metadata": {},
60 "outputs": [],
61 "source": [
62 "# Code here"
63 ]
64 },
65 {
66 "cell_type": "markdown",
67 "metadata": {},
68 "source": [
69 "Looking at histograms, it should be pretty straightforward how to determine direction of movement. You need so select those bins the correspond to up/down/left/right directions, and that are above certain threshold."
70 ]
71 },
72 {
73 "cell_type": "code",
74 "execution_count": null,
75 "metadata": {},
76 "outputs": [],
77 "source": [
78 "# Code here"
79 ]
80 },
81 {
82 "cell_type": "markdown",
83 "metadata": {},
84 "source": [
85 "Congratulations! If you have done all steps above, you have completed the lab!"
86 ]
87 }
88 ],
89 "metadata": {
90 "language_info": {
91 "name": "python"
92 },
93 "orig_nbformat": 4
94 },
95 "nbformat": 4,
96 "nbformat_minor": 2
97}
98