simple_vehicle_counting-master
所属分类:OpenCV
开发工具:Visual C++
文件大小:17952KB
下载次数:43
上传日期:2016-01-18 10:25:03
上 传 者:
ichchenfeng
说明: 基于opencv的车辆数量计数器,Visual C++,完整的程序代码
(a simple_vehicle_counting-master based on Opencv)
文件列表:
CMakeLists.txt (2136, 2015-09-18)
Demo.cpp (1721, 2015-09-18)
build (0, 2015-09-18)
build\FOR_LINUX_USERS (3, 2015-09-18)
config (0, 2015-09-18)
config\BlobTracking.xml (215, 2015-09-18)
config\PixelBasedAdaptiveSegmenter.xml (437, 2015-09-18)
config\VehicleCouting.xml (296, 2015-09-18)
dataset (0, 2015-09-18)
dataset\video.avi (1049784, 2015-09-18)
include (0, 2015-09-18)
include\opencv (0, 2015-09-18)
include\opencv\cv.h (3438, 2015-09-18)
include\opencv\cv.hpp (2411, 2015-09-18)
include\opencv\cvaux.h (2850, 2015-09-18)
include\opencv\cvaux.hpp (2346, 2015-09-18)
include\opencv\cvwimage.h (2184, 2015-09-18)
include\opencv\cxcore.h (2465, 2015-09-18)
include\opencv\cxcore.hpp (2423, 2015-09-18)
include\opencv\cxeigen.hpp (2265, 2015-09-18)
include\opencv\cxmisc.h (110, 2015-09-18)
include\opencv\highgui.h (2306, 2015-09-18)
include\opencv\ml.h (2189, 2015-09-18)
include\opencv2 (0, 2015-09-18)
include\opencv2\calib3d (0, 2015-09-18)
include\opencv2\calib3d\calib3d.hpp (41241, 2015-09-18)
include\opencv2\contrib (0, 2015-09-18)
include\opencv2\contrib\contrib.hpp (38786, 2015-09-18)
include\opencv2\contrib\detection_based_tracker.hpp (3042, 2015-09-18)
include\opencv2\contrib\hybridtracker.hpp (7099, 2015-09-18)
include\opencv2\contrib\openfabmap.hpp (12807, 2015-09-18)
include\opencv2\contrib\retina.hpp (23958, 2015-09-18)
include\opencv2\core (0, 2015-09-18)
include\opencv2\core\affine.hpp (15428, 2015-09-18)
include\opencv2\core\core.hpp (186571, 2015-09-18)
include\opencv2\core\core_c.h (78509, 2015-09-18)
... ...
Vehicle Detection, Tracking and Counting
========================================
Last page update: **30/04/2015**
Last version: **1.0.0** (see Release Notes for more info)
Hi everyone,
There are several ways to perform vehicle detection, tracking and counting.
Here is a step-by-step of a simplest way to do this:
1. First, you will need to detect the moving objects. An easy way to do vehicle detection is by using a Background Subtraction (BS) algorithm. You can try to use a background subtraction library like [BGSLibrary](https://github.com/andrewssobral/bgslibrary#bgslibrary).
2. For vehicle tracking, you will need to use a tracking algorithm. A simplest way to do this is by using a blob tracker algorithm (see [cvBlob](https://code.google.com/p/cvblob/) or [OpenCVBlobsLib](http://opencvblobslib.github.io/opencvblobslib/)). So, send the foreground mask to **cvBlob** or **OpenCVBlobsLib**. For example, the **cvBlob** library provide some methods to get the **centroid**, the **track** and the **ID** of the moving objects. You can also set to draw a **bounding box**, the **centroid** and the **angle** of the tracked object.
3. And then, check if the **centroid** of the moving object has crossed a **region of interest** (i.e. virtual line) in your video.
4. Voil! enjoy it :)
Additional informations:
* There is a Visual Studio 2013 template project in the **vs2013/** folder. Open it in the Visual Studio IDE and select [Release]-[Win32] mode.
* The include files for the OpenCV 2.4.10 are provided in the **include/** folder, and the related static libraries are provided in the **lib/x86/vc12** folder.
Example code
------------
```C++
#include
#include
#include
#include "package_bgs/PBAS/PixelBasedAdaptiveSegmenter.h"
#include "package_tracking/BlobTracking.h"
#include "package_analysis/VehicleCouting.h"
int main(int argc, char **argv)
{
/* Open video file */
CvCapture *capture = 0;
capture = cvCaptureFromAVI("dataset/video.avi");
if(!capture){
std::cerr << "Cannot open video!" << std::endl;
return 1;
}
/* Background Subtraction Algorithm */
IBGS *bgs;
bgs = new PixelBasedAdaptiveSegmenter;
/* Blob Tracking Algorithm */
cv::Mat img_blob;
BlobTracking* blobTracking;
blobTracking = new BlobTracking;
/* Vehicle Counting Algorithm */
VehicleCouting* vehicleCouting;
vehicleCouting = new VehicleCouting;
std::cout << "Press 'q' to quit..." << std::endl;
int key = 0;
IplImage *frame;
while(key != 'q')
{
frame = cvQueryFrame(capture);
if(!frame) break;
cv::Mat img_input(frame);
cv::imshow("Input", img_input);
// bgs->process(...) internally process and show the foreground mask image
cv::Mat img_mask;
bgs->process(img_input, img_mask);
if(!img_mask.empty())
{
// Perform blob tracking
blobTracking->process(img_input, img_mask, img_blob);
// Perform vehicle counting
vehicleCouting->setInput(img_blob);
vehicleCouting->setTracks(blobTracking->getTracks());
vehicleCouting->process();
}
key = cvWaitKey(1);
}
delete vehicleCouting;
delete blobTracking;
delete bgs;
cvDestroyAllWindows();
cvReleaseCapture(&capture);
return 0;
}
```
Release Notes:
--------------
* Version 1.0.0:
First version.
近期下载者:
相关文件:
收藏者: