SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
OpenCV Basics and Camera Calibration


         Computer Vision Lab Tutorial
               5 October 2012
    Lorenz Meier, Kevin Koeser, Kalin Kolev




           Institute of Visual Computing
What is OpenCV ?



The most popular library in Computer Vision
Released under the liberal BSD license
It has C++, C, Python and Java interfaces and supports
 Windows, Linux, Android and Mac OS
Offers optimized implementation of more than 2500
 algorithms
New official website: http://code.opencv.org
OpenCV4Android: http://opencv.org/android.html


                    Institute of Visual Computing
OpenCV Overview




 Institute of Visual Computing
Core Functionality



Each image is represented as a matrix
Basic class Mat for storing general n-dimensional arrays
 (e.g. grayscale images, color images, voxel volumes etc.)
Fast access to its elements via pointers, e.g.
        Mat mat;
        mat.ptr<float>(i)[j] = …

Direct access to user-allocated data (e.g. video frames)
        Mat image(height, width, CV_8UC3, pixels, step);




                      Institute of Visual Computing
Hints for Android Developers



If you use the camera device, make sure that you have
 required permission in your AndroidManifest.xml
   <uses-feature android:name="android.hardware.camera" />
   <uses-permission android:name="android.permission.CAMERA" />

If you want to write images to the storage of the mobile
 device via imwrite(), make sure that you have required
 permission in your AndroidManifest.xml

   <uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE" />




                         Institute of Visual Computing
Image Segmentation


Interactive image segmentation




 C. Rother, V. Kolmogorov, A. Blake, "GrabCut — Interactive
 Foreground Extraction using Iterated Graph Cuts"
OpenCV implementation
    void grabCut(img, mask, rect, bgdModel, fgdModel, iterCount, mode);




                        Institute of Visual Computing
Pinhole Camera




                                                       𝑃 = 𝐾[𝑅|𝑡]
Pinhole camera model                             projection matrix




                                                         𝑓𝑥   𝑠     𝑝𝑥
                                                  calibration matrix

                                                  𝐾=     0    𝑓𝑦    𝑝𝑦
                                                         0    0     1


                                                          𝑅 ∊ ℝ3𝑥𝑥
                                                  extrinsic parameters

                                                           𝑡 ∊ ℝ3




                  Institute of Visual Computing
Camera Calibration



OpenCV implementation

    bool findChessboardCorners(image, patternSize, corners, flags);

    double calibrateCamera(objectPoints, imgPoints, imgSize, camMatrix,
                          distCoeffs, rvecs, tvecs, flags, criteria);

    Mat initCameraMatrix2D(objPoints, imgPoints, imgSize, aspectRatio);

    void getOptimalNewCameraMatrix(camMatrix, distCoeffs, imgSize,
                                   alpha, newImgSize, PixROI, cPP);

    void undistort(src, dst, cameraMatrix, distCoeffs, newCameraMatrix);



                         Institute of Visual Computing
Structure from Motion



Structure-from-motion pipeline


       feature point                   feature point      camera pose
         extraction                  matching/tracking     estimation




                          Institute of Visual Computing
Feature Point Extraction




Abstract base class for 2D image feature detectors
 FeatureDetector
     void FeatureDetector::detect(image, keypoints, mask);
     Ptr<FeatureDetector> FeatureDetector::create(detectorType);

The following detector types are supported: FAST, STAR,
 SIFT (nonfree module), SURF (nonfree module), ORB, MSER,
 GFTT, HARRIS, Dense, SimpleBlob


                         Institute of Visual Computing
Feature Point Matching



Abstract base class for computing descriptors for image
 keypoints DescriptorExtractor
     void DescriptorExtractor::compute(image, keypoints, descriptors);
     Ptr<DescriptorExtractor> DescriptorExtractor::create(descriptorType);

The following types of descriptor extractors are supported: SIFT,
 SURF, ORB, BRIEF
Alternative in case of video input: KLT tracker
     void calcOpticalFlowPyrLK(prevImg, nextImg, prevPts, nextPts, …);
     int buildOpticalFlowPyramid(img, pyramid, …);




                          Institute of Visual Computing
Camera Pose Estimation


General approach: triangulation + bundle adjustment
                                X



                  x                       x'




Special case: ground plane estimation

                                                         𝐻 ∊ ℝ3𝑥𝑥
                                                      homography matrix


                                                          𝑥 ′ = 𝐻𝐻


                      Institute of Visual Computing
Hints to Planar Homography
                       Estimation



Don’t use OpenCV’s findHomography()                as it estimates a
 general homography
Note that a general homography has 8 degrees of freedeom
 while a plane is determined by only 3 degrees of freedom
 (=> use additional constraints)
Reference:
 R. Hartley, A. Zisserman, "Multiple View Geometry in
 Computer Vision"




                    Institute of Visual Computing
Qualcomm`s Vuforia




The Vuforia toolkit estimates camera intrinsics and poses by
 means of markers
Camera intrinsics: QCAR::CameraCalibration
Camera poses: QCAR::Trackable -> getPose()
Note that in the current implementation no distortion
 parameters are being estimated



                     Institute of Visual Computing

Más contenido relacionado

La actualidad más candente

License Plate Recognition System
License Plate Recognition System License Plate Recognition System
License Plate Recognition System Hira Rizvi
 
European Robotics Forum 2014 Talk on Closing the Perception-Action Gap
European Robotics Forum 2014 Talk on Closing the Perception-Action GapEuropean Robotics Forum 2014 Talk on Closing the Perception-Action Gap
European Robotics Forum 2014 Talk on Closing the Perception-Action GapDariolakis
 
Collaborative modeling and co simulation with destecs - a pilot study
Collaborative modeling and co simulation with destecs - a pilot studyCollaborative modeling and co simulation with destecs - a pilot study
Collaborative modeling and co simulation with destecs - a pilot studyDaniele Gianni
 
Advance Multimedia Tech. Augmented reality. Pertemuan 2
Advance Multimedia Tech. Augmented reality. Pertemuan 2Advance Multimedia Tech. Augmented reality. Pertemuan 2
Advance Multimedia Tech. Augmented reality. Pertemuan 2giamuhammad
 
Computer vision for microscopes
Computer vision for microscopesComputer vision for microscopes
Computer vision for microscopesJan Wedekind
 
The MiCRoN Project
The MiCRoN ProjectThe MiCRoN Project
The MiCRoN ProjectJan Wedekind
 
COSC 426 Lect. 3 -AR Developer Tools
COSC 426 Lect. 3 -AR Developer ToolsCOSC 426 Lect. 3 -AR Developer Tools
COSC 426 Lect. 3 -AR Developer ToolsMark Billinghurst
 

La actualidad más candente (8)

License Plate Recognition System
License Plate Recognition System License Plate Recognition System
License Plate Recognition System
 
European Robotics Forum 2014 Talk on Closing the Perception-Action Gap
European Robotics Forum 2014 Talk on Closing the Perception-Action GapEuropean Robotics Forum 2014 Talk on Closing the Perception-Action Gap
European Robotics Forum 2014 Talk on Closing the Perception-Action Gap
 
Introduction to OpenCV
Introduction to OpenCVIntroduction to OpenCV
Introduction to OpenCV
 
Collaborative modeling and co simulation with destecs - a pilot study
Collaborative modeling and co simulation with destecs - a pilot studyCollaborative modeling and co simulation with destecs - a pilot study
Collaborative modeling and co simulation with destecs - a pilot study
 
Advance Multimedia Tech. Augmented reality. Pertemuan 2
Advance Multimedia Tech. Augmented reality. Pertemuan 2Advance Multimedia Tech. Augmented reality. Pertemuan 2
Advance Multimedia Tech. Augmented reality. Pertemuan 2
 
Computer vision for microscopes
Computer vision for microscopesComputer vision for microscopes
Computer vision for microscopes
 
The MiCRoN Project
The MiCRoN ProjectThe MiCRoN Project
The MiCRoN Project
 
COSC 426 Lect. 3 -AR Developer Tools
COSC 426 Lect. 3 -AR Developer ToolsCOSC 426 Lect. 3 -AR Developer Tools
COSC 426 Lect. 3 -AR Developer Tools
 

Destacado

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009zukun
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Informationzukun
 
3D visualization with VTVK and MayaVi2
3D visualization with VTVK and MayaVi23D visualization with VTVK and MayaVi2
3D visualization with VTVK and MayaVi2zukun
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statisticszukun
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-softwarezukun
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibrationzukun
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectorszukun
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptorszukun
 

Destacado (8)

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Information
 
3D visualization with VTVK and MayaVi2
3D visualization with VTVK and MayaVi23D visualization with VTVK and MayaVi2
3D visualization with VTVK and MayaVi2
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statistics
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-software
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibration
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectors
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptors
 

Similar a ETHZ CV2012: Tutorial openCV

Presentation Object Recognition And Tracking Project
Presentation Object Recognition And Tracking ProjectPresentation Object Recognition And Tracking Project
Presentation Object Recognition And Tracking ProjectPrathamesh Joshi
 
Automated Face Detection System
Automated Face Detection SystemAutomated Face Detection System
Automated Face Detection SystemAbhiroop Ghatak
 
ANISH_and_DR.DANIEL_augmented_reality_presentation
ANISH_and_DR.DANIEL_augmented_reality_presentationANISH_and_DR.DANIEL_augmented_reality_presentation
ANISH_and_DR.DANIEL_augmented_reality_presentationAnish Patel
 
SkyStitch: a Cooperative Multi-UAV-based Real-time Video Surveillance System ...
SkyStitch: a Cooperative Multi-UAV-based Real-time Video Surveillance System ...SkyStitch: a Cooperative Multi-UAV-based Real-time Video Surveillance System ...
SkyStitch: a Cooperative Multi-UAV-based Real-time Video Surveillance System ...Kitsukawa Yuki
 
AUTO LANDING PROCESS FOR AUTONOMOUS FLYING ROBOT BY USING IMAGE PROCESSING BA...
AUTO LANDING PROCESS FOR AUTONOMOUS FLYING ROBOT BY USING IMAGE PROCESSING BA...AUTO LANDING PROCESS FOR AUTONOMOUS FLYING ROBOT BY USING IMAGE PROCESSING BA...
AUTO LANDING PROCESS FOR AUTONOMOUS FLYING ROBOT BY USING IMAGE PROCESSING BA...csandit
 
Visual pattern recognition in robotics
Visual pattern recognition in roboticsVisual pattern recognition in robotics
Visual pattern recognition in roboticsIAEME Publication
 
Portfolio - Ramsundar K G
Portfolio - Ramsundar K GPortfolio - Ramsundar K G
Portfolio - Ramsundar K GRamsundar K G
 
SENSITIVITY OF A VIDEO SURVEILLANCE SYSTEM BASED ON MOTION DETECTION
SENSITIVITY OF A VIDEO SURVEILLANCE SYSTEM BASED ON MOTION DETECTIONSENSITIVITY OF A VIDEO SURVEILLANCE SYSTEM BASED ON MOTION DETECTION
SENSITIVITY OF A VIDEO SURVEILLANCE SYSTEM BASED ON MOTION DETECTIONsipij
 
Visual pattern recognition in robotics
Visual pattern recognition in roboticsVisual pattern recognition in robotics
Visual pattern recognition in roboticsIAEME Publication
 
Build Your Own 3D Scanner: 3D Scanning with Structured Lighting
Build Your Own 3D Scanner: 3D Scanning with Structured LightingBuild Your Own 3D Scanner: 3D Scanning with Structured Lighting
Build Your Own 3D Scanner: 3D Scanning with Structured LightingDouglas Lanman
 
Cvpr2010 open source vision software, intro and training part v open cv and r...
Cvpr2010 open source vision software, intro and training part v open cv and r...Cvpr2010 open source vision software, intro and training part v open cv and r...
Cvpr2010 open source vision software, intro and training part v open cv and r...zukun
 
Vision based system for monitoring the loss of attention in automotive driver
Vision based system for monitoring the loss of attention in automotive driverVision based system for monitoring the loss of attention in automotive driver
Vision based system for monitoring the loss of attention in automotive driverVinay Diddi
 
426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer ToolsMark Billinghurst
 
Artifacts Detection by Extracting Edge Features and Error Block Analysis from...
Artifacts Detection by Extracting Edge Features and Error Block Analysis from...Artifacts Detection by Extracting Edge Features and Error Block Analysis from...
Artifacts Detection by Extracting Edge Features and Error Block Analysis from...Md. Mehedi Hasan
 
Real Time Object Dectection using machine learning
Real Time Object Dectection using machine learningReal Time Object Dectection using machine learning
Real Time Object Dectection using machine learningpratik pratyay
 
AUTOMATIC THEFT SECURITY SYSTEM (SMART SURVEILLANCE CAMERA)
AUTOMATIC THEFT SECURITY SYSTEM (SMART SURVEILLANCE CAMERA)AUTOMATIC THEFT SECURITY SYSTEM (SMART SURVEILLANCE CAMERA)
AUTOMATIC THEFT SECURITY SYSTEM (SMART SURVEILLANCE CAMERA)cscpconf
 
Fisheye/Omnidirectional View in Autonomous Driving IV
Fisheye/Omnidirectional View in Autonomous Driving IVFisheye/Omnidirectional View in Autonomous Driving IV
Fisheye/Omnidirectional View in Autonomous Driving IVYu Huang
 

Similar a ETHZ CV2012: Tutorial openCV (20)

Presentation Object Recognition And Tracking Project
Presentation Object Recognition And Tracking ProjectPresentation Object Recognition And Tracking Project
Presentation Object Recognition And Tracking Project
 
Automated Face Detection System
Automated Face Detection SystemAutomated Face Detection System
Automated Face Detection System
 
ANISH_and_DR.DANIEL_augmented_reality_presentation
ANISH_and_DR.DANIEL_augmented_reality_presentationANISH_and_DR.DANIEL_augmented_reality_presentation
ANISH_and_DR.DANIEL_augmented_reality_presentation
 
SkyStitch: a Cooperative Multi-UAV-based Real-time Video Surveillance System ...
SkyStitch: a Cooperative Multi-UAV-based Real-time Video Surveillance System ...SkyStitch: a Cooperative Multi-UAV-based Real-time Video Surveillance System ...
SkyStitch: a Cooperative Multi-UAV-based Real-time Video Surveillance System ...
 
AUTO LANDING PROCESS FOR AUTONOMOUS FLYING ROBOT BY USING IMAGE PROCESSING BA...
AUTO LANDING PROCESS FOR AUTONOMOUS FLYING ROBOT BY USING IMAGE PROCESSING BA...AUTO LANDING PROCESS FOR AUTONOMOUS FLYING ROBOT BY USING IMAGE PROCESSING BA...
AUTO LANDING PROCESS FOR AUTONOMOUS FLYING ROBOT BY USING IMAGE PROCESSING BA...
 
Visual pattern recognition in robotics
Visual pattern recognition in roboticsVisual pattern recognition in robotics
Visual pattern recognition in robotics
 
Portfolio - Ramsundar K G
Portfolio - Ramsundar K GPortfolio - Ramsundar K G
Portfolio - Ramsundar K G
 
OpenCV+Android.pptx
OpenCV+Android.pptxOpenCV+Android.pptx
OpenCV+Android.pptx
 
SENSITIVITY OF A VIDEO SURVEILLANCE SYSTEM BASED ON MOTION DETECTION
SENSITIVITY OF A VIDEO SURVEILLANCE SYSTEM BASED ON MOTION DETECTIONSENSITIVITY OF A VIDEO SURVEILLANCE SYSTEM BASED ON MOTION DETECTION
SENSITIVITY OF A VIDEO SURVEILLANCE SYSTEM BASED ON MOTION DETECTION
 
Visual pattern recognition in robotics
Visual pattern recognition in roboticsVisual pattern recognition in robotics
Visual pattern recognition in robotics
 
Build Your Own 3D Scanner: 3D Scanning with Structured Lighting
Build Your Own 3D Scanner: 3D Scanning with Structured LightingBuild Your Own 3D Scanner: 3D Scanning with Structured Lighting
Build Your Own 3D Scanner: 3D Scanning with Structured Lighting
 
Cvpr2010 open source vision software, intro and training part v open cv and r...
Cvpr2010 open source vision software, intro and training part v open cv and r...Cvpr2010 open source vision software, intro and training part v open cv and r...
Cvpr2010 open source vision software, intro and training part v open cv and r...
 
Computer Vision Introduction
Computer Vision IntroductionComputer Vision Introduction
Computer Vision Introduction
 
Vision based system for monitoring the loss of attention in automotive driver
Vision based system for monitoring the loss of attention in automotive driverVision based system for monitoring the loss of attention in automotive driver
Vision based system for monitoring the loss of attention in automotive driver
 
426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools
 
Artifacts Detection by Extracting Edge Features and Error Block Analysis from...
Artifacts Detection by Extracting Edge Features and Error Block Analysis from...Artifacts Detection by Extracting Edge Features and Error Block Analysis from...
Artifacts Detection by Extracting Edge Features and Error Block Analysis from...
 
Real Time Object Dectection using machine learning
Real Time Object Dectection using machine learningReal Time Object Dectection using machine learning
Real Time Object Dectection using machine learning
 
AUTOMATIC THEFT SECURITY SYSTEM (SMART SURVEILLANCE CAMERA)
AUTOMATIC THEFT SECURITY SYSTEM (SMART SURVEILLANCE CAMERA)AUTOMATIC THEFT SECURITY SYSTEM (SMART SURVEILLANCE CAMERA)
AUTOMATIC THEFT SECURITY SYSTEM (SMART SURVEILLANCE CAMERA)
 
Fisheye/Omnidirectional View in Autonomous Driving IV
Fisheye/Omnidirectional View in Autonomous Driving IVFisheye/Omnidirectional View in Autonomous Driving IV
Fisheye/Omnidirectional View in Autonomous Driving IV
 
slide-171212080528.pptx
slide-171212080528.pptxslide-171212080528.pptx
slide-171212080528.pptx
 

Más de zukun

Brunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionBrunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionzukun
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluationzukun
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-introzukun
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video searchzukun
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video searchzukun
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video searchzukun
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learningzukun
 
Advances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionAdvances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionzukun
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick startzukun
 
EM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysisEM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysiszukun
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structureszukun
 
Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities zukun
 
Icml2012 learning hierarchies of invariant features
Icml2012 learning hierarchies of invariant featuresIcml2012 learning hierarchies of invariant features
Icml2012 learning hierarchies of invariant featureszukun
 
ECCV2010: Modeling Temporal Structure of Decomposable Motion Segments for Act...
ECCV2010: Modeling Temporal Structure of Decomposable Motion Segments for Act...ECCV2010: Modeling Temporal Structure of Decomposable Motion Segments for Act...
ECCV2010: Modeling Temporal Structure of Decomposable Motion Segments for Act...zukun
 
Quoc le tera-scale deep learning
Quoc le   tera-scale deep learningQuoc le   tera-scale deep learning
Quoc le tera-scale deep learningzukun
 
Deep Learning workshop 2010: Deep Learning of Invariant Spatiotemporal Featur...
Deep Learning workshop 2010: Deep Learning of Invariant Spatiotemporal Featur...Deep Learning workshop 2010: Deep Learning of Invariant Spatiotemporal Featur...
Deep Learning workshop 2010: Deep Learning of Invariant Spatiotemporal Featur...zukun
 
Lecun 20060816-ciar-01-energy based learning
Lecun 20060816-ciar-01-energy based learningLecun 20060816-ciar-01-energy based learning
Lecun 20060816-ciar-01-energy based learningzukun
 
Lecun 20060816-ciar-02-deep learning for generic object recognition
Lecun 20060816-ciar-02-deep learning for generic object recognitionLecun 20060816-ciar-02-deep learning for generic object recognition
Lecun 20060816-ciar-02-deep learning for generic object recognitionzukun
 
P05 deep boltzmann machines cvpr2012 deep learning methods for vision
P05 deep boltzmann machines cvpr2012 deep learning methods for visionP05 deep boltzmann machines cvpr2012 deep learning methods for vision
P05 deep boltzmann machines cvpr2012 deep learning methods for visionzukun
 
P06 motion and video cvpr2012 deep learning methods for vision
P06 motion and video cvpr2012 deep learning methods for visionP06 motion and video cvpr2012 deep learning methods for vision
P06 motion and video cvpr2012 deep learning methods for visionzukun
 

Más de zukun (20)

Brunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionBrunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer vision
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluation
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-intro
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video search
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video search
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video search
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learning
 
Advances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionAdvances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer vision
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick start
 
EM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysisEM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysis
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structures
 
Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities
 
Icml2012 learning hierarchies of invariant features
Icml2012 learning hierarchies of invariant featuresIcml2012 learning hierarchies of invariant features
Icml2012 learning hierarchies of invariant features
 
ECCV2010: Modeling Temporal Structure of Decomposable Motion Segments for Act...
ECCV2010: Modeling Temporal Structure of Decomposable Motion Segments for Act...ECCV2010: Modeling Temporal Structure of Decomposable Motion Segments for Act...
ECCV2010: Modeling Temporal Structure of Decomposable Motion Segments for Act...
 
Quoc le tera-scale deep learning
Quoc le   tera-scale deep learningQuoc le   tera-scale deep learning
Quoc le tera-scale deep learning
 
Deep Learning workshop 2010: Deep Learning of Invariant Spatiotemporal Featur...
Deep Learning workshop 2010: Deep Learning of Invariant Spatiotemporal Featur...Deep Learning workshop 2010: Deep Learning of Invariant Spatiotemporal Featur...
Deep Learning workshop 2010: Deep Learning of Invariant Spatiotemporal Featur...
 
Lecun 20060816-ciar-01-energy based learning
Lecun 20060816-ciar-01-energy based learningLecun 20060816-ciar-01-energy based learning
Lecun 20060816-ciar-01-energy based learning
 
Lecun 20060816-ciar-02-deep learning for generic object recognition
Lecun 20060816-ciar-02-deep learning for generic object recognitionLecun 20060816-ciar-02-deep learning for generic object recognition
Lecun 20060816-ciar-02-deep learning for generic object recognition
 
P05 deep boltzmann machines cvpr2012 deep learning methods for vision
P05 deep boltzmann machines cvpr2012 deep learning methods for visionP05 deep boltzmann machines cvpr2012 deep learning methods for vision
P05 deep boltzmann machines cvpr2012 deep learning methods for vision
 
P06 motion and video cvpr2012 deep learning methods for vision
P06 motion and video cvpr2012 deep learning methods for visionP06 motion and video cvpr2012 deep learning methods for vision
P06 motion and video cvpr2012 deep learning methods for vision
 

ETHZ CV2012: Tutorial openCV

  • 1. OpenCV Basics and Camera Calibration Computer Vision Lab Tutorial 5 October 2012 Lorenz Meier, Kevin Koeser, Kalin Kolev Institute of Visual Computing
  • 2. What is OpenCV ? The most popular library in Computer Vision Released under the liberal BSD license It has C++, C, Python and Java interfaces and supports Windows, Linux, Android and Mac OS Offers optimized implementation of more than 2500 algorithms New official website: http://code.opencv.org OpenCV4Android: http://opencv.org/android.html Institute of Visual Computing
  • 3. OpenCV Overview Institute of Visual Computing
  • 4. Core Functionality Each image is represented as a matrix Basic class Mat for storing general n-dimensional arrays (e.g. grayscale images, color images, voxel volumes etc.) Fast access to its elements via pointers, e.g. Mat mat; mat.ptr<float>(i)[j] = … Direct access to user-allocated data (e.g. video frames) Mat image(height, width, CV_8UC3, pixels, step); Institute of Visual Computing
  • 5. Hints for Android Developers If you use the camera device, make sure that you have required permission in your AndroidManifest.xml <uses-feature android:name="android.hardware.camera" /> <uses-permission android:name="android.permission.CAMERA" /> If you want to write images to the storage of the mobile device via imwrite(), make sure that you have required permission in your AndroidManifest.xml <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> Institute of Visual Computing
  • 6. Image Segmentation Interactive image segmentation C. Rother, V. Kolmogorov, A. Blake, "GrabCut — Interactive Foreground Extraction using Iterated Graph Cuts" OpenCV implementation void grabCut(img, mask, rect, bgdModel, fgdModel, iterCount, mode); Institute of Visual Computing
  • 7. Pinhole Camera 𝑃 = 𝐾[𝑅|𝑡] Pinhole camera model projection matrix 𝑓𝑥 𝑠 𝑝𝑥 calibration matrix 𝐾= 0 𝑓𝑦 𝑝𝑦 0 0 1 𝑅 ∊ ℝ3𝑥𝑥 extrinsic parameters 𝑡 ∊ ℝ3 Institute of Visual Computing
  • 8. Camera Calibration OpenCV implementation bool findChessboardCorners(image, patternSize, corners, flags); double calibrateCamera(objectPoints, imgPoints, imgSize, camMatrix, distCoeffs, rvecs, tvecs, flags, criteria); Mat initCameraMatrix2D(objPoints, imgPoints, imgSize, aspectRatio); void getOptimalNewCameraMatrix(camMatrix, distCoeffs, imgSize, alpha, newImgSize, PixROI, cPP); void undistort(src, dst, cameraMatrix, distCoeffs, newCameraMatrix); Institute of Visual Computing
  • 9. Structure from Motion Structure-from-motion pipeline feature point feature point camera pose extraction matching/tracking estimation Institute of Visual Computing
  • 10. Feature Point Extraction Abstract base class for 2D image feature detectors FeatureDetector void FeatureDetector::detect(image, keypoints, mask); Ptr<FeatureDetector> FeatureDetector::create(detectorType); The following detector types are supported: FAST, STAR, SIFT (nonfree module), SURF (nonfree module), ORB, MSER, GFTT, HARRIS, Dense, SimpleBlob Institute of Visual Computing
  • 11. Feature Point Matching Abstract base class for computing descriptors for image keypoints DescriptorExtractor void DescriptorExtractor::compute(image, keypoints, descriptors); Ptr<DescriptorExtractor> DescriptorExtractor::create(descriptorType); The following types of descriptor extractors are supported: SIFT, SURF, ORB, BRIEF Alternative in case of video input: KLT tracker void calcOpticalFlowPyrLK(prevImg, nextImg, prevPts, nextPts, …); int buildOpticalFlowPyramid(img, pyramid, …); Institute of Visual Computing
  • 12. Camera Pose Estimation General approach: triangulation + bundle adjustment X x x' Special case: ground plane estimation 𝐻 ∊ ℝ3𝑥𝑥 homography matrix 𝑥 ′ = 𝐻𝐻 Institute of Visual Computing
  • 13. Hints to Planar Homography Estimation Don’t use OpenCV’s findHomography() as it estimates a general homography Note that a general homography has 8 degrees of freedeom while a plane is determined by only 3 degrees of freedom (=> use additional constraints) Reference: R. Hartley, A. Zisserman, "Multiple View Geometry in Computer Vision" Institute of Visual Computing
  • 14. Qualcomm`s Vuforia The Vuforia toolkit estimates camera intrinsics and poses by means of markers Camera intrinsics: QCAR::CameraCalibration Camera poses: QCAR::Trackable -> getPose() Note that in the current implementation no distortion parameters are being estimated Institute of Visual Computing