4
©Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016 OpenCV Introduction Lecture #3 January 27, 2016 ©Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016 … and so it begins ©Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016 … and today … ©Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016 Need to Start Somewhere ©Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016 OpenCV : First Steps (C++) Include OpenCV Most important classes: Mat (image/matrix class) VideoCapture (video class) Windows (not really a class) ©Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016 Read/Show Example (from OpenCV)

OpenCV Introduction - CS CSU HomepageOpenCV Introduction Lecture #3 January 27, 2016 ... (C++) • Include OpenCV • Most important classes: –Mat (image/matrix class) –VideoCapture

Embed Size (px)

Citation preview

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

OpenCVIntroduction

Lecture #3January 27, 2016

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

… and so it begins

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

… and today …© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Need to Start Somewhere

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

OpenCV : First Steps (C++)• Include OpenCV

• Most important classes:– Mat (image/matrix class)– VideoCapture (video class)– Windows (not really a class)

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Read/Show Example (from OpenCV)

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Simple Image Access (from OpenCV)

• 1st image type: CV_8UC1• 2nd image type: CV_8UC3• Unfortunately, Mat is not templated

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

VideoCapture Example

• First part of code opens a video stream• 2nd part gets properties from stream• Note that this will read many (but not all)

video formats

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

VideoCapture Example II

• Grab() advances stream• Retrieve() gets the current frame• pyrDown() reduces image size by 1/2

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Accessing Color Images

• median_img is a 3 color byte image– Passed in as argument, not shown

• mad_img is a 1 color floating point image– Inidcated by CV_32FC1

• Notice Mat is not typed, but iterators are– So is the single pixel accessor

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Accessing Images (continued)

• Iterators accessed as you expect

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Useful Functions for this Assignment

• getRotationMatrix2D• getAffineTransform• getPerspectiveTransform• invertAffineTransform• warpAffine• warpPerspective

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

New projectin Eclipse

I am going to follow the KISS process here(which actually makes some things hard).

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Here is what you get …

Notice the lack of anything relate to OpenCV

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Customize Project Properties

Essentially, we are telling Eclipse to stop trying to be helpful.

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

IncludesBe careful you have GNU C++ selected.Obviously these are my paths on my Yosemite installed Mac.

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

LibrariesSince we are building our own extremely simple Makefile, not clear this step is needed.

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Now, we need a source file

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Now, make meets KISS• Why am I being so primitive?

– Walk before you run …– Be able to test from a command line prompt!

• As your systems grow, so too will the automation in your Makefile.

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Eclipse and compiling = targetsNote new targets are created in the targets window in the upper right.

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Gotcha!

Remove“Debug”

© Bru ce A. Drap er & J. Ro ss Bev erid g e, Jan u ary 2 7 , 2 016

Run