1 / 16

Optical Flow walk through

Optical Flow walk through. Aidean Sharghi Spring 14. Optical Flow. The objective in this assignment is to setup and use Optical Flow This implementation is fast and so you will see it can be used for real-time purposes Required steps to setup and run are provided in this presentation.

benita
Download Presentation

Optical Flow walk through

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Optical Flow walk through Aidean Sharghi Spring 14

  2. Optical Flow • The objective in this assignment is to setup and use Optical Flow • This implementation is fast and so you will see it can be used for real-time purposes • Required steps to setup and run are provided in this presentation

  3. Contents • OpenCV installation process • Setting Environment Variables • How to run Optical Flow

  4. OpenCV • OpenCV stands for Open-source Computer Vision • It is a library of useful functions used in Computer Vision • To run Optical Flow: • Install OpenCV 2.2 if you have VS 2010 installed on your machine • Install OpenCV 2.4 if you have VS 2012

  5. Install OpenCV2.2 for VS 2010 • Download OpenCV2.2 from http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.2/ • Extract the files in C:\OpenCV2.2 • Set Environment Variables. • If variable ‘path’ exists, just add the C:\OpenCV2.2\bin\ to the end of its value • If ‘path’ does not exist, just add a new variable and name it ‘path’ and set its value to what mentioned above

  6. Install OpenCV2.4 for VS 2012 • Download OpenCV2.4 from http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.4/OpenCV-2.4.4.exe • Extract the files in C:\opencv • Set Environment Variables. • Add the new variable ‘path’ and set its value to “C:\opencv\build\(your VS build x86/x64)\vc11\bin\ “ • E.g. if you have VS x64 version installed on your machine, the value will be: C:\opencv\build\x64\vc11\bin

  7. Set the Environment Variable in Windows 7/8/8.1

  8. Building the Project • Just download and build the project using your VS • Open a command prompt and change its directory to your project’s debug folder • Give the input

  9. Command Prompt • Open Command Prompt • To do so, you can hold Ctrl key and press R. Run window will show up. Then write cmd in the box and press enter. • Change Directory to the Debug Folder • cd is the command you need to use. • For example if you enter: • cd C:\Users\’your username’\Desktop This will take you to your desktop

  10. Two ways to use • When you are in the Debug folder, then you have two options • Compute Optical Flow • frames imageFile1 imageFile2 change directory to the debug folder then enter these: > OpticalFlow.exe frames image0.jpg image1.jpg • Find the Optical Flow by webcam • camera or NULL > OpticalFlow.exe camera

  11. Four keys to control • w : increment (by 10) number of corners to track (max = 400) • s : decrement (by 10) number of corners to track (min=10) • d : double pyramid window size (max=64) • a : half pyramid window size (min=2)

  12. Code Analysis Load Image 1 Interest Points KLT Tracker using 2 images

  13. Harris Corner Detector • Compute horizontal and vertical derivatives of image • Compute the matrix • Convolve the matrix with a larger Gaussian window. • Compute the Eigen vector of M • Find local maxima above threshold as interest points

  14. KLT Tracker • Detect Harris corners in the first frame • Build the Optical Flow Pyramid • For each Harris corner compute motion between consecutive frames • Link motion vectors in successive frames to get a track for each Harris point • Introduce new Harris points by applying Harris detector at every m frames

  15. Two useful functions • void cvCalcOpticalFlowPyrLK(constCvArr* prev, constCvArr* curr, CvArr* prevPyr, CvArr* currPyr, const CvPoint2D32f* prevFeatures, CvPoint2D32f* currFeatures, int count, CvSizewinSize, int level, char* status, float* track_error, CvTermCriteria criteria, int flags)

  16. Two useful functions • intbuildOpticalFlowPyramid(InputArrayimg, OutputArrayOfArrayspyramid, Size winSize, intmaxLevel, boolwithDerivatives=true, intpyrBorder=BORDER_REFLECT_101, intderivBorder=BORDER_CONSTANT, booltryReuseInputImage=true)

More Related