Skip to content

Commit

Permalink
Merge pull request #3 from mjmarin/devel
Browse files Browse the repository at this point in the history
Devel merged into master
  • Loading branch information
mjmarin committed Mar 15, 2014
2 parents d025181 + 268af90 commit 194740a
Show file tree
Hide file tree
Showing 33 changed files with 2,110 additions and 270 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ Thumbs.db
##########
*.aux
*.bbl
*.blg
*.blg
*.html
*.map
*.md5
*.png
*.gch
*.css
*~
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(pabod)
set(PROJECT_VERSION "0.2.7")
set(PROJECT_VERSION "0.2.10")
string(REGEX MATCHALL "[0-9]" PROJECT_VERSION_PARTS "${PROJECT_VERSION}")
list(GET PROJECT_VERSION_PARTS 0 PROJECT_VERSION_MAJOR)
list(GET PROJECT_VERSION_PARTS 1 PROJECT_VERSION_MINOR)
list(GET PROJECT_VERSION_PARTS 2 PROJECT_VERSION_PATCH)
list(GET PROJECT_VERSION_PARTS 3 PROJECT_VERSION_PATCH2)
set(PROJECT_SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")


Expand All @@ -29,7 +30,7 @@ MESSAGE(STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")

if(WIN32)
# Postfix of DLLs:
SET(PROJECT_DLLVERSION "${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}${PROJECT_VERSION_PATCH}")
SET(PROJECT_DLLVERSION "${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}${PROJECT_VERSION_PATCH}${PROJECT_VERSION_PATCH2}")
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}")
SET(RUNTIME_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Directory for dlls and binaries")
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Directory for binaries")
Expand Down Expand Up @@ -127,7 +128,7 @@ endif()
# ADDING PROJECT VERSION
file(APPEND ${CUSTOM_H} "\n#define PABOD_MAJOR_VERSION ${PROJECT_VERSION_MAJOR}\n")
file(APPEND ${CUSTOM_H} "\n#define PABOD_MINOR_VERSION ${PROJECT_VERSION_MINOR}\n")
file(APPEND ${CUSTOM_H} "\n#define PABOD_PATCH_VERSION ${PROJECT_VERSION_PATCH}\n")
file(APPEND ${CUSTOM_H} "\n#define PABOD_PATCH_VERSION ${PROJECT_VERSION_PATCH}${PROJECT_VERSION_PATCH2}\n")

# DEALING WITH MATIO VERSIONS
IF(WIN32)
Expand Down Expand Up @@ -155,7 +156,7 @@ ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/c
# ----------------------------------------------------------------------------
# create configuration file from .in file (If you use windows take care with paths)
# ----------------------------------------------------------------------------

set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE ${CMAKE_CURRENT_SOURCE_DIR}/include)
CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/config.cmake.in" "${PROJECT_BINARY_DIR}/Find${PROJECT_NAME}.cmake")
INSTALL(FILES "${PROJECT_BINARY_DIR}/Find${PROJECT_NAME}.cmake" DESTINATION lib/cmake/ )

Expand Down
2 changes: 1 addition & 1 deletion COPYING.libpabod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2011 Daniel Rodriguez Molina and Manuel J. Marin-Jimenez
Copyright (C) 2011, 2012, 2013 Daniel Rodriguez Molina and Manuel J. Marin-Jimenez

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
116 changes: 116 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
==============================================================================
libpabod: Library for PArt-Based Object Detection in C++
==============================================================================
Daniel Rodriguez Molina and Manuel J. Marin-Jimenez

This software implements the object detection system described in Felzenszwalb et al. [1].
--------------------------------------------------------------------------------

Source-Code: https://github.com/mjmarin/libpabod

--------------------------------------------------------------------------------
Contents of the package:
--------------------------------------------------------------------------------
- bin - the executable file will be created here
- data:
- models - contains all the object model files
- testimages - a set of images to test the software
- doc - folder where the documentation will be generated
- include - contains all the software header files
- libs - folder where the library will be generated
- obj - folder where the object files will be generated during the compilation
- src - contains all the software source files
- tests - contains some programs to test the library
- makefile - used to compile the library, the documentation and the test program

--------------------------------------------------------------------------------
Requirements:
--------------------------------------------------------------------------------
This software has been tested on Ubuntu 10.10 (Maverick Meerkat) with the following libraries:
- libmatio-dev - v1.3.4-2 (required)
- libcv-dev - v2.1.0-2 (required)
- libhighgui-dev - v2.1.0-2 (required)
- doxygen - v1.7.1-1 (optional; used to generate the documentation)
- graphviz - v2.26.3-4 (optional; used to generate figures for the documentation)

--------------------------------------------------------------------------------
Quick start:
--------------------------------------------------------------------------------

A) Classic installation (obsolete --> CMake is highly recommended):
1. Unpack in <libpabod_directory>
2. cd <libpabod_directory>
3.1. Generating the library
> make
3.2. Creating the test programs
> make alltests
3.3. Generating the documentation
> make docum
3.4. Recompiling all
> make cleanobj
> make

Tip: use 'make all' to generate both the library and the test programs.

B) Installing with CMake:
Please, follow the steps described in the file named INSTALL.

C) Testing the library:
(assuming test program has been already generated)
1. cd <libpabod_directory>
2. ./bin/detectobj -m <model_path> -i <image_path> [-t <threshold>] [-o <detections_path>] [-d <0/1>]
Example:
> ./bin/detectobj -m data/models/person_v6.mat -i data/testimages/2008_007537.jpg -t -0.3 -o detections.txt

If the program has finished correctly, you will find a text file named 'detections.txt' with the following structure:
<number_of_detected_objects>
<x1_i> <y1_i> <x2_i> <y2_i> <score_i>
where <x1_i> <y1_i> <x2_i> <y2_i> are the pairs of coordinates of the i-th bounding box and <score_i> is its corresponding detection score.

Tip: object detection can be performed directly on video frames (e.g. avi file) with the test program named 'detectvid'.

--------------------------------------------------------------------------------
Citation:
--------------------------------------------------------------------------------
If you use this library for your publications, please cite it as:
@misc{libpabod,
author = {Rodriguez-Molina, Daniel and Marin-Jimenez, Manuel J.},
title = {{LibPaBOD}: A Library for Part-Based Object Detection in {C++}},
year = {2011},
note = {Software available at \url{http://www.uco.es/~in1majim/}}
}

--------------------------------------------------------------------------------
Contact the authors:
--------------------------------------------------------------------------------
Daniel Rodriguez Molina (developer) - [email protected] / [email protected]
Manuel J. Marin-Jimenez (advisor) - [email protected]

--------------------------------------------------------------------------------
References:
--------------------------------------------------------------------------------
[1] P. Felzenszwalb, R. Girshick, D. McAllester, D. Ramanan. "Object Detection with Discriminatively Trained Part Based Models." IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 32, No. 9, September 2010.
URL: http://people.cs.uchicago.edu/~pff/latent/

--------------------------------------------------------------------------------
Version history:
--------------------------------------------------------------------------------
- v0.2.10: new option '-k' added to 'detectobj2' to show only K top detections
- v0.2.9: moving CvMat to cv::Mat
- v0.2.8: new class Detection
- v0.2.7: memory leaks found by github/yokox solved. Thanks!
- v0.2.6: new file 'export.h' for properly exporting functions to dll's.
- v0.2.5: updated CMake files and other minor improvements for Windows compatibility.
- v0.2.4: CMake and code updated to properly manage libmatio on Windows (thanks to Eric Sommerlade for his invaluable contributions). See new file 'INSTALL.windows'. libmatio 1.5.x is supported.
- v0.2.2: detector component is now included in detections matrix. Other minor improvements.
- v0.2.1: OpenMP is now optional via CMake. Selection of OpenMP overrides pthread's choice.
- v0.2: new class Pabod. It encapsulates the class model and detection process. New demo file 'detectobj2.cpp' uses Pabod class. pthread is now optional via CMake. New 'quickstart.pdf' in directory 'doc'.
- v0.1.7: fixed bugs (i.e. memory leaks) reported by <anonymous>.
- v0.1.6: fixed documentation option for CMake (thanks to eichnerm). Use 'cmake .. -DINSTALL_DOC=ON" to generate the library documentation.
- v0.1.5: CMake is supported (thanks to [email protected]). By default, the library is built in shared mode (non-static).
- v0.1.4: added an alternative 'makeDetection' function. Updated makefile. Now 'make all' builds both the library and the test programs.
- v0.1.3: added 'detectvid' program. It performs detection on video sequences (e.g. avi). Use 'make test3' to generate it. Use 'make alltests' to generate all test programs.
- v0.1.2: small fixes in code.
- v0.1.1: added 'detectobj' program. It can save detections to disk. Use 'make test2' to generate it.
- v0.1: first release.

2 changes: 2 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ URL: http://people.cs.uchicago.edu/~pff/latent/

Version history:
================
- v0.2.9: moving CvMat to cv::Mat
- v0.2.8: new class Detection
- v0.2.7: memory leaks found by github/yokox solved. Thanks!
- v0.2.6: new file 'export.h' for properly exporting functions to dll's.
- v0.2.5: updated CMake files and other minor improvements for Windows compatibility.
Expand Down
4 changes: 4 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
+ Some memory leaks still to be fixed:
- Possible ones: Model, Cell
+ Add a new method to load object models from XML file. This requires a M-script to create such XML model files.
+ Convert CvMat * variables to cv::Mat class.
16 changes: 16 additions & 0 deletions doc/quickstart.tex
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ \section{Easy detection with LibPaBOD}

\noindent So easy!

\section{Using the OpenCV C++ interface}

\begin{verbatim}
LDetections detections;
cv::Mat img = cv::imread("my_image.jpg", CV_LOAD_IMAGE_COLOR);
Pabod detector("data/models/person_v6.mat");
detector.detect(img, POSITIVE_INF, 0.5, detections);
detector.drawDetections(img, detections);
cv::imwrite("my_image_dets.jpg", img);
\end{verbatim}

\begin{thebibliography}{}
\bibitem{felzenszwalb2010}
P. Felzenszwalb, R. Girshick, D. McAllester, D. Ramanan. ``Object Detection with Discriminatively Trained Part Based Models''. IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 32, No. 9, September 2010.
Expand Down
65 changes: 50 additions & 15 deletions include/cell.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
#ifndef _CELL_H_
#define _CELL_H_

#include <vector>
#include <readTypes.h>
#include <handlerOpenCVStructs.h>


/** \file
* This file contains the definition of Model class. This class is used to
* load a the model structure stored on a .mat file.
*/

/** \file
* This file contains the definition of <tt>Cell</tt> class. This class is
* an auxiliar part of class <tt>Model</tt>, and is used to load the
* field <tt>rules</tt> of .mat model file
*/


/** \def INVALID_STR
* This define is used to indicate a structure is invalid, which means their
* fields are not considered.
Expand Down Expand Up @@ -54,6 +49,12 @@ typedef struct offset
{
float w;
int blocklabel;

offset()
{
w = 0.0;
blocklabel = 0;
}
} offset;


Expand All @@ -70,6 +71,12 @@ typedef struct anchor
{
int* array;
int dim;

anchor()
{
dim = 0;
array = NULL;
}
} anchor;


Expand All @@ -88,6 +95,16 @@ typedef struct def
int blocklabel;
bool flip;
char symmetric;

//! Constructor
def()
{
w[0]=w[1]=w[2]=w[3] = 0.0;
blocklabel = 0;
flip = false;
symmetric = '\0';
}

} def;


Expand Down Expand Up @@ -152,6 +169,10 @@ class Cell
*/
void destroyCell ();

void releaseScore(void);
void releaseIxIy(void);



///////////////////////////////
///// LOAD FILE FUNCTIONS /////
Expand Down Expand Up @@ -474,15 +495,17 @@ class Cell
* \sa _score
* \sa _scoreDim
*/
CvMat** getScore () const {return _score;}
//CvMat** getScore () const {return _score;}
const vectorMat & getScore () const {return _score;}


/** Set the value of private variable <tt>_score</tt> to <tt>score</tt>.
* \param score - new array of matrixes for the variable <tt>_score</tt>
* \sa _score
* \sa _scoreDim
*/
void setScore (CvMat **score);
//void setScore (CvMat **score);
void setScore (vectorMat & score);


/** Returns the value of private variable <tt>_scoreDim</tt>
Expand Down Expand Up @@ -510,16 +533,23 @@ class Cell
* \sa _Ix
* \sa _IxDim
*/
CvMat** getIx () const {return _Ix;}
//CvMat** getIx () const {return _Ix;}
const vectorMat & getIx () const {return _Ix;}


/** Set the value of private variable <tt>_Ix</tt> to <tt>Ix</tt>.
* \param Ix - new array of matrixes for the variable <tt>_Ix</tt>
* \sa _Ix
* \sa _IxDim
*/
void setIx (CvMat **Ix);
//void setIx (CvMat **Ix);
void setIx (vectorMat &Ix);

void addIxItem(cv::Mat &Ix){_Ix.push_back(Ix);};
void addIyItem(cv::Mat &Iy){_Iy.push_back(Iy);};

void addIxItem(CvMat * Ix){_Ix.push_back(Ix);};
void addIyItem(CvMat * Iy){_Iy.push_back(Iy);};

/** Returns the value of private variable <tt>_IxDim</tt>
* \return The int value <tt>_IxDim</tt>, which indicates <tt>_Ix</tt>
Expand Down Expand Up @@ -547,15 +577,17 @@ class Cell
* \sa _Iy
* \sa _IyDim
*/
CvMat** getIy () const {return _Iy;}
//CvMat** getIy () const {return _Iy;}
const vectorMat & getIy () const {return _Iy;}


/** Set the value of private variable <tt>_Iy</tt> to <tt>Iy</tt>.
* \param Iy - new array of matrixes for the variable <tt>_Iy</tt>
* \sa _Iy
* \sa _IyDim
*/
void setIy (CvMat **Iy);
//void setIy (CvMat **Iy);
void setIy (vectorMat & Iy);


/** Returns the value of private variable <tt>_IyDim</tt>
Expand Down Expand Up @@ -686,7 +718,8 @@ class Cell
/** Is a CvMat* array private variable.
* \sa _scoreDim
*/
CvMat** _score;
//CvMat** _score;
vectorMat _score;


/** Is an int private variable. Indicates the size of
Expand All @@ -699,7 +732,8 @@ class Cell
/** Is a CvMat* array private variable.
* \sa _IxDim
*/
CvMat** _Ix;
//CvMat** _Ix;
vectorMat _Ix;


/** Is an int private variable. Indicates the size of
Expand All @@ -712,7 +746,8 @@ class Cell
/** Is a CvMat* array private variable.
* \sa _IyDim
*/
CvMat** _Iy;
//CvMat** _Iy;
vectorMat _Iy;


/** Is an int private variable. Indicates the size of
Expand Down
Loading

0 comments on commit 194740a

Please sign in to comment.