Slide 1

Slide 1 text

It seeeeeez! Computer Vision with OpenCV Marcel Neidinger Department of Mathematics and Computer Science, University of Basel April 27, 2017

Slide 2

Slide 2 text

Derivation of Gradient Form for Images Introduce transformation V : R3 → R2 ( 3 x ) yt → ( 2 x − v1t ) y − v2t (1) Rewrite I(x, y, t) = ˜ I(V(x, y, t)) and use chain-rule for derivative gradI(x, y, t) = grad˜ I(x − v1t, y − v2t) · ( 1 0 −v1 0 1 −v2 ) (2) We search for ∂I ∂t → third component ∂I ∂t = − ( v1 · ∂I ∂x + v2 ∂I ∂y ) = −(grad˜ I ·⃗ v) (3) It seeeeeez! Computer Vision with OpenCV 2 / 1

Slide 3

Slide 3 text

Derivation of Gradient Form for Images Introduce transformation V : R3 → R2 ( 3 x ) yt → ( 2 x − v1t ) y − v2t (1) Rewrite I(x, y, t) = ˜ I(V(x, y, t)) and use chain-rule for derivative gradI(x, y, t) = grad˜ I(x − v1t, y − v2t) · ( 1 0 −v1 0 1 −v2 ) (2) We search for ∂I ∂t → third component ∂I ∂t = − ( v1 · ∂I ∂x + v2 ∂I ∂y ) = −(grad˜ I ·⃗ v) (3) It seeeeeez! Computer Vision with OpenCV 2 / 1

Slide 4

Slide 4 text

OpenCV is practical It seeeeeez! Computer Vision with OpenCV 3 / 1

Slide 5

Slide 5 text

OpenCV: History Started at Intel Research Cross-plattform library for CV Today: More then a CV Library (machine learning) It seeeeeez! Computer Vision with OpenCV 4 / 1

Slide 6

Slide 6 text

Programming OpenCV + = It seeeeeez! Computer Vision with OpenCV 5 / 1

Slide 7

Slide 7 text

Programming OpenCV + = It seeeeeez! Computer Vision with OpenCV 5 / 1

Slide 8

Slide 8 text

Programming OpenCV + = It seeeeeez! Computer Vision with OpenCV 5 / 1

Slide 9

Slide 9 text

Programming OpenCV + = It seeeeeez! Computer Vision with OpenCV 5 / 1

Slide 10

Slide 10 text

Programming OpenCV OpenCV is polygamous. - Florian Spiess It seeeeeez! Computer Vision with OpenCV 6 / 1

Slide 11

Slide 11 text

Programming OpenCV OpenCV is polygamous. - Florian Spiess We will still use C++ in this workshop. Why? It’s the root language of OpenCV(fastest) Most examples are in C++(followed by python) It seeeeeez! Computer Vision with OpenCV 6 / 1

Slide 12

Slide 12 text

Programming OpenCV OpenCV is polygamous. - Florian Spiess We will still use C++ in this workshop. Why? It’s the root language of OpenCV(fastest) Most examples are in C++(followed by python) I’m a c++ fanboy and this is my workshop It seeeeeez! Computer Vision with OpenCV 6 / 1

Slide 13

Slide 13 text

Loading an image #include int main(int argc, char** argv) { cv::Mat img; img = cv::imread(argv[1]); } It seeeeeez! Computer Vision with OpenCV 7 / 1

Slide 14

Slide 14 text

Displaying the image [...] cv::namedWindow(”debug”, cv::CV_WINDOW_AUTOSIZE); imshow(”debug”, img); while( true ) { if( cv::waitKey(0) != −1 ) { break; } } It seeeeeez! Computer Vision with OpenCV 8 / 1

Slide 15

Slide 15 text

Theory: Segmenting images It seeeeeez! Computer Vision with OpenCV 9 / 1

Slide 16

Slide 16 text

Segementation in OpenCV // Create new image to store greyscale cv::Mat imgGray, imgThresh; cv::cvtColor( img, imgGray, cv::CV_BGR2GRAY ); // Threshold int value = 20; int maxval = 255; cv::threshold( imgGray, imgThresh, value, maxval, cv::THRESH_BINARY); dst(x, y) = { maxval, if src(x, y) > value 0, else (4) It seeeeeez! Computer Vision with OpenCV 10 / 1

Slide 17

Slide 17 text

OpenCV: Finding contours std::vector > contours; std::vector hierarchy; cv::findContours( imgThresh, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cv:: Point(0,0) ); It seeeeeez! Computer Vision with OpenCV 11 / 1

Slide 18

Slide 18 text

OpenCV: Practical example Enough examples. Let’s write a tennis ball tracker It seeeeeez! Computer Vision with OpenCV 12 / 1

Slide 19

Slide 19 text

OpenCV: And moving images? VideoCapture cap(0); if( !cap.isOpened() ) { return −1; } for(;;) { Mat frame; cap >> frame; // Treat like normal picture } It seeeeeez! Computer Vision with OpenCV 13 / 1

Slide 20

Slide 20 text

Beyond the scope This barely scratched the surface of what OpenCV can do Advanced object detection Advanced feature selection Advanced tracking and object recognition methods Video analysis capabilities Machine Learning Capabilities(Boosting, Cascaders, k-nearest Neighbor …) Support for OpenCL and CUDA Integration into e.g. TensorFlow It seeeeeez! Computer Vision with OpenCV 14 / 1

Slide 21

Slide 21 text

Beyond the scope This barely scratched the surface of what OpenCV can do Advanced object detection Advanced feature selection Advanced tracking and object recognition methods Video analysis capabilities Machine Learning Capabilities(Boosting, Cascaders, k-nearest Neighbor …) Support for OpenCL and CUDA Integration into e.g. TensorFlow Theorem Rule of Thumb: If there is an algorithm in computer vision, OpenCV has a highly optimized implementation readily available. It seeeeeez! Computer Vision with OpenCV 14 / 1

Slide 22

Slide 22 text

Questions?