-
-
Save JosvanderWesthuizen/eaa5c92c3772976835f3ad0dbefde81d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Opened: True\n" | |
] | |
} | |
], | |
"source": [ | |
"%matplotlib inline\n", | |
"\n", | |
"import cv2\n", | |
"import matplotlib.pyplot as plt\n", | |
"import numpy as np\n", | |
"\n", | |
"vc = cv2.VideoCapture('https://s3-eu-west-1.amazonaws.com/jamcams.tfl.gov.uk/00001.03680.mp4')\n", | |
"print('Opened: {}'.format(vc.isOpened()))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"# Read every 10th frame from first 90 frames\n", | |
"frames = []\n", | |
"for idx in range(90):\n", | |
" ok, I = vc.read()\n", | |
" if not ok:\n", | |
" print('Video ended early')\n", | |
" break\n", | |
" if idx % 10 == 0:\n", | |
" # OpenCV returns image in BGR format. We want RGB\n", | |
" I = cv2.cvtColor(I, cv2.COLOR_BGR2RGB)\n", | |
" frames.append(I)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(-0.5, 1055.5, 863.5, -0.5)" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment