{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Palm Movement Detection using Optical Flow\n",
    "\n",
    "This lab is part of [AI for Beginners Curriculum](http://aka.ms/ai-beginners).\n",
    "\n",
    "Consider [this video](palm-movement.mp4), in which a person's palm moves left/right/up/down on the stable background.\n",
    "\n",
    "<img src=\"../images/palm-movement.png\" width=\"30%\" alt=\"Palm Movement Frame\"/>\n",
    "\n",
    "**Your goal** would be to use Optical Flow to determine, which parts of video contain up/down/left/right movements. \n",
    "\n",
    "Start by getting video frames as described in the lecture:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Code here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, calculate dense optical flow frames as described in the lecture, and convert dense optical flow to polar coordinates: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Code here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "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",
    "\n",
    "> 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",
    "\n",
    "Plot the histograms for some of the frames."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Code here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "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."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Code here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Congratulations! If you have done all steps above, you have completed the lab!"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
