Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update comments & switch main files
  • Loading branch information
Ivan Pozdnyakov authored and Ivan Pozdnyakov committed May 22, 2015
1 parent cd9734f commit 5689ea3
Show file tree
Hide file tree
Showing 6 changed files with 825 additions and 20 deletions.
7 changes: 7 additions & 0 deletions AdaptiveMedianBGS.cpp
Expand Up @@ -27,6 +27,13 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/

/* Modified by Ivan Pozdnyakov
*
* The code modification makes sure that pixels belonging to the background model
* never update as long as they are in the background model.
*
*/

#include <iostream>
#include <stdlib.h>
#include <cmath>
Expand Down
9 changes: 9 additions & 0 deletions DPAdaptiveMedianBGS.cpp
Expand Up @@ -14,6 +14,15 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*/

/* Modified by Ivan Pozdnyakov
*
* The code modification makes sure the background model is saved in img_bgmodel and is useable
* by the caller of process. Also the expected location of DPAdaptiveMedianBGS.xml has been changed
* to be the local directory instead of BGS library folder.
*
*/

#include "DPAdaptiveMedianBGS.h"

DPAdaptiveMedianBGS::DPAdaptiveMedianBGS() : firstTime(true), frameNumber(0), threshold(40), samplingRate(7), learningFrames(30), showOutput(true)
Expand Down
9 changes: 9 additions & 0 deletions FrameDifferenceBGS.cpp
Expand Up @@ -14,6 +14,15 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*/

/* Modified by Ivan Pozdnyakov
*
* The code modification makes sure the background model is saved in img_bgmodel and is useable
* by the caller of process. Also the expected location of FrameDifferenceBGS.xml has been changed
* to be the local directory instead of BGS library folder.
*
*/

#include "FrameDifferenceBGS.h"

FrameDifferenceBGS::FrameDifferenceBGS() : firstTime(true), enableThreshold(true), threshold(15), showOutput(true)
Expand Down
32 changes: 19 additions & 13 deletions carCounter.h
Expand Up @@ -35,14 +35,13 @@
#include <ctime>
#include <thread>
#include <limits>
#include <vector>
#include <queue>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>

#include <vector>
#include <queue>

#include "sqlite3.h"
#include "DPAdaptiveMedianBGS.h"
#include "FrameDifferenceBGS.h"
Expand Down Expand Up @@ -147,12 +146,15 @@ struct Object
* carCounter will keep table data updated as the algorithm
* runs.
*
* note: Anything marked with (*) is specific to night time mode only.
*
* while(true)
* - obtainframe < (opencv)
* - obtainBoundBoxes
* - createFrame
* - threshold < (opencv)
* - selectBackgroundSubtraction
* - MOG2 < (opencv) || - Adaptive Median < (BGS) || - FrameDifference < (BGS)
* - MOG2 < (opencv) || - Adaptive Median < (BGS) || - (*) FrameDifference < (BGS)
* - dilate < (opencv)
* - erode < (opencv)
* - medianblur < (opencv)
Expand All @@ -170,6 +172,7 @@ struct Object
* - histogramClacAndFindStd
* - calcHistogram
* - findStd
* - (*) detectCarBoxForNight
* - drawResult
*
*/
Expand Down Expand Up @@ -316,7 +319,7 @@ private:
cv::vector<cv::Point> endRegion);
/* Custom Utility */

int carCounter::obtainBoundBoxes(cv::vector<cv::vector<cv::Point>> &contours,cv::vector<cv::vector<cv::Point>> &contours_poly,
int obtainBoundBoxes(cv::vector<cv::vector<cv::Point>> &contours,cv::vector<cv::vector<cv::Point>> &contours_poly,
cv::vector<cv::Rect> &boundRect,
cv::vector<cv::Point2f> &center,cv::vector<float> &radius, int minObjectSize);

Expand All @@ -338,26 +341,29 @@ public:
carCounter(int expID,bool night);

/* Start the counter
* NAME: :DESCRIPTION :UNITS (IF APPLICABLE)
* bufferSize: Local workspace (how many of the latest frames of the video to store)
* minObjectSizeDay: Minimum required size for an object to be considered (ignore things that are too small to be a car)
* minObjectSizeNight: Minimum required size for an object to be considered (ignore things that are too small to be a headlight)
* skip: Skips frames from video (potential performance improvement)
* learningTime: Give time for BGS to settle
* minObjectSizeDay: Minimum required size for an object to be considered (ignore things that are too small to be a car) Pixels Squared
(*) minObjectSizeNight: Minimum required size for an object to be considered (ignore things that are too small to be a headlight) Pixels Squared
* skip: Skips frames from video (potential performance improvement) Frames
* learningTime: Give time for BGS to settle Frames
* fileName: Video filename that you want run the algorithm on.
* saveImgTo: Directory in which cropped images of counted cars will be saved.
* dataBase The local sqlite database to which you want to save data. (absolute location)
* fps: Ignore this for now (set the frames per second of this video. Can be used to track how many seconds into the video the car is detect)
* expectedDist: Tells the algorithm the threshold on how far along in pixels the object will be next frame.
* horizontalBandWidth: If looking for a sibling headlight object this tells the algorithm how wide the search area band should be horizontally.
* fps: Ignore this for now (set the frames per second of this video. Can be used to track how many seconds into the video the car is detect) Frames/second
* expectedDist: Tells the algorithm the threshold on how far along in pixels the object will be next frame. Pixels
* horizontalBandWidth: If looking for a sibling headlight object this tells the algorithm how wide the search area band should be horizontally. Pixels
* online: Whether to display frames
* ppt,ppt2,npt,npt2: Set an overlay mask on the video (optional)
* useMOG2: Choose between MOG2 or Adaptive Median for background subtraction
(Adaptive median is more primitive but is able to handle stationary objects).
Check MOG2 for details.
* startRegion: Set points for start Region.
* endRegion: Set points for end Region.
Other parameters are settings for displaying if online mode is chosen.
*
* note: Anything marked with (*) is specific to night time mode only.
*/
void run(int bufferSize, int minObjectSizeDay, int minObjectSizeNight, int skip, int learningTime,
char fileName[100], char saveImgTo[200], char dataBase[200],
Expand Down

0 comments on commit 5689ea3

Please sign in to comment.