Object Detection Source Code (Matlab)

1. About the code.

2. Download the code.

3. Demo step by step for one scale.

4. Related papers.

5. Contact me.

6. Back to main page

 

1. About the code.

Copyleft @2008

This code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

This code is written for the paper [1]. It was initially developed by Gang and Liming, and cleaned up by Liming in Jan 2008. It's tested under Matlab 7.0. The version number is now 1.0beta.

The main part of the code uses improved Shape Context as feature descriptor and fit into a Hough Voting framework to detect objects. It can be used for initial hypothesis proposal. I hope you find this code helpful!

2. Download the code here.

Note:

1) Currently, this code does not include the False Positive Pruning (FPP) procedure using bottom-up segmentation, which is the second part of the paper [1].

3. Demo step by step for one scale, multi-scale detection is here.

<<Top

1) Load codebook data;

% load codebook, which are set of model features (How does codebook look like?)

load(codebook_file);

% Take 'FudanPed00001.png' as an example,only scale 4 is demonstrated.

% Please see how to detect object across scales here.

% Only some code fragments are shown here, please refer to 'demo_one_image.m' for details

2) Read image in and do edge detection;

img_name = 'FudanPed00001.png';

img= imread(img_name); % read image data in.

imshow(img); % Figure 1

% edge detection on image using pb edge detector

I_edge = compute_edge_pb(img);

imshow(I_edge.edge); % Figure 2

3) Sampling on edge map and compute shape context on each sample point;

% sample feature points on test image and remove those nearly-zero features

testpos = sample_grid_location([imgh,imgw], para_fea.sample_step);

hold on;

plot(testpos(:,1),testpos(:,2), '*'); % Figure 3

extract_sc_feature;

Source image Edge scale 4 Sampling on edge
Fig 1. Input image. Fig 2. Edge detection result of input image. Fig 3. Sample points on input image to extract features on.

4) Compute matching score and select best K matches for each test point;

% compute matching for each feature points, each test feature point will look for best K matches among codebook

compute_matching_scores_bestK;

point on test image
 
Fig 4. 'A' is a point on input image. Fig 5. These 7 images are from codebook, which are model images.
'B' - 'H' are matches to 'A' in Fig 4.
Each match will indicate where the body center could possibly be.

5) Voting to get a vote map;

% each match votes for possible candidate positions

get_candidate_pos; % Figure 5

% generate hypotheses acording to vote map

get_hypo_center; %Figure 6, Figure 7

Vote map Vote map over edge with hypotheses plotted
Fig 6. Vote result. High value indicate high possiblity that position could be a hypothesis center. Fig 7. Select hypotheses postition from vote map(Fig. 6), indicated by magenta cross.

% For each possible hypotheses, trace back to get its vote mask and boundary box.

6) Elect possible hypotheses positions and trace back to get hypothesis masks;

generate_mask_and_bbox; % Figure 8

% Enforce one-to-one feature point and model point match, Figure and figure show the score computed before this enforcement and after

compute_unique_vote_score; % Figure 9

Mask and bbox Mask and bbox 1
Fig 8. For each hypothesis, trace back to find its voters and each vote predict the foreground/background labeling of the input image, which gives a hypothesis mask, and boundary boxs can be easily derived from this mask. Fig 9. After force one-to-one unique matching, we get an new score for each hypothesis.

 

7) Image segmentation using Normalized Cut ([2])

8) Segments reasoning based on hypothesis mask and segmentation results;

9) Re-evaluate hypothesis score;

 

4. Related papers and database.

<<Top

[1] Object Detection Combining Recognition and Segmentation, Liming Wang, Jianbo Shi, Gang Song, I-Fan Shen, Eighth Asian Conference on Computer Vision (ACCV), 2007 [Database: Penn-Fudan Pedstrian Database ]

[2] Normalized Cuts and Image Segmentation Jianbo Shi and Jitendra Malik IEEE Transactions on Pattern Analysis and Machine Intelligence(PAMI) 2000

5. Feel free to contact me if you have any question or suggestion:

wanglm AT fudan DOT edu DOT cn.

<<Top <<Back to main page