Skip to content

Commit cf506b8

Browse files
committed
Out of frame objects removed immediately
1 parent 798e2c0 commit cf506b8

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ project(MTTracking)
44

55
unset(CMAKE_CXX_FLAGS CACHE)
66
unset(CMAKE_CXX_FLAGS_RELEASE CACHE)
7-
unset(CMAKE_CXX_FLAGS_DEBUG CACHE)
7+
# unset(CMAKE_CXX_FLAGS_DEBUG CACHE)
88

99
find_package(OpenMP)
1010
if (OPENMP_FOUND)
@@ -20,8 +20,8 @@ if (CMAKE_COMPILER_IS_GNUCXX)
2020
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -march=native -mtune=native -Wall -DDEBUG" CACHE STRING COMPILE_FLAGS FORCE)
2121
elseif (MSVC)
2222
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /W4 -DGTL_STATIC" CACHE STRING COMPILE_FLAGS FORCE)
23-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /Ox /Ob2 /Oi /Ot /arch:AVX /fp:fast /DNDEBUG" CACHE STRING COMPILE_FLAGS FORCE)
24-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /Od /Ob0 /DDEBUG" CACHE STRING COMPILE_FLAGS FORCE)
23+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /Ox /Ob2 /Oi /Ot /arch:AVX2 /fp:fast /DNDEBUG" CACHE STRING COMPILE_FLAGS FORCE)
24+
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /Od /Ob0 /DDEBUG" CACHE STRING COMPILE_FLAGS FORCE)
2525
endif()
2626

2727
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)

example/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ int main(int argc, char** argv)
3838

3939
cv::CommandLineParser parser(argc, argv, keys);
4040

41-
bool useOCL = parser.get<int>("gpu") ? 1 : 0;
41+
bool useOCL = parser.get<int>("gpu") != 0;
4242
cv::ocl::setUseOpenCL(useOCL);
4343
std::cout << (cv::ocl::useOpenCL() ? "OpenCL is enabled" : "OpenCL not used") << std::endl;
4444

src/Tracker/Ctracker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ void CTracker::UpdateTrackingState(
9999
for (size_t i = 0; i < m_tracks.size();)
100100
{
101101
if (m_tracks[i]->SkippedFrames() > m_settings.m_maximumAllowedSkippedFrames ||
102+
m_tracks[i]->IsOutOfTheFrame() ||
102103
m_tracks[i]->IsStaticTimeout(cvRound(fps * (m_settings.m_maxStaticTime - m_settings.m_minStaticTime))))
103104
{
104105
m_tracks.erase(m_tracks.begin() + i);

src/Tracker/track.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ cv::RotatedRect CTrack::CalcPredictionEllipse(cv::Size_<track_t> minRadius) cons
231231
else
232232
{
233233
rrect.center.y += d.y / 3;
234-
rrect.angle = CV_PI / 2.f;
234+
rrect.angle = static_cast<float>(CV_PI / 2.);
235235
}
236236
}
237237
return rrect;
@@ -419,8 +419,8 @@ void CTrack::RectUpdate(
419419
{
420420
int res = 0;
421421

422-
if (size < 2)
423-
size = 2;
422+
if (size < 1)
423+
size = 0;
424424

425425
if (v < 0)
426426
{
@@ -650,11 +650,11 @@ void CTrack::RectUpdate(
650650
m_predictionRect.center.x += dx;
651651
m_predictionRect.center.y += dy;
652652
#endif
653-
m_outOfTheFrame = (dx != 0) || (dy != 0);
653+
m_outOfTheFrame = (dx != 0) || (dy != 0) || (brect.width < 2) || (brect.height < 2);
654654

655655
m_predictionPoint = m_predictionRect.center;
656656

657-
//std::cout << "brect = " << brect << ", dx = " << dx << ", dy = " << dy << ", m_outOfTheFrame = " << m_outOfTheFrame << ", m_predictionPoint = " << m_predictionPoint << std::endl;
657+
//std::cout << "brect = " << brect << ", dx = " << dx << ", dy = " << dy << ", outOfTheFrame = " << m_outOfTheFrame << ", predictionPoint = " << m_predictionPoint << std::endl;
658658
}
659659

660660
///
@@ -899,5 +899,7 @@ void CTrack::PointUpdate(
899899
return false;
900900
};
901901
auto p = m_predictionPoint;
902-
m_outOfTheFrame = Clamp(p.x, frameSize.width) | Clamp(p.y, frameSize.height);
902+
m_outOfTheFrame = Clamp(p.x, frameSize.width) || Clamp(p.y, frameSize.height) || (m_predictionRect.size.width < 2) || (m_predictionRect.size.height < 2);
903+
904+
//std::cout << "predictionRect = " << m_predictionRect.boundingRect() << ", outOfTheFrame = " << m_outOfTheFrame << ", predictionPoint = " << m_predictionPoint << std::endl;
903905
}

0 commit comments

Comments
 (0)