Coder Social home page Coder Social logo

car_detection_counting's Introduction

car_detection_counting

车辆检测与车流量统计

An algorithm for car detection and counting, which is based on frame difference. Demo video can be found here

here

Requirement

  • C++
  • OpenCV3.0

Usage

The path of video can be set in "test.cpp".

capture.open("E:\traffic\苏交科视频\无人机\无人机2\视频\9.MP4");

Also, the number and position of counting lines can be set in "test.cpp".

//line1
pair<double, double> downOutStart(0.43, 0.75);
pair<double, double> downOutEnd(0.455, 0.75);
crossingLineStart.push_back(downOutStart);
crossingLineEnd.push_back(downOutEnd);
crossingLineColor.push_back(Scalar(rand() % 255, rand() % 255, rand() & 255));

Debug, show intermediate result, save result.

#define SHOW_FLAG true
#define DEBUG_BY_STEP false
#define SAVE_VIDEO false

Adjust parameters to handle videos with different view, resolution. The parameters can be set in "Blob.h".

const int minBlobArea = 100;                     // min area of an object
const int maxBlobArea = 10000;                   // max area of an object
const int minBlobWidth = 10;                     // min width
const int maxBlobWidth = 150;                    // max width
const int minBlobheight = 10;                    // min height
const int maxBlobheight = 150;                   // max height
const int minBlobDiagonal = 10;                  // min diagonal
const int maxBlobDiagonal = 150;                 // max diagonal
const int maxBlobNum = 500;        // max number of objects in a frame, if a frame contains too many objeects, it may be a noisy frame
const double minBlobRatio = 0.2;                 // min ratio of width and height
const double maxBlobRatio = 4;                   // max ratio of width and height
// bounding coefficient is used to get ROI. Objects which are not in ROI will not be detected. For example, if leftBoundingCoefficient = 0.1 and the width of a frame is 1080, then the left bounding of ROI start from 1080 * 0.1 = 108. Default value means ROI is the whole frame.
const double leftBoundingCoefficient = 0;      
const double rightBoundingCoefficient = 1;
const double upBoundingCoefficient = 0;
const double bottomBoundingCoefficient = 1;
const double IOUThreshold = 0.7; 
// resize coefficient is used to resize frame. If resize width coefficient = 0.5 and the width of a frame is 1080, then the width of the frame will be resized to 1080 * 0.5 = 540. Resize to a smaller frame can avoid some noise and increase the speed of our algorithm. Default value means no resize.
const double resizeHeightCoefficient = 1;  
const double resizeWidthCoefficient = 1;

car_detection_counting's People

Contributors

hjptriplebee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

car_detection_counting's Issues

A more detailed readme or explanation of the parameters in blob.h would be appreciated.

Thank you for you kind open source!
When I test my video with your project, I am wondering how to reset these massive parameters in test.cpp and blob.h. Which made a chaos visualization result and wrong counting number in the code test. Could you give me a detailed parameter configure list on how to reset it when testing another video. updating the readme file will be better and be appreciated.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.