Skip to content

Commit d1be3d0

Browse files
committed
Cars counting to examples
1 parent 3e7213d commit d1be3d0

14 files changed

Lines changed: 398 additions & 685 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ endif(BUILD_EXAMPLES)
5656

5757
option(BUILD_CARS_COUNTING "Should compiled Cars counting example?" OFF)
5858
if (BUILD_CARS_COUNTING)
59-
add_subdirectory(cars_counting)
59+
add_definitions(-DBUILD_CARS_COUNTING)
6060
endif(BUILD_CARS_COUNTING)
6161

6262
option(BUILD_ASYNC_DETECTOR "Should compiled async example with low fps Detector?" OFF)

async_detector/AsyncDetector.cpp

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -149,39 +149,28 @@ void AsyncDetector::Process()
149149
///
150150
/// \brief AsyncDetector::DrawTrack
151151
/// \param frame
152-
/// \param resizeCoeff
153152
/// \param track
154153
/// \param drawTrajectory
155154
/// \param isStatic
156155
///
157156
void AsyncDetector::DrawTrack(cv::Mat frame,
158-
int resizeCoeff,
159157
const TrackingObject& track,
160158
bool drawTrajectory)
161159
{
162-
auto ResizeRect = [&](const cv::Rect& r) -> cv::Rect
163-
{
164-
return cv::Rect(resizeCoeff * r.x, resizeCoeff * r.y, resizeCoeff * r.width, resizeCoeff * r.height);
165-
};
166-
auto ResizePoint = [&](const cv::Point& pt) -> cv::Point
167-
{
168-
return cv::Point(resizeCoeff * pt.x, resizeCoeff * pt.y);
169-
};
170-
171160
if (track.m_isStatic)
172161
{
173162
#if (CV_VERSION_MAJOR >= 4)
174-
cv::rectangle(frame, ResizeRect(track.m_rrect.boundingRect()), cv::Scalar(255, 0, 255), 2, cv::LINE_AA);
163+
cv::rectangle(frame, track.m_rrect.boundingRect(), cv::Scalar(255, 0, 255), 2, cv::LINE_AA);
175164
#else
176-
cv::rectangle(frame, ResizeRect(track.m_rrect.boundingRect()), cv::Scalar(255, 0, 255), 2, CV_AA);
165+
cv::rectangle(frame, track.m_rrect.boundingRect(), cv::Scalar(255, 0, 255), 2, CV_AA);
177166
#endif
178167
}
179168
else
180169
{
181170
#if (CV_VERSION_MAJOR >= 4)
182-
cv::rectangle(frame, ResizeRect(track.m_rrect.boundingRect()), cv::Scalar(0, 255, 0), 1, cv::LINE_AA);
171+
cv::rectangle(frame, track.m_rrect.boundingRect(), cv::Scalar(0, 255, 0), 1, cv::LINE_AA);
183172
#else
184-
cv::rectangle(frame, ResizeRect(track.m_rrect.boundingRect()), cv::Scalar(0, 255, 0), 1, CV_AA);
173+
cv::rectangle(frame, track.m_rrect.boundingRect(), cv::Scalar(0, 255, 0), 1, CV_AA);
185174
#endif
186175
}
187176

@@ -194,16 +183,16 @@ void AsyncDetector::DrawTrack(cv::Mat frame,
194183
const TrajectoryPoint& pt1 = track.m_trace.at(j);
195184
const TrajectoryPoint& pt2 = track.m_trace.at(j + 1);
196185
#if (CV_VERSION_MAJOR >= 4)
197-
cv::line(frame, ResizePoint(pt1.m_prediction), ResizePoint(pt2.m_prediction), cl, 1, cv::LINE_AA);
186+
cv::line(frame, pt1.m_prediction, pt2.m_prediction, cl, 1, cv::LINE_AA);
198187
#else
199-
cv::line(frame, ResizePoint(pt1.m_prediction), ResizePoint(pt2.m_prediction), cl, 1, CV_AA);
188+
cv::line(frame, pt1.m_prediction, pt2.m_prediction, cl, 1, CV_AA);
200189
#endif
201190
if (pt2.m_hasRaw)
202191
{
203192
#if (CV_VERSION_MAJOR >= 4)
204-
cv::circle(frame, ResizePoint(pt2.m_prediction), 4, cl, 4, cv::LINE_AA);
193+
cv::circle(frame, pt2.m_prediction, 4, cl, 4, cv::LINE_AA);
205194
#else
206-
cv::circle(frame, ResizePoint(pt2.m_prediction), 4, cl, 4, CV_AA);
195+
cv::circle(frame, pt2.m_prediction, 4, cl, 4, CV_AA);
207196
#endif
208197
}
209198
}
@@ -229,7 +218,7 @@ void AsyncDetector::DrawData(frame_ptr frameInfo, int framesCounter, int currTim
229218
{
230219
if (track.m_isStatic)
231220
{
232-
DrawTrack(frameInfo->m_frame, 1, track, true);
221+
DrawTrack(frameInfo->m_frame, track, true);
233222
}
234223
else
235224
{
@@ -239,7 +228,7 @@ void AsyncDetector::DrawData(frame_ptr frameInfo, int framesCounter, int currTim
239228
{
240229
//std::cout << TypeConverter::Type2Str(track.m_type) << " - " << track.m_rect << std::endl;
241230

242-
DrawTrack(frameInfo->m_frame, 1, track, true);
231+
DrawTrack(frameInfo->m_frame, track, true);
243232

244233
std::string label = TypeConverter::Type2Str(track.m_type);// +": " + std::to_string(track.m_confidence);
245234
int baseLine = 0;

async_detector/AsyncDetector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class AsyncDetector
7171

7272
void DrawData(frame_ptr frameInfo, int framesCounter, int currTime);
7373

74-
void DrawTrack(cv::Mat frame, int resizeCoeff, const TrackingObject& track, bool drawTrajectory = true);
74+
void DrawTrack(cv::Mat frame, const TrackingObject& track, bool drawTrajectory = true);
7575

7676
static void CaptureThread(std::string fileName, int startFrame, float* fps, FramesQueue* framesQue, bool* stopFlag);
7777
static void DetectThread(const config_t& config, cv::Mat firstFrame, FramesQueue* framesQue, bool* stopFlag);

cars_counting/CMakeLists.txt

Lines changed: 0 additions & 50 deletions
This file was deleted.

cars_counting/main.cpp

Lines changed: 0 additions & 59 deletions
This file was deleted.

example/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ set(HEADERS
1111
MouseExample.h
1212
VideoExample.h
1313
examples.h
14+
FileLogger.h
1415
)
1516

17+
if (BUILD_CARS_COUNTING)
18+
set(SOURCES ${SOURCES} CarsCounting.cpp)
19+
set(HEADERS ${HEADERS} CarsCounting.h)
20+
endif(BUILD_CARS_COUNTING)
21+
1622
# ----------------------------------------------------------------------------
1723
# добавляем include директории
1824
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)