<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://mediawiki.isr.tecnico.ulisboa.pt/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Anambiar</id>
	<title>ISRWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://mediawiki.isr.tecnico.ulisboa.pt/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Anambiar"/>
	<link rel="alternate" type="text/html" href="http://mediawiki.isr.tecnico.ulisboa.pt/wiki/Special:Contributions/Anambiar"/>
	<updated>2026-06-21T18:01:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>http://mediawiki.isr.tecnico.ulisboa.pt/index.php?title=DollarPedestrianDetectionCode&amp;diff=5399</id>
		<title>DollarPedestrianDetectionCode</title>
		<link rel="alternate" type="text/html" href="http://mediawiki.isr.tecnico.ulisboa.pt/index.php?title=DollarPedestrianDetectionCode&amp;diff=5399"/>
		<updated>2013-07-11T14:26:10Z</updated>

		<summary type="html">&lt;p&gt;Anambiar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Piotr Dollár et. al. collected the [http://www.vision.caltech.edu/Image_Datasets/CaltechPedestrians/ Caltech Pedestrian Detection Benchmark], a set of data and code to evaluate pedestrian detection algorithms. The data base consists of sequences of annotated images acquired by a camera mounted on a car. The authors provide the data, some code that allow others to test their detector on that data and the results of many state-of-the-art detectors, both in a synthetic form (ROC curves), as well as in the extensive form (the actual detection bounding boxes for each image). The authors also provide other data sets and results converted to match their format.&lt;br /&gt;
&lt;br /&gt;
In order to have the system running you should download Piotr&#039;s Matlab Toolbox, the Evaluation/Labelling code and the data (image sequences, ground truth bounding boxes and detection results bounding boxes). You have link to these on the main page of the [http://www.vision.caltech.edu/Image_Datasets/CaltechPedestrians/ Caltech Pedestrian Detection Benchmark].&amp;lt;br&amp;gt;&lt;br /&gt;
For the code to work you need to have Matlab with the Image Toolbox installed.&lt;br /&gt;
&lt;br /&gt;
== Getting ready ==&lt;br /&gt;
You should unpack the Piotr&#039;s Matlab Toolbox somewhere and add it to the Matlab Path: &lt;br /&gt;
  addpath(genpath(&#039;/home/matteo/PMT/&#039;)); savepath;&lt;br /&gt;
&lt;br /&gt;
You should unpack the Evaluation/Labelling code in a directory that we will call $code (later, you should run Matlab from that directory).&lt;br /&gt;
&lt;br /&gt;
All the files (image data bases, annotations, detection results) should be put in some standard subdirectories of &#039;&#039;&#039;$code/&#039;&#039;&#039;.&lt;br /&gt;
You have to have one subdirectory for each db, for instance, you need one for INRIA: &#039;&#039;&#039;$code/data-INRIA/&#039;&#039;&#039;. The names are standard, they&#039;re defined in some matlab file.&amp;lt;br&amp;gt;&lt;br /&gt;
Inside the particular db directory, you need to have:&lt;br /&gt;
# the video subdirectory, &#039;&#039;&#039;$code/data-INRIA/videos&#039;&#039;&#039;, containing more subdirectories and the &amp;quot;.seq&amp;quot; files with the images&lt;br /&gt;
# the annotations subdirectory, &#039;&#039;&#039;$code/data-INRIA/annotations&#039;&#039;&#039;, containing more subdirectories and the ground truth annotations&lt;br /&gt;
# the res subdirectory, &#039;&#039;&#039;$code/data-INRIA/res&#039;&#039;&#039;, containing more subdirectories with the results of the detections obtained running various algorithms&lt;br /&gt;
&lt;br /&gt;
Annotations are in the format: (x0, y0, deltaX, deltaY, confidence). The confidence value is used to plot the ROC curves.&lt;br /&gt;
There is one annotation file for each image.&lt;br /&gt;
I don&#039;t know if the top-left corner is (0,0) or (1,1).&lt;br /&gt;
&lt;br /&gt;
== Operations you want to do ==&lt;br /&gt;
=== Set the db you&#039;re working on ===&lt;br /&gt;
  [pth,setIds,vidIds,skip,minHt] = dbInfo( &#039;inriatest&#039; )&lt;br /&gt;
or simply:&lt;br /&gt;
  dbInfo( &#039;inriatest&#039; )&lt;br /&gt;
&lt;br /&gt;
=== Show db images with annotations ===&lt;br /&gt;
vbbPlayer&lt;br /&gt;
&lt;br /&gt;
=== Compute the ROC curves for the specified algorithms, on the current db ===&lt;br /&gt;
dbEval&lt;br /&gt;
&lt;br /&gt;
=== Display images with GT annotations, the detections of a specific algorithm and their evaluation (true positive, false positive, etc.) ===&lt;br /&gt;
dbBrowser&lt;br /&gt;
&lt;br /&gt;
You should set some parameters in dbBrowser.m, such as which algorithm&#039;s results you want to plot and if you want to resize the detected bounding boxes. I am not sure when you want to resize the bounding boxes, if it depends on the algorithm you are testing or on the data base you are using.&lt;br /&gt;
  rPth=[pth &#039;/res/HOG&#039;];        % directory containing results&lt;br /&gt;
  thr=[];                       % detection threshold&lt;br /&gt;
  resize={100/128, 42/64, 0};   % controls resizing of detected bbs&lt;br /&gt;
&lt;br /&gt;
This file writes plots in $code/results and data in $code/eval.&lt;br /&gt;
&lt;br /&gt;
==How to evaluate the results of your algorithm==&lt;br /&gt;
&lt;br /&gt;
You should repeat, for all the images in a given set:&lt;br /&gt;
# read one image &lt;br /&gt;
# run your classifier on it&lt;br /&gt;
# write the annotations in your results directory, e.g. &#039;&#039;&#039;$code/data-INRIA/res/myDetector/set01/V000/I00000.txt&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example:&lt;br /&gt;
  close all, clear;&lt;br /&gt;
  &lt;br /&gt;
  %Add the directories where Maji code is stored to the path&lt;br /&gt;
  addpath MajiCode/ped-demo-fast-8x8x1.1/&lt;br /&gt;
  addpath MajiCode/libsvm-mat-2.84-1-fast.v3/&lt;br /&gt;
  &lt;br /&gt;
  %Set parameters for Maji&#039;s code&lt;br /&gt;
      % non max supression (similar to hog-detector)&lt;br /&gt;
      nmax_param.sw = 0.1;&lt;br /&gt;
      nmax_param.sh = 0.1;&lt;br /&gt;
      nmax_param.ss = 1.3;&lt;br /&gt;
      nmax_param.th = 0.0;&lt;br /&gt;
  &lt;br /&gt;
      % detector is run at this scaleratio with a stride of 8x8&lt;br /&gt;
      scaleratio = 2^(1/8);&lt;br /&gt;
  &lt;br /&gt;
      % load precomputed models&lt;br /&gt;
      load approx_models;&lt;br /&gt;
      approx_model_hard = approx_models{2}; &lt;br /&gt;
      %two slightly different models (#training) &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  %Open the image sequence file (INRIA test set)&lt;br /&gt;
  seqReader = seqIo( &#039;data-INRIA/videos/set01/V000.seq&#039;, &#039;reader&#039;); %The pointer initially points to image -1, after the first sequReader.next() it points to image 1&lt;br /&gt;
  outputDirectory = &#039;data-INRIA/res/MatteoMaji/set01/V000/&#039;; %Set where to write the results&lt;br /&gt;
  info = seqReader.getinfo();&lt;br /&gt;
  nImages = info.numFrames;&lt;br /&gt;
  &lt;br /&gt;
  %Run the detector on each image, store bounding boxes results (and images?)&lt;br /&gt;
  for (imageNumber = 1 : nImages)&lt;br /&gt;
    seqReader.next();                          %Move pointer to the next image&lt;br /&gt;
    [image, timeStamp] = seqReader.getframe(); %Get current image&lt;br /&gt;
    [dr,ds] = run_detectorForDollar(image,approx_model_hard,scaleratio,nmax_param, outputDirectory, imageNumber-1); %Detect pedestrians (imageNumber is -1 because file numbers start from 0!)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Once you have you detections, you can evaluate them with &#039;&#039;&#039;dbEval.m&#039;&#039;&#039;, I had to change some parameters like this:&lt;br /&gt;
  dataNames={&#039;InriaTest&#039;};  %Evaluate algorithms on INRIA test&lt;br /&gt;
  &lt;br /&gt;
  [...]&lt;br /&gt;
  &lt;br /&gt;
  case &#039;InriaTest&#039;&lt;br /&gt;
      aIds=[7 15]; bnds=[]; %Evaluate only HIKSVM and my algorithm&lt;br /&gt;
  &lt;br /&gt;
  [...]&lt;br /&gt;
  &lt;br /&gt;
  case 15,    alg=def(&#039;MatteoMaji&#039;,1,id); %Define the name and directory for my algorithm&lt;br /&gt;
  %I&#039;m not quite sure what the 1 means&lt;br /&gt;
&lt;br /&gt;
After running &#039;&#039;&#039;dbEval.m&#039;&#039;&#039;, you can run &#039;&#039;&#039;dbBrowser.m&#039;&#039;&#039; and compare your detection bounding boxes with the ground truth ones, inspect whether or not the evaluation software considers a detection as successful, etc.&lt;br /&gt;
&lt;br /&gt;
You can change some parameters in &#039;&#039;&#039;dbEval.m&#039;&#039;&#039; so that it creates albums showing the mistakes a specific algorithm makes.&lt;br /&gt;
(Be careful to select only one algorithm to evaluate, otherwise you will create at least tens of albums!)&lt;br /&gt;
&lt;br /&gt;
  plotBb( res, rDir, 30, &#039;fp&#039; ); %The third parameter tells the system how many pages of fals positives to save at most&lt;br /&gt;
  plotBb( res, rDir, 0, &#039;tp&#039; );  %If you want to save true positives&lt;br /&gt;
  plotBb( res, rDir, 30, &#039;fn&#039; ); %The third parameter tells the system how many pages of fals negatives to save at most&lt;br /&gt;
&lt;br /&gt;
=== Read one or more imags from a &amp;quot;.seq&amp;quot; file and write it to a regular file ===&lt;br /&gt;
  Is = seqIo( &#039;data-INRIA/videos/set00/V000.seq&#039;, &#039;toImgs&#039;, &#039;.&#039;,              1,                  0,               2,          &#039;png&#039; )&lt;br /&gt;
               input seq file                      command  dest directory    frames to skip      first frame   last frame     format&lt;br /&gt;
&lt;br /&gt;
=== Create seq file from a directory of images ===&lt;br /&gt;
&lt;br /&gt;
seq utility: help seqIo&amp;gt;frImags&lt;br /&gt;
&lt;br /&gt;
   info.codec=&#039;jpg&#039;; &lt;br /&gt;
   info.fps=5;&lt;br /&gt;
   info.quality = 100;&lt;br /&gt;
   info.width =640;&lt;br /&gt;
   info.height =480;&lt;br /&gt;
   seqIo(&#039;cam51.seq&#039;,&#039;frImgs&#039;, info,&#039;sDir&#039;,&#039;/home/athira/Desktop/HDA/data_labelling/toolbox/cam51&#039;, &#039;f0&#039;,0,&#039;f1&#039;,3660  )&lt;br /&gt;
          fname       command  info  varargin&lt;br /&gt;
Note: The code expects the extention of the image as &#039;.jpg&#039; and not &#039;.jpeg&#039;. So, in case if you want to use jpeg, alter the seqIo.m  in line 335.(frmStr)&lt;br /&gt;
&lt;br /&gt;
=== Adding a new dataset WIP ===&lt;br /&gt;
In order to add a new dataset to the system, you should first of all create one or more seq files.&lt;br /&gt;
So, create the root directory where this dataset will reside &#039;&#039;&#039;data-HDA&#039;&#039;&#039;, plus the three subdirectories &#039;&#039;&#039;data-HDA/videos&#039;&#039;&#039;, &#039;&#039;&#039;data-HDA/annotations&#039;&#039;&#039; and &#039;&#039;&#039;data-HDA/res&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Insert the entry relative to this dataset into the dbInfo.m script:&lt;br /&gt;
&lt;br /&gt;
  case &#039;hda&#039;&lt;br /&gt;
    setIds=0;      %ID&#039;s of sub datasets if there are some&lt;br /&gt;
    subdir=&#039;HDA&#039;;&lt;br /&gt;
    skip=1;        %number of frames used for subsampling during evaluation&lt;br /&gt;
    minHt=50;      %minimum labeled pedestrian height in dataset, not sure if this is used in the code somewhere or if it&#039;s just descriptive&lt;br /&gt;
    vidIds={0};    %video ID&#039;s inside each of the sub datasets&lt;br /&gt;
&lt;br /&gt;
To create a seq file staring from a video, you can use the [http://users.isr.ist.utl.pt/~mtaiana/code/createSeqFile.m createSeqFile.m] script. For some reason, the seq files created this way are not playable directly with &#039;&#039;&#039;vbbPlayer.m&#039;&#039;&#039;, but it can be labelled using &#039;&#039;&#039;vbbLabeler.m&#039;&#039;&#039;. You can download a short tutorial on how to use the labeller here: [http://users.isr.ist.utl.pt/~mtaiana/temp/LabellingDemo.mkv labelling demo].&lt;br /&gt;
&lt;br /&gt;
The classes for the bounding boxes are &#039;&#039;&#039;person&#039;&#039;&#039; for a single person, &#039;&#039;&#039;person?&#039;&#039;&#039; for something the labeler is not sure whether it is a person or not, &#039;&#039;&#039;people&#039;&#039;&#039; for groups of people for which it is impossible to label each person correctly. There is a label for persons who are partly occluded, it&#039;s not so clear how it works.&lt;br /&gt;
&lt;br /&gt;
=== Accessing the frames of a seq file ===&lt;br /&gt;
&lt;br /&gt;
  %Initialize the reader&lt;br /&gt;
  seqReader = seqIo( &#039;cam60.seq&#039;, &#039;reader&#039;);&lt;br /&gt;
  %Read one frame&lt;br /&gt;
  seqReader.seek(269);&lt;br /&gt;
  image = seqReader.getframe();&lt;br /&gt;
  imshow(image);&lt;br /&gt;
&lt;br /&gt;
=== Annotating the INRIA data set again ===&lt;br /&gt;
It seems impossible to do it with &#039;&#039;&#039;vbbLabeler.m&#039;: it complains about something, like the fact that the images are not all of the same size.&lt;br /&gt;
So we might do that using &#039;&#039;&#039;bblabeler.m&#039;&#039;&#039;, which saves the annotations in a different format, but should be useful anyway.&lt;br /&gt;
&lt;br /&gt;
  bbLabeler( [{&#039;person&#039;, &#039;people&#039;}], &#039;~/PhD/datasets/INRIAPerson/Train/pos/&#039;, &#039;inriaNewLabels&#039;);&lt;/div&gt;</summary>
		<author><name>Anambiar</name></author>
	</entry>
</feed>