{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 2. Background Remvoal with SVD" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Our goal today**: ![background removal](images/surveillance3.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load and Format the Data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's use the real video 003 dataset from [BMC 2012 Background Models Challenge Dataset](http://bmc.iut-auvergne.com/?page_id=24)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import needed libraries:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Imageio: 'ffmpeg.linux64' was not found on your computer; downloading it now.\n", "Try 1. Download from https://github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg.linux64 (27.2 MB)\n", "Downloading: 8192/28549024 bytes (0.02260992/28549024 bytes (7.9%5455872/28549024 bytes (19.18790016/28549024 bytes (30.812189696/28549024 bytes (42.7%15687680/28549024 bytes (54.9%18898944/28549024 bytes (66.2%22134784/28549024 bytes (77.5%25518080/28549024 bytes (89.4%28549024/28549024 bytes (100.0%)\n", " Done\n", "File saved as /home/racheltho/.imageio/ffmpeg/ffmpeg.linux64.\n" ] } ], "source": [ "import imageio\n", "imageio.plugins.ffmpeg.download()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true, "scrolled": true }, "outputs": [], "source": [ "import moviepy.editor as mpe\n", "import numpy as np\n", "import scipy\n", "\n", "%matplotlib inline\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "np.set_printoptions(precision=4, suppress=True)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "video = mpe.VideoFileClip(\"movie/Video_003.avi\")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2589| 350/351 [00:00<00:00, 914.11it/s]\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "\n", " | 100 | \n", "1000 | \n", "10000 | \n", "
---|---|---|---|
100 | \n", "0.006 | \n", "0.009 | \n", "0.043 | \n", "
1000 | \n", "0.004 | \n", "0.259 | \n", "0.992 | \n", "
10000 | \n", "0.019 | \n", "0.984 | \n", "218.726 | \n", "