CS 330 Programming Languages 11 / 13 / 2007 Instructor: Michael Eckmann.
CS 376b Introduction to Computer Vision 01 / 22 / 2008 Instructor: Michael Eckmann.
-
Upload
jayson-flowers -
Category
Documents
-
view
214 -
download
1
Transcript of CS 376b Introduction to Computer Vision 01 / 22 / 2008 Instructor: Michael Eckmann.
CS 376bIntroduction to Computer Vision
01 / 22 / 2008
Instructor: Michael Eckmann
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Today’s Topics• This is technically a lab session, but I'll treat it as a
lecture today and maybe Friday or Monday will act as a lab session.
• Introduction to the course
– layout, assignments, exams, topics etc.• Homework assignment• What is Computer Vision?• Start C++ introduction.
Course Information• First week and a half to two weeks maximum
– dive in and learn the major differences between C++ and Java
• so you can code the assignments in C++ using the openCV library.
• C++ programming knowledge is a great skill to have for any computer science major
– quick overview of the openCV library– I will provide sample programs using the openCV
library.
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Course Information (cont.)• Computer Vision topics to be covered
– parts of chapters 1-7 and 9-11 in our text book
– additional material when our text doesn't go deep enough into a topic
• e.g. image processing techniques
• Expect to have 4 programming assignments
– 1st one will make sure you understand certain important C++ concepts as well how to use the openCV library in your code
– 2nd one will deal with image processing techniques
– 3rd and 4th will probably have to do with edge/feature detection and segmentation
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Course Information (cont.)• In addition to the programming assignments, we will have a
few homeworks dealing with some concepts that aren't covered in the programming assignments
• We will have two exams plus a final exam.
– APPROXIMATE DATES are
– exam 1 on or about 2/18/08
– exam 2 on or about 3/31/08
– final exam 5/08/08 6pm (set by registrar)
• We will have weekly labs initially for C++ concepts and interaction with openCV. After first few, the labs will allow you to explore the current lecture topics.
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++ comments• I did some searching on the web to find some pages that could
be useful as a reference to you and what I found was all over the place due to several things
– 1. C++ evolved over time and added features
– 2. Java evolved over time and added features
• There are many false statements on the web and in text books comparing Java and C++
– they may have been correct at the time of writing, but are false now e.g.
• Java added “generics” in 2003/2004• C++ added namespaces after some time
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
1st Homework• Start reading “Moving from Java to C++” page. • Read the page in the “C/C++ Reference” regarding “Data
Types”.
– Links under our useful links page.• If you purchased the recommended book “C++ for Java
Programmers”, read the first 3 chapters.
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Computer Vision• Before getting into C++ topics, let me first say a
little about computer vision which is what this course is mostly about.– The goal of Computer Vision, according to our text is
to “make useful decisions about real physical objects and scenes from sensed images.” That is, “understanding images.”
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Computer Vision• Basic observations on the relationship between
Computer Vision, Computer Graphics and Image Processing.– Computer Graphics
• Given models, generate images
– Computer Vision• Given images, generate models
– Image Processing• Given images, generate (other) images
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Computer Vision• Many computer vision tasks require image
processing techniques. • So, a substantial portion of the course will be
spent on learning image processing techniques and how they can be applied to computer vision problems.
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Computer Vision• For example if the computer vision task was to
find, in an image, a particular flat object for which you know the basic outline. The task might be solved by – reducing noise in the image (image processing)– processing the image to find all “edges” and generate
an edge image (image processing)– process the edge image to connect the edges into a
contour– determine if any of the contour shapes match the
contour of the shape you're trying to find.Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Computer Vision Topics• Image formation and representation (Ch. 2)
– how do we acquire digital images and in what format are they stored
• Binary Image Analysis (Ch. 3)– what information can we get out of a black and white
image (as opposed to a color image or a greyscale image)?
– what are typical operations on binary images and for what are they used?
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Computer Vision Topics• Image Filtering and Enhancement (Ch. 5)
– how do we reduce different kinds of noise– how do we enhance an image to show better detail in
areas of low contrast– use of histograms– applying image operators– detecting edges etc.
• Color (Ch. 6)– techniques and information from color images
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Computer Vision Topics• Texture (Ch. 7)
– how can we capture texture of an object in an image and what can we do with it
• Motion (Ch. 9)– different techniques for detecting motion in image
sequences (video) and what information can be gained from this
• Segmentation (Ch. 10)– techniques to segment an image into meaningful areas
based on various criteria
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
Computer Vision Topics• Matching in 2D (Ch. 11)
– how to find correspondences between two images– how to use these correspondences to generate
meaningful information
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++• C++
– Bjarne Stroustrup (designer and 1st implementer)– designed to be fast– object oriented– C is almost a proper subset of C++
• that is, a valid C program should typically be a valid C++ program
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++ vs. Java• In C++ but not in Java
– can use pointers to memory locations– have a pointer to a reference to an object that has been
returned to the heap (destroyed)• dangling pointer problem
• explicit programmer deallocation of memory allowed
– memory leaks• no garbage collection
– array indices are not checked• unpredictable behaviour when accessing array elements
beyond end of array
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++ vs. Java• In C++ but not in Java
– allow use of uninitialized variables (causes runtime error)
– allowed to not return a value from a non-void function – can overload operators
• e.g. for a class I can overload the + operator to perform some operation on objects of that class. more flexible than requiring a function.
– can have global functions that are not part of any class
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++ vs. Java• In C++ but not in Java
– has a preprocessor which can be used for (among other things) conditional compilation
– has the STL which contains things similar to what is found in Java Collections API
– has templates whereas Java uses generics for same purpose
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++ vs. Java• c++ has fewer compile time checks (which
generate errors) than Java• c++ has fewer run time checks• c++ has no standard GUI library• c++ has less standard library functions vs. the
large Java API• c++ is not as portable as Java, but there are
guidelines out there to which one should try to adhere for more portable c++
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++ from C• There are programming features leftover from C
that can be used in c++.– c-style strings, c-style dynamic memory management,
c-style printing, etc.
• we will look at the c-style way of doing things, but typically prefer the c++ way.
• we need to know the C ways because they are part of valid c++ programs and we need to be able to read code not written by us that may use the C style stuff and sometimes we might want to call a C function in some C library ...
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++• Some types
– int, short, long
– float, double, long double
– any of the above numeric types can be prefaced with signed or unsigned
– char (typically 8 bits)
– wchar_t (wide = larger than a char)
– bool (0 = false, 1 = true)• ints can be interpreted as bool (holdover from C which
had no bool), 0=false, any other int is true.
– void
– enum (creates an integer type and named constants)Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++• Some types
– union
union number {
int x;
double y;
long double z;
};
number num;
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++// Hello.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!" << endl;
return 0;
}
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++// #include logically inserts the code from the iostream file into this file
// (Hello.cpp)
// iostream is a system header file so we use the < >
// if we wanted to include our own user-defined header file then we use " "
// int main() is the function declaration (all programs need one main)
// can take 2 arguments if defined with them (int argc, char **argv)
// returns an int
// cout is like System.out.println
// << is an operator for writing
// >> is an operator for reading
// endl is a newline character
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++// note: cout and endl are in the std namespace (like a package in java)
// without using namespace std, we could:
// std::cout << "Hello, world!" << std::endl;
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++• The C++ specification does not specify the exact sizes of the
types therefore they are implementation dependent. If you want to know the size of a type on a particular system, you can use the sizeof operator in C++ to get this info.
• Let's see a program that uses this sizeof operator and prints the sizes of the various types.
• We are in the process of getting C++ working with Eclipse, but until then you can write code in a text editor and compile it at the command line like:
• g++ mycode.cpp -o mycode.o
• then to execute your program do:
• ./mycode.o
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++• a struct is a record in C++ and in C e.g.
struct PhoneNumber
{int areaCode; // first 3 digits, e.g. 518
int exchange; // next 3 digits e.g. 580
int last4; // last 4 digits e.g. 5294
}
• if you know structs from C, they are different in C++. In C++ they are essentially the same as classes except that by default a struct's members are public and by default a class's members are private.
Michael Eckmann - Skidmore College - CS 376b - Spring 2008
C++• classes in C++
– can have multiple inheritance
– typically divided into header and implementation (usually in different files)
– class definitions end with a semicolon
– divided into sections public: private: protected:
– inline functions - code in the definition
– header (interface) file vs. implementation file
– prototypes of functions and classes must appear before use
– extern
– destructors
– should have a default constructor and a copy constructorMichael Eckmann - Skidmore College - CS 376b - Spring 2008