Skip to content

Assignment 2

drebain edited this page Feb 12, 2020 · 3 revisions

For this assignment you will be given partially completed skeleton code that contains some of the logic you will need. All areas that you need to add or modify code to to complete the assignment requirements will be marked with a TODO comment and some more specific instructions. It is not necessary to add or modify code outside these sections.

Note: You may reuse parts your code from assignment 1 that may be helpful.

Tasks

(2 Marks) Opening a Window

Fill in code to load input.txt and use the canvas line to open a window of the correct size with OpenCV.

(4 Marks) Draw Shapes from Input File

Parse the lines from the input as in Assignment 1, but now draw the described shapes into the window you have opened.

(4 Marks) Draw Filled Polygon from Mouse Input

Implement code that responds to user input and interactively draws filled polygons:

  • When the user left-clicks, add a new vertex to the current polygon.
  • The most recently added vertex should always move to follow the mouse.
  • When the user double-left-clicks, place a vertex then start a new empty polygon.

Please also watch the video demo attached to the assignment on connex.

Resources

Unfortunately, OpenCV does not have as nice of API documentation for its python bindings as the python standard library does. These tutorial pages should help though:

Data for Grading

canvas 800 600
circle 3 10 50 50
line 5 10 10 200 10
polyline 3 70 20 30 90 40 20 110 95
polyfill 100 100 30 70 90 20 10 10 25 78