6.S063 Engineering Interactive Technologies (fall 2017)

HW7: Setup OpenCV

Deadline: due Wednesday (October 4, 2017) at 1pm, upload here

  • a screenshot of your OpenCV program and the resulting camera image, upload here
  • post on piazza
  • go to a TA office hour for building/coding oriented questions (tbd)
  • go to an instructor office hour for logistical questions and grading (mondays, 4-5pm, 32-211)
  • do not send us emails

Install OpenCV. Then test run your camera:
  • create a new python file with the code below (e.g. test.py)
  • go to your console, call the python file (I had to use the python3 prompt to make it work, e.g. python3 test.py)
  • you should see your camera image displayed, if you have the wrong camera image, change the camera_port variable.
  • if you get errors, your openCV and python setup might not be linked correctly, consider talking to your TA

import cv2
camera_port = 0
camera = cv2.VideoCapture(camera_port)
ret, frame = camera.read()

You are done when you see this:

Installing (general):
  • You should be able to install OpenCV using pip:
    • In terminal, or command line, run pip install opencv-python
    • If pip is not found, you may need to use pip3 or pip3.5 in place of pip
  • If this doesn't work, you can try manually installing OpenCV for Python (see below).
Installing on Windows:
Installing on Mac: