Presentation is loading. Please wait.

Presentation is loading. Please wait.

Optical Flow walk through Aidean Sharghi Spring 14.

Similar presentations


Presentation on theme: "Optical Flow walk through Aidean Sharghi Spring 14."— 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

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 void cvCalcOpticalFlowPyrLK(const CvArr* prev, const CvArr* curr, CvArr* prevPyr, CvArr* currPyr, const CvPoint2D32f* prevFeatures, CvPoint2D32f* currFeatures, int count, CvSize winSize, int level, char* status, float* track_error, CvTermCriteria criteria, int flags) Two useful functions

16 int buildOpticalFlowPyramid(InputArray img, OutputArrayOfArrays pyramid, Size winSize, int maxLevel, bool withDerivatives=true, int pyrBorder=BORDER_REFLECT_101, intderivBorder=BORDER_CONSTANT, bool tryReuseInputImage=true)


Download ppt "Optical Flow walk through Aidean Sharghi Spring 14."

Similar presentations


Ads by Google