Upgrade to Pro — share decks privately, control downloads, hide ads and more …

It seeeeeez! - Computer Vision with OpenCV

It seeeeeez! - Computer Vision with OpenCV

A (more scientific) little workshop on computer vision with C++/OpenCV.

Marcel Neidinger

April 27, 2017
Tweet

More Decks by Marcel Neidinger

Other Decks in Programming

Transcript

  1. It seeeeeez! Computer Vision with OpenCV Marcel Neidinger <[email protected]> Department

    of Mathematics and Computer Science, University of Basel April 27, 2017
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. Loading an image #include <opencv2/opencv.hpp> int main(int argc, char** argv)

    { cv::Mat img; img = cv::imread(argv[1]); } It seeeeeez! Computer Vision with OpenCV 7 / 1
  8. 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
  9. 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
  10. OpenCV: Finding contours std::vector<std::vector<cv::Point> > contours; std::vector<cv::Vec4i> 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
  11. OpenCV: Practical example Enough examples. Let’s write a tennis ball

    tracker It seeeeeez! Computer Vision with OpenCV 12 / 1
  12. 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
  13. 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
  14. 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