From a41aac37922acb4baaba6c269e05d38a12c65a81 Mon Sep 17 00:00:00 2001 From: Ivan Pozdnyakov Date: Fri, 22 May 2015 13:55:36 -0400 Subject: [PATCH] update test --- main.cpp | 227 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- main.h | 9 ++- 2 files changed, 226 insertions(+), 10 deletions(-) diff --git a/main.cpp b/main.cpp index 84c2cb2..2eec445 100644 --- a/main.cpp +++ b/main.cpp @@ -1,10 +1,21 @@ -#include "runWrapper.h" +// This demo will show you how the Vista-core-API can be used. It was test code I left for demonstration purposes +// so it hasn't been properely managed in any way. You'll see a lot of unecessary redundancy. +// The absolutely addresses to videos on my local machines directory should be replaced with your own. +// If you are using your own videos then make sure the input params to run are +// properly choosen. Details on what the input params should be are available in the carCounter.h file. -void runACounter(int id){ +#include "main.h" + +// Wrapper methods for creating instances of car counter and calling the run function on them. +// These can be threaded to make multiple instances of carCounters run at the same time. +// Ideally you should make a single wrapper capable of handing multiple params instead of creating +// multiple ones and defining the inputs to run() locally. + +void runACounter1(int id){ char fileName[100] = "Standard_SCU3IU_2014-08-18_0700.002.avi"; char saveImgTo[200] = "C:/Users/Vanya/Desktop/Car/"; char dataBase[200] = "C:/Users/Vanya/Desktop/car_count_db"; - int bufferSize = 30; + int bufferSize = 2; int minObjectSizeDay = 5000; int minObjectSizeNight = 10; int skip = 3; @@ -64,6 +75,208 @@ void runACounter(int id){ DETECT_SHADOWS_ON,SHOW_LAST_CAR_ON,SHOW_BOUNDBOX_ON,SHOW_PREDICTION_ON,SHOW_LATEST_PATHS_ON,SHOW_TRANSIT_LEDGER_ON,SHOW_REGION_MONITORS_ON, SHOW_PATH_OF_CAR_X_OFF,USE_RESIZED_WITH_OVERLAYS_FRAME, startRegion, endRegion); } + +void runACounter2(int id){ + char fileName[100] = "Standard_SCU3IP_2014-10-21_0830.023.mp4"; + char saveImgTo[200] = "C:/Users/Vanya/Desktop/Car/"; + char dataBase[200] = "C:/Users/Vanya/Desktop/car_count_db"; + int bufferSize = 30; + int minObjectSizeDay = 5000; + int minObjectSizeNight = 10; + int skip = 3; + int learningTime = 240; + int fps = 30; + int expectedDist = 20; + int horizontalBandwidth = 100; + int nmixtures = 5; + double backgroundratio = .6; + bool detectShadows = false; + bool online = true; + + cv::Point Sp1(200,250); + cv::Point Sp4(600,250); + cv::Point Sp2(200,300); + cv::Point Sp3(600,300); + + cv::vector startRegion; + startRegion.push_back(Sp1); + startRegion.push_back(Sp2); + startRegion.push_back(Sp3); + startRegion.push_back(Sp4); + + cv::Point Ep1(300,375); + cv::Point Ep4(700,375); + cv::Point Ep2(300,425); + cv::Point Ep3(700,425); + + cv::vector endRegion; + endRegion.push_back(Ep1); + endRegion.push_back(Ep2); + endRegion.push_back(Ep3); + endRegion.push_back(Ep4); + + cv::Point overlay1[1][4]; + overlay1[0][0] = cv::Point( 0, 0 ); + overlay1[0][1] = cv::Point( 0, 480 ); + overlay1[0][2] = cv::Point( 320, 480); + overlay1[0][3] = cv::Point( 30, 0 ); + + const cv::Point* ppt[1] = { overlay1[0] }; + int npt[] = { 4 }; + + cv::Point overlay2[1][4]; + overlay2[0][0] = cv::Point( 40, 0 ); + overlay2[0][1] = cv::Point( 720, 380 ); + overlay2[0][2] = cv::Point( 720, 380 ); + overlay2[0][3] = cv::Point( 720, 0 ); + + + const cv::Point* ppt2[1] = { overlay2[0] }; + int npt2[] = { 4 }; + + carCounter CC(7,true); + CC.run(bufferSize,minObjectSizeDay,minObjectSizeNight,skip,learningTime,fileName,saveImgTo,dataBase,fps,expectedDist,horizontalBandwidth,RUN_ONLINE, + *ppt,*ppt2,npt,npt2, + USE_MOG2_ON,nmixtures,backgroundratio, + DETECT_SHADOWS_ON,SHOW_LAST_CAR_ON,SHOW_BOUNDBOX_ON,SHOW_PREDICTION_ON,SHOW_LATEST_PATHS_ON,SHOW_TRANSIT_LEDGER_ON,SHOW_REGION_MONITORS_ON, + SHOW_PATH_OF_CAR_X_OFF,USE_RESIZED_WITH_OVERLAYS_FRAME, startRegion, endRegion); +} + +void runACounter3(int id){ + char fileName[100] = "Standard_SCU3IP_2014-10-21_0830.010.mp4"; + char saveImgTo[200] = "C:/Users/Vanya/Desktop/Car/"; + char dataBase[200] = "C:/Users/Vanya/Desktop/car_count_db"; + int bufferSize = 30; + int minObjectSizeDay = 5000; + int minObjectSizeNight = 10; + int skip = 3; + int learningTime = 240; + int fps = 30; + int expectedDist = 100; + int horizontalBandwidth = 50; + int nmixtures = 5; + double backgroundratio = .6; + bool detectShadows = false; + bool online = true; + + cv::Point Sp1(200,250); + cv::Point Sp4(600,250); + cv::Point Sp2(200,300); + cv::Point Sp3(600,300); + + cv::vector startRegion; + startRegion.push_back(Sp1); + startRegion.push_back(Sp2); + startRegion.push_back(Sp3); + startRegion.push_back(Sp4); + + cv::Point Ep1(200,325); + cv::Point Ep4(600,325); + cv::Point Ep2(200,375); + cv::Point Ep3(600,375); + + cv::vector endRegion; + endRegion.push_back(Ep1); + endRegion.push_back(Ep2); + endRegion.push_back(Ep3); + endRegion.push_back(Ep4); + + cv::Point overlay1[1][4]; + overlay1[0][0] = cv::Point( 0, 0 ); + overlay1[0][1] = cv::Point( 0, 480 ); + overlay1[0][2] = cv::Point( 320, 480); + overlay1[0][3] = cv::Point( 30, 0 ); + + + const cv::Point* ppt[1] = { overlay1[0] }; + int npt[] = { 4 }; + + cv::Point overlay2[1][4]; + overlay2[0][0] = cv::Point( 40, 0 ); + overlay2[0][1] = cv::Point( 720, 400 ); + overlay2[0][2] = cv::Point( 720, 400 ); + overlay2[0][3] = cv::Point( 720, 0 ); + + + const cv::Point* ppt2[1] = { overlay2[0] }; + int npt2[] = { 4 }; + + carCounter CC(6,false); + CC.run(bufferSize,minObjectSizeDay,minObjectSizeNight,skip,learningTime,fileName,saveImgTo,dataBase,fps,expectedDist,horizontalBandwidth,RUN_ONLINE, + *ppt,*ppt2,npt,npt2, + USE_MOG2_ON,nmixtures,backgroundratio, + DETECT_SHADOWS_ON,SHOW_LAST_CAR_ON,SHOW_BOUNDBOX_ON,SHOW_PREDICTION_ON,SHOW_LATEST_PATHS_ON,SHOW_TRANSIT_LEDGER_ON,SHOW_REGION_MONITORS_ON, + SHOW_PATH_OF_CAR_X_OFF,USE_RESIZED_WITH_OVERLAYS_FRAME, startRegion, endRegion); +} + +void runACounter4(int id){ + char fileName[100] = "Standard_SCU3IS_2014-10-21_0930.012.mp4"; + char saveImgTo[200] = "C:/Users/Vanya/Desktop/Car/"; + char dataBase[200] = "C:/Users/Vanya/Desktop/car_count_db"; + int bufferSize = 30; + int minObjectSizeDay = 5000; + int minObjectSizeNight = 10; + int skip = 3; + int learningTime = 240; + int fps = 30; + int expectedDist = 20; + int horizontalBandwidth = 50; + int nmixtures = 5; + double backgroundratio = .6; + bool detectShadows = false; + bool online = true; + + cv::Point Sp1(100,325); + cv::Point Sp4(400,325); + cv::Point Sp2(100,375); + cv::Point Sp3(400,375); + + cv::vector startRegion; + startRegion.push_back(Sp1); + startRegion.push_back(Sp2); + startRegion.push_back(Sp3); + startRegion.push_back(Sp4); + + cv::Point Ep1(100,250); + cv::Point Ep4(400,250); + cv::Point Ep2(100,300); + cv::Point Ep3(400,300); + + cv::vector endRegion; + endRegion.push_back(Ep1); + endRegion.push_back(Ep2); + endRegion.push_back(Ep3); + endRegion.push_back(Ep4); + + cv::Point overlay1[1][4]; + overlay1[0][0] = cv::Point( 0, 0 ); + overlay1[0][1] = cv::Point( 0, 480 ); + overlay1[0][2] = cv::Point( 0, 480); + overlay1[0][3] = cv::Point( 370, 0 ); + + + const cv::Point* ppt[1] = { overlay1[0] }; + int npt[] = { 4 }; + + cv::Point overlay2[1][4]; + overlay2[0][0] = cv::Point( 410, 0 ); + overlay2[0][1] = cv::Point( 480, 480 ); + overlay2[0][2] = cv::Point( 720, 480 ); + overlay2[0][3] = cv::Point( 720, 0 ); + + + const cv::Point* ppt2[1] = { overlay2[0] }; + int npt2[] = { 4 }; + + carCounter CC(8,true); + CC.run(bufferSize,minObjectSizeDay,minObjectSizeNight,skip,learningTime,fileName,saveImgTo,dataBase,fps,expectedDist,horizontalBandwidth,RUN_ONLINE, + *ppt,*ppt2,npt,npt2, + USE_MOG2_ON,nmixtures,backgroundratio, + DETECT_SHADOWS_ON,SHOW_LAST_CAR_ON,SHOW_BOUNDBOX_ON,SHOW_PREDICTION_ON,SHOW_LATEST_PATHS_ON,SHOW_TRANSIT_LEDGER_ON,SHOW_REGION_MONITORS_ON, + SHOW_PATH_OF_CAR_X_OFF,USE_RESIZED_WITH_OVERLAYS_FRAME, startRegion, endRegion); +} + + int main() { using namespace cv; @@ -94,10 +307,10 @@ int main() // TEST1: Day Time/Going away from camera/Multithreaded if(runTest == 1) { - std::thread thread1(runACounter,1); - std::thread thread2(runACounter,2); - std::thread thread3(runACounter,3); - std::thread thread4(runACounter,4); + std::thread thread1(runACounter1,1); + std::thread thread2(runACounter2,2); + std::thread thread3(runACounter3,3); + std::thread thread4(runACounter4,4); thread1.detach(); thread2.detach(); thread3.detach(); diff --git a/main.h b/main.h index d86dbb4..e98eb3a 100644 --- a/main.h +++ b/main.h @@ -1,9 +1,12 @@ -#ifndef RUNWRAPPER_H -#define RUNWRAPPER_H +#ifndef MAIN_H +#define MAIN_H #include "carCounter.h" -void runACounter(int id); +void runACounter1(int id); +void runACounter2(int id); +void runACounter3(int id); +void runACounter4(int id); int runWrapper(); #endif \ No newline at end of file