File Exchange

image thumbnail

January 2013 "Computer Vision with MATLAB" webinar demo files

version (413 KB) by Bruce Tannenbaum
MATLAB code used in the computer vision webinar held on January 29, 2013.


Updated 01 Sep 2016

View Version History

View License

The demos were presented in this order:
1. MatchCard.m - Showed how to recognize specific objects in a scene using SURF features.
2. FacePeopleDetection.m - Showed object detectors available in Computer Vision System Toolbox (vision.CascadeObjectDetector and vision.PeopleDetector).
3. visionfacetrackingKLT - Showed vision.PointTracker, which uses the Kanade-Lucas-Tomasi (KLT) algorithm.
4. ForegroundDetection.m - Showed vision.ForegroundDetector, configureKalmanFilter, and vision.KalmanFilter.

In the webinar, I also showed the demo "multiObjectTracking", which ships with Computer Vision System Toolbox

Cite As

Bruce Tannenbaum (2021). January 2013 "Computer Vision with MATLAB" webinar demo files (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (55)

zahra esp

vinh do

thank you very much!

ricardo pepinos

Bruce Tannenbaum

Hola Joseba,

En la versión 2016a, reemplazamos algunos objetos del sistema con funciones. Este código es para la versión 2012b, por lo que debe actualizarse con nuevas funciones. Puedes encontrar una tabla de funciones de reemplazo aquí:
Abra la última viñeta en esa página.

In English:
In release 2016a, we replaced some system objects with functions. This code is for release 2012b, so it needs to be updated with newer functions. You can find a table of replacement functions here:
Open the last bullet on that page.


Hola buenas ,

Tengo roblemas con una parte del programa. Me está dando error y no se bien por que puede ser. El error es el siguiente :

Undefined variable "vision" or class "vision.GeometricTransformEstimator".

Error in MatchCard (line 48)
gte = vision.GeometricTransformEstimator;

Nahet Cortés

Excelente, me ayuda muchisimo para mi proyecto, gracias!!!

Wenjia Zhang

Bruce Tannenbaum

Hi Thien,
The fourth argument of InsertObjectAnnotation is a label with the string 'scores'. You hit a frame where 'scores' is empty because the 'peopleDetector' algorithm didn't find anything in that frame. I believe we changed the algorithm such that it doesn't have the same exact results as 5 years ago when I wrote this. I suggest putting insertObjectAnnotation inside an if-statement with ' if ~isempty(scores)'. That will help catch and avoid this problem. As an example I did this in the loop in 'ForegroundDetection.m' which is also in the the zipfile. This is a "best practice" for annotations. No need to annotate something that doesn't exist!

Thien Tang

Hi Bruce
I have a problem in FacepeopleDection
When i use "Use PeopleDetector with video" ,it has this error
"Error using insertObjectAnnotation
Expected LABEL to be nonempty"
Can you tell me how to fix this, i really need this code to run
Thank you.

Pravachan benchals

hiii frnds

yi huang


Bruce Tannenbaum

Hi all,
Unfortunately, the playControl function used in ForegroundDetection.m does not work properly. Until I get this fixed, I suggest you remove it from the code and replace it with some other mechanism to pause the video.

Jubaer Hossain

Hello Bruce,
I'm using 2015a version.

Bruce Tannenbaum

Hi Jubaer,
What version of MATLAB are you using? I haven't tested this code in a few years.

Jubaer Hossain

Hi, Bruce. In ForegroundDetection section, playControl function does not seem to work. When any deployable vedio player starts, it does not show play and pause option. It keeps playing. Can you help me in this regard?


Maxim Kuzminsky

mina daowud

Terrill Yang

Bruce Tannenbaum

Ahmed - Try adjusting the 'MetricThreshold' parameter to detect weaker features. Another option would be to try another feature type: BRISK, FAST, MSER, Harris, LBP, etc.

ahmed SHAH

hi all .. i need to detect object in the image .. i am using surf features using caltech dataset but its not working fine ..any idea how to detect objects using surf or might my image dataset is not good any idea or tutorial on images

Alan Guadalupe Cano

chfakht chfakht

Hi all,

I need to separate the background from the foreground in a video using Kalman filter. Can somebody give me some resources or examples to follow.


Ömer Faruk AKMESE


Hasan Basik


Bruce Tannenbaum

Hi Arun,

Check out this doc page:



Hi Bruce,
Thanks for the webinar. Can you give some pointers towards how to choose values for InitialEstimateError, MotionNoise and MeasurementNoise in configureKalmanFilter?

Mario Svarc

Hi Bruce,
regarding MatchCard.m. If I have more variations of same reference Object in one image (more Queen of diamond cards - scaled, rotated...) and "matchFeatures" found for each of those objects a few matching pairs. Is there a way, using "estimateGeometricTransform", not to inlier only one cards matched points and overlay with patch/box but to keep all the "groups" of matched points and overlay patch/box over each of the cards. Or which function should I use.
Thank You,

Bruce Tannenbaum


Stereo vision gives you a depth value at every x,y location in the scene.



Thanks Bruce for your kind perusal. But, stereo vision would give me one dimension that is depth (if I am correct). What about the other dimension(other axis), that I need at the same time. My purpose is to get position of the boat in Cartesian coordinates (x,y) from the camera on ground.

Bruce Tannenbaum

Nadeem - Optical flow and stereo vision are two very different things. Optical flow is a class of algorithms that estimate motion, while stereo vision is the extraction of 3D information from a pair of cameras. If your cameras are on stable ground (not another boat) then you could use optical flow to find the boat and stereo vision to determine its distance from the cameras. If your cameras are on a boat, then you need an algorithm that is invariant to camera motion.

Andrei - I don't imagine Kalman filtering being particularly useful in smoke detection, which is a particularly hard challenge. You might want to keep blob detection, but use color or some other attribute as the basis for segmentation. Maybe vision.ForegroundDetector would work better along with moving data to the HSV color space and finding the color plane that shows the greatest difference between smoke and non-smoke.

Andrei Maresiev

Hi Bruse. I'm a student of Saratov State Technical University. I develop program detection smoke by video. Based on program tracking cars, i can detect motion using optical flow, method Lucas Canade. But, i can't to difference between smoke and non smoke. I try to use blob analysis, but also don't get results. So, my question to you, using KalmanFilter in object tracking, is it possible to distinguish smoke from human?


Hi Bruce,

I watched your video and downloaded the file. Its really a nice work. I have to find the real world x,y position data accurately for a slow moving boat(having a ball on the CG point) in order to incorporate in my research. In your opinion what should I use: the optical flow or stereo vision. I have two Fastcam MC2 cameras. Moreover, I have very little knowledge of Image processing and Computer Vision System. Kindly guide me. Thanks in anticipation.


Bruce Tannenbaum

Hi Nicola,

The technique I used in this demo assumed a camera at a fixed location. For when a car is moving, I suggest looking at this example:

You will need to train an object detector to recognize cars. You can do this with the trainCascadeObjectDetector function and several hundred images of cars as seen from the camera as you expect to mount it.

Nicola Bongiorno

Hi Bruce. I'm a student of University of Messina, I'd like to use your program to find cars using a dynamic camera mounted on my car. Is it possible? How can I do it? Could you help me?


Where can we watch this recorded webinar?

Suhas Yelluru

Suhas Yelluru

Hey Bruce,
what changes are to be made in order to use your face tacking algorithm so that the process is done in real time using the computer's webcamera as videoinput?

Bruce Tannenbaum

Hi Syazana,

I suggest using vision.KalmanFilter and configureKalmanFilter.


Syazana Ibrahim

Hye Bruce Tannenbaum, If i had make a detection of people use the vision.peopleDetector and what is the best way to track people by using that toolbox?

Bruce Tannenbaum

Hi Syazana,

Thanks for your question!

vision.ForegroundDetector provides a binary mask of "pixels" in the foreground of a video.

vision.PeopleDetector requires at least grayscale images, if not color, to detect upright standing people. It wasn't designed to be used in combination. Rather, it is a replacement.

If the camera is stationary, then vision.ForegroundDetector is much faster at detecting moving objects, including people. If the camera is moving, then that algorithm fails to detect people, but vision.PeopleDetector will still work.

Hope this helps!

- Bruce

Syazana Ibrahim

Hye Bruce Tannenbaum, I have try use the foreground for vision.PeopleDetector but it seem not support that function. Is it when we use peopleDetector we can not add the function of foreground? Because the example you give for foreground is by using the blobAnalysis. Thank you.

Eric Nunes

Hi Bruce,
I am trying to run the demo in 13b. But I am getting the error :
Undefined variable "vision" or function "vision.PeopleDetector".

Error in FacePeopleDetection (line 7)
peopleDetector = vision.PeopleDetector;

How do i get around it.


Bruce Tannenbaum

Hi John,

This code requires release 12b or later. The function "vision.PeopleDetector" was new in release 12b, so I would expect you to get that error if you ran the code in 12a.


Lukas John

Hi Bruce,
i have 12a but this code i doesn't work.
It write error:
Undefined variable "vision" or function "vision.PeopleDetector".
Try help me please.

i have use matlab 13a is this code work for it

Bruce Tannenbaum

Hi Hassan,

I’ve checked the code for release 13b and everything seems functional. Can you answer two questions so that I can try to figure out what’s not working for you?

1. What release of MATLAB are you using (12b, 13a, ?) If you are using 11b or earlier, this code won't work right.
2. Which file in my entry is giving you the problem?

Thanks, Bruce

Hassan Javaid

I'm also having the same error:

Scalar structure required for this assignment.

Error in SURFPoints/subsref (line 462)
locS.subs{2} = 1:2;

Error in MatchCard (line 21)
scale = ref_pts(i).Scale;

Please help me with this error.


Perfect code.


I got the following error message
Scalar structure required for this assignment.
Error in SURFPoints/subsref (line 462)
locS.subs{2} = 1:2;

Error in MatchCard (line 21)
scale = ref_pts(i).Scale;
Could you please help? I tried your version from 2012. They also have same error


Thank You

fath yhia

thank you

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!