Skip to content

Commit 5ebafb5

Browse files
authored
Merge pull request #504 from Nuzhny007/master
Portion of fixes
2 parents 6698a93 + b1eadff commit 5ebafb5

32 files changed

Lines changed: 783 additions & 738 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ endif(SILENT_WORK)
4444
include(CheckIncludeFileCXX)
4545
check_include_file_cxx(filesystem HAVE_FILESYSTEM)
4646
if(HAVE_FILESYSTEM)
47-
add_definitions(-DHAVE_FILESYSTEM)
4847
message("Founded filesystem header")
4948
else(HAVE_FILESYSTEM)
49+
add_definitions(-DHAVE_EXPERIMENTAL_FILESYSTEM)
5050
message("Do not found filesystem header")
5151
endif(HAVE_FILESYSTEM)
5252

async_detector/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set(HEADERS AsyncDetector.h
1212
# добавляем include директории
1313
# ----------------------------------------------------------------------------
1414
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/../src
15-
${PROJECT_SOURCE_DIR}/../src/common
15+
${PROJECT_SOURCE_DIR}/../src/mtracking
1616
${PROJECT_SOURCE_DIR}/../src/Detector
1717
${PROJECT_SOURCE_DIR}/../src/Detector/vibe_src
1818
${PROJECT_SOURCE_DIR}/../src/Detector/Subsense

example/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ endif(BUILD_CARS_COUNTING)
2020
# добавляем include директории
2121
# ----------------------------------------------------------------------------
2222
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/../src
23-
${PROJECT_SOURCE_DIR}/../src/common
23+
${PROJECT_SOURCE_DIR}/../src/mtracking
2424
${PROJECT_SOURCE_DIR}/../src/Detector
2525
${PROJECT_SOURCE_DIR}/../src/Detector/vibe_src
2626
${PROJECT_SOURCE_DIR}/../src/Detector/Subsense

example/MotionDetectorExample.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class MotionDetectorExample final : public VideoExample
3939
m_logger->info("MotionDetectorExample::InitDetector");
4040

4141
//m_minObjWidth = frame.cols / 20;
42-
m_minObjWidth = 2;
42+
m_minObjWidth = 4;
4343

4444
config_t config;
4545
config.emplace("useRotatedRect", "0");
@@ -56,7 +56,7 @@ class MotionDetectorExample final : public VideoExample
5656
config.emplace("updateFactor", "16");
5757
break;
5858
case tracking::Detectors::Motion_MOG:
59-
config.emplace("history", std::to_string(cvRound(50 * m_fps)));
59+
config.emplace("history", std::to_string(cvRound(5000 * m_fps)));
6060
config.emplace("nmixtures", "3");
6161
config.emplace("backgroundRatio", "0.7");
6262
config.emplace("noiseSigma", "0");
@@ -97,7 +97,7 @@ class MotionDetectorExample final : public VideoExample
9797

9898
if (!m_trackerSettingsLoaded)
9999
{
100-
m_trackerSettings.SetDistance(tracking::DistCenters);
100+
m_trackerSettings.SetDistance(tracking::DistJaccard);
101101
m_trackerSettings.m_kalmanType = tracking::KalmanLinear;
102102
m_trackerSettings.m_filterGoal = tracking::FilterCenter;
103103
m_trackerSettings.m_lostTrackType = tracking::TrackNone; // Use visual objects tracker for collisions resolving. Used if m_filterGoal == tracking::FilterRect
@@ -197,8 +197,9 @@ class MotionDetectorExample final : public VideoExample
197197
auto velocity = sqrt(sqr(track.m_velocity[0]) + sqr(track.m_velocity[1]));
198198
if (track.IsRobust(4, // Minimal trajectory size
199199
0.3f, // Minimal ratio raw_trajectory_points / trajectory_lenght
200-
cv::Size2f(0.2f, 5.0f))) // Min and max ratio: width / height
201-
//velocity > 30 // Velocity more than 30 pixels per second
200+
cv::Size2f(0.2f, 5.0f), // Min and max ratio: width / height
201+
2))
202+
//velocity > 30 // Velocity more than 30 pixels per second
202203
{
203204
//track_t mean = 0;
204205
//track_t stddev = 0;

example/VideoExample.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,14 @@ void VideoExample::SyncProcess()
153153

154154
int64 startLoopTime = cv::getTickCount();
155155

156+
//double fps = capture.get(cv::CAP_PROP_FPS);
157+
//double readPeriodSeconds = 2.;
158+
//int readPeriodFrames = cvRound(readPeriodSeconds * fps);
159+
156160
for (;;)
157161
{
162+
//int currFramesPos = cvRound(capture.get(cv::CAP_PROP_POS_FRAMES));
163+
158164
size_t i = 0;
159165
for (; i < m_batchSize; ++i)
160166
{
@@ -177,6 +183,8 @@ void VideoExample::SyncProcess()
177183
if (i < m_batchSize)
178184
break;
179185

186+
//capture.set(cv::CAP_PROP_POS_FRAMES, currFramesPos + readPeriodFrames);
187+
180188
if (!m_isDetectorInitialized || !m_isTrackerInitialized)
181189
{
182190
cv::UMat ufirst = frameInfo.m_frames[0].GetUMatBGR();
@@ -202,7 +210,6 @@ void VideoExample::SyncProcess()
202210

203211
int64 t1 = cv::getTickCount();
204212

205-
regions_t regions;
206213
Detection(frameInfo);
207214
Tracking(frameInfo);
208215
int64 t2 = cv::getTickCount();

example/VideoExample.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@ class VideoExample
281281
bool m_isDetectorInitialized = false;
282282
std::string m_inFile;
283283
std::string m_outFile;
284-
int m_fourcc = cv::VideoWriter::fourcc('h', '2', '6', '4'); //cv::VideoWriter::fourcc('M', 'J', 'P', 'G');
284+
#if 0
285+
int m_fourcc = cv::VideoWriter::fourcc('h', '2', '6', '4');
286+
#else
287+
int m_fourcc = cv::VideoWriter::fourcc('M', 'J', 'P', 'G');
288+
#endif
285289
int m_startFrame = 0;
286290
int m_endFrame = 0;
287291
int m_finishDelay = 0;

example/main.cpp

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,39 @@
99
#include <opencv2/opencv.hpp>
1010
#include <opencv2/core/ocl.hpp>
1111

12-
// ----------------------------------------------------------------------
13-
14-
static void Help()
15-
{
16-
printf("\nExamples of the Multitarget tracking algorithm\n"
17-
"Usage: \n"
18-
" ./MultitargetTracker <path to movie file> [--example]=<number of example 0..7> [--start_frame]=<start a video from this position> [--end_frame]=<play a video to this position> [--end_delay]=<delay in milliseconds after video ending> [--out]=<name of result video file> [--show_logs]=<show logs> [--async]=<async pipeline> [--res]=<csv log file> [--settings]=<ini file> [--batch_size=<number of frames>] \n\n"
19-
"Press:\n"
20-
"\'m\' key for change mode: play|pause. When video is paused you can press any key for get next frame. \n\n"
21-
"Press Esc to exit from video \n\n"
22-
);
23-
}
24-
25-
const char* keys =
26-
{
27-
"{ @1 |../data/atrium.avi | movie file | }"
28-
"{ e example |1 | number of example 0 - MouseTracking, 1 - MotionDetector, 3 - YOLO TensorRT Detector, 4 - Cars counting | }"
29-
"{ sf start_frame |0 | Start a video from this position | }"
30-
"{ ef end_frame |0 | Play a video to this position (if 0 then played to the end of file) | }"
31-
"{ ed end_delay |0 | Delay in milliseconds after video ending | }"
32-
"{ o out | | Name of result video file | }"
33-
"{ show_logs |info | Show Trackers logs: trace, debug, info, warning, error, critical, off | }"
34-
"{ g gpu |0 | Use OpenCL acceleration | }"
35-
"{ a async |1 | Use 2 theads for processing pipeline | }"
36-
"{ r log_res | | Path to the csv file with tracking result | }"
37-
"{ cvat_res | | Path to the xml file in cvat format with tracking result | }"
38-
"{ s settings | | Path to the ini file with tracking settings | }"
39-
"{ bs batch_size |1 | Batch size - frames count for processing | }"
40-
"{ wf write_n_frame |1 | Write logs on each N frame: 1 for writing each frame | }"
41-
"{ hm heat_map |0 | For CarsCounting: Draw heat map | }"
42-
"{ geo_bind |geo_bind.ini | For CarsCounting: ini file with geographical binding | }"
43-
"{ contrast_adjustment |0 | Use contrast adjustment for frames before detection | }"
44-
};
45-
46-
// ----------------------------------------------------------------------
47-
12+
///----------------------------------------------------------------------
4813
int main(int argc, char** argv)
4914
{
15+
const char* keys =
16+
{
17+
"{ @1 |../data/atrium.avi | movie file | }"
18+
"{ e example |1 | number of example 0 - MouseTracking, 1 - MotionDetector, 3 - YOLO TensorRT Detector, 4 - Cars counting | }"
19+
"{ sf start_frame |0 | Start a video from this position | }"
20+
"{ ef end_frame |0 | Play a video to this position (if 0 then played to the end of file) | }"
21+
"{ ed end_delay |0 | Delay in milliseconds after video ending | }"
22+
"{ o out | | Name of result video file | }"
23+
"{ show_logs |info | Show Trackers logs: trace, debug, info, warning, error, critical, off | }"
24+
"{ g gpu |0 | Use OpenCL acceleration | }"
25+
"{ a async |1 | Use 2 theads for processing pipeline | }"
26+
"{ r log_res | | Path to the csv file with tracking result | }"
27+
"{ cvat_res | | Path to the xml file in cvat format with tracking result | }"
28+
"{ s settings | | Path to the ini file with tracking settings | }"
29+
"{ bs batch_size |1 | Batch size - frames count for processing | }"
30+
"{ wf write_n_frame |1 | Write logs on each N frame: 1 for writing each frame | }"
31+
"{ hm heat_map |0 | For CarsCounting: Draw heat map | }"
32+
"{ geo_bind |geo_bind.ini | For CarsCounting: ini file with geographical binding | }"
33+
"{ contrast_adjustment |0 | Use contrast adjustment for frames before detection | }"
34+
};
35+
5036
cv::CommandLineParser parser(argc, argv, keys);
5137

52-
Help();
38+
std::cout << "\nExamples of the Multitarget tracking algorithm\n"
39+
"Usage: \n"
40+
" ./MultitargetTracker <path to movie file> [--example]=<number of example 0..7> [--start_frame]=<start a video from this position> [--end_frame]=<play a video to this position> [--end_delay]=<delay in milliseconds after video ending> [--out]=<name of result video file> [--show_logs]=<show logs> [--async]=<async pipeline> [--res]=<csv log file> [--settings]=<ini file> [--batch_size=<number of frames>] \n\n"
41+
"Press:\n"
42+
"\'m\' key for change mode: play|pause. When video is paused you can press any key for get next frame. \n\n"
43+
"Press Esc to exit from video \n" << std::endl;
44+
5345
parser.printMessage();
5446

5547
bool useOCL = parser.get<int>("gpu") != 0;

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ else()
2323
set(LIB_PTHREAD pthread)
2424
endif()
2525

26-
include_directories(common)
26+
include_directories(mtracking)
2727

2828
pybind11_add_module(pymtracking ${mtracker_python_src} ${mtracker_python_inc})
2929
target_link_libraries(pymtracking PRIVATE mtracking mdetection ${OpenCV_LIBS} ${PYTHON_LIBRARY} pybind11::module)

src/Detector/BackgroundSubtract.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "defines.h"
3+
#include "mtracking/defines.h"
44
#include "vibe_src/vibe.hpp"
55

66
#ifdef USE_OCV_BGFG

src/Detector/BaseDetector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include <memory>
4-
#include "defines.h"
4+
#include "mtracking/defines.h"
55

66
///
77
/// \brief The KeyVal struct

0 commit comments

Comments
 (0)