|
1 | | -### mciantyre/scipy-opencv-notebook Docker image |
| 1 | +## mciantyre/scipy-opencv-notebook Docker image |
2 | 2 |
|
3 | 3 | All the fun of the [jupyter/scipy-notebook][jupyter-scipy-nb] Docker image, plus OpenCV 3.0.0, Python 3 bindings, and the OpenCV extra modules. Check out the [jupyter/scipy-notebook][jupyter-scipy-nb] for more information. |
4 | 4 |
|
5 | 5 | Note: OpenCV was built with only Python 3 bindings. Therefore, Python 2 notebooks cannot `import cv2`. |
6 | 6 |
|
7 | | -#### Doesn't this exist? |
| 7 | +## Getting started |
| 8 | + |
| 9 | +``` |
| 10 | +docker pull mciantyre/scipy-opencv-notebook |
| 11 | +docker run -d -p 8888:8888 mciantyre/scipy-opencv-notebook |
| 12 | +``` |
| 13 | + |
| 14 | +See [jupyter/scipy-notebook][jupyter-scipy-nb] for optional `run` arguments. |
| 15 | + |
| 16 | +Navigate to `localhost:8888` in any browser, and make your first Python 3 notebook! Here's a script to find a face in a picture that you upload: |
| 17 | + |
| 18 | +```python |
| 19 | +%matplotlib inline |
| 20 | +import numpy as np |
| 21 | +import matplotlib.pyplot as plt |
| 22 | +import cv2 |
| 23 | + |
| 24 | +img = cv2.imread("your_uploaded_image.jpg") |
| 25 | +img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) |
| 26 | +plt.imshow(img) # shows face without box |
| 27 | + |
| 28 | +# If you need to find directories of data files, |
| 29 | +# open up a terminal window from the web interface and search from there |
| 30 | +# find /opt -iname *haar* |
| 31 | +face_cascade = cv2.CascadeClassifier('/opt/opencv/data/haarcascades/haarcascade_frontalface_default.xml') |
| 32 | + |
| 33 | +faces = face_cascade.detectMultiScale(img, 1.3, 5) |
| 34 | +for (x,y,w,h) in faces: |
| 35 | + cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) |
| 36 | + roi = img[y:y+h, x:x+w] |
| 37 | + |
| 38 | +plt.imshow(img) # shows the face with a box around it |
| 39 | +``` |
| 40 | + |
| 41 | +### Doesn't this exist? |
8 | 42 |
|
9 | 43 | In a few places! But, I wanted to make my own for practice. |
10 | 44 |
|
11 | | -Thanks to the [jupyter/docker-stacks][jupyter-stacks] project, OpenCV, and Docker. Made for the University of Pittsburgh DesignHub. |
| 45 | +Thanks to the [jupyter/docker-stacks][jupyter-stacks] project and the Jupyter team, OpenCV, and Docker. Made for the University of Pittsburgh DesignHub. |
12 | 46 |
|
13 | 47 | [jupyter-scipy-nb]: https://github.com/jupyter/docker-stacks/tree/master/scipy-notebook |
14 | 48 | [jupyter-stacks]: https://github.com/jupyter/docker-stacks |
0 commit comments