Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
2fd8ad65
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2fd8ad65
编写于
10月 04, 2012
作者:
L
Leonid Beynenson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Made changes in cv::DetectionBasedTracker -- now it can return status of the tracked objects
上级
9218bdcb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
64 addition
and
11 deletion
+64
-11
modules/contrib/include/opencv2/contrib/detection_based_tracker.hpp
...ntrib/include/opencv2/contrib/detection_based_tracker.hpp
+21
-0
modules/contrib/src/detection_based_tracker.cpp
modules/contrib/src/detection_based_tracker.cpp
+43
-11
未找到文件。
modules/contrib/include/opencv2/contrib/detection_based_tracker.hpp
浏览文件 @
2fd8ad65
...
...
@@ -90,6 +90,26 @@ class DetectionBasedTracker
virtual
void
getObjects
(
std
::
vector
<
cv
::
Rect
>&
result
)
const
;
virtual
void
getObjects
(
std
::
vector
<
Object
>&
result
)
const
;
enum
ObjectStatus
{
DETECTED_NOT_SHOWN_YET
,
DETECTED
,
DETECTED_TEMPORARY_LOST
,
WRONG_OBJECT
};
struct
ExtObject
{
int
id
;
cv
::
Rect
location
;
ObjectStatus
status
;
ExtObject
(
int
_id
,
cv
::
Rect
_location
,
ObjectStatus
_status
)
:
id
(
_id
),
location
(
_location
),
status
(
_status
)
{
}
};
virtual
void
getObjects
(
std
::
vector
<
ExtObject
>&
result
)
const
;
virtual
int
addObject
(
const
cv
::
Rect
&
location
);
//returns id of the new object
protected:
...
...
@@ -146,6 +166,7 @@ class DetectionBasedTracker
void
updateTrackedObjects
(
const
std
::
vector
<
cv
::
Rect
>&
detectedObjects
);
cv
::
Rect
calcTrackedObjectPositionToShow
(
int
i
)
const
;
cv
::
Rect
calcTrackedObjectPositionToShow
(
int
i
,
ObjectStatus
&
status
)
const
;
void
detectInRegion
(
const
cv
::
Mat
&
img
,
const
cv
::
Rect
&
r
,
std
::
vector
<
cv
::
Rect
>&
detectedObjectsInRegions
);
};
}
//end of cv namespace
...
...
modules/contrib/src/detection_based_tracker.cpp
浏览文件 @
2fd8ad65
#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID)
#include "opencv2/contrib/detection_based_tracker.hpp"
#if defined(DEBUG) || defined(_DEBUG)
#undef DEBUGLOGS
#define DEBUGLOGS 1
#endif
#ifndef DEBUGLOGS
#define DEBUGLOGS 0
#endif
#ifdef ANDROID
#include <android/log.h>
...
...
@@ -173,33 +180,33 @@ bool cv::DetectionBasedTracker::SeparateDetectionWork::run()
}
#ifdef __GNUC__
#define CATCH_ALL_AND_LOG(_block)
\
do {
\
#define CATCH_ALL_AND_LOG(_block) \
do { \
try { \
_block; \
break; \
} \
catch(cv::Exception& e) { \
LOGE0("\n %s: ERROR: OpenCV Exception caught: \n'%s'\n\n", __func__, e.what()); \
LOGE0("\n %s: ERROR: OpenCV Exception caught: \n'%s'\n\n", __func__, e.what());
\
} catch(std::exception& e) { \
LOGE0("\n %s: ERROR: Exception caught: \n'%s'\n\n", __func__, e.what()); \
LOGE0("\n %s: ERROR: Exception caught: \n'%s'\n\n", __func__, e.what());
\
} catch(...) { \
LOGE0("\n %s: ERROR: UNKNOWN Exception caught\n\n", __func__); \
LOGE0("\n %s: ERROR: UNKNOWN Exception caught\n\n", __func__);
\
} \
} while(0)
#else
#define CATCH_ALL_AND_LOG(_block)
\
do {
\
#define CATCH_ALL_AND_LOG(_block) \
do { \
try { \
_block; \
break; \
} \
catch(cv::Exception& e) { \
LOGE0("\n ERROR: OpenCV Exception caught: \n'%s'\n\n", e.what()); \
LOGE0("\n ERROR: OpenCV Exception caught: \n'%s'\n\n", e.what());
\
} catch(std::exception& e) { \
LOGE0("\n ERROR: Exception caught: \n'%s'\n\n", e.what()); \
LOGE0("\n ERROR: Exception caught: \n'%s'\n\n", e.what());
\
} catch(...) { \
LOGE0("\n ERROR: UNKNOWN Exception caught\n\n"); \
LOGE0("\n ERROR: UNKNOWN Exception caught\n\n");
\
} \
} while(0)
#endif
...
...
@@ -218,7 +225,7 @@ void* cv::workcycleObjectDetectorFunction(void* p)
void
cv
::
DetectionBasedTracker
::
SeparateDetectionWork
::
workcycleObjectDetector
()
{
static
double
freq
=
getTickFrequency
();
LOGD
0
(
"DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- start"
);
LOGD
(
"DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- start"
);
vector
<
Rect
>
objects
;
CV_Assert
(
stateThread
==
STATE_THREAD_WORKING_SLEEPING
);
...
...
@@ -303,6 +310,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()
int64
t2_detect
=
getTickCount
();
int64
dt_detect
=
t2_detect
-
t1_detect
;
double
dt_detect_ms
=
((
double
)
dt_detect
)
/
freq
*
1000.0
;
(
void
)(
dt_detect_ms
);
LOGI
(
"DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- objects num==%d, t_ms=%.4f"
,
(
int
)
objects
.
size
(),
dt_detect_ms
);
...
...
@@ -396,6 +404,7 @@ bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingT
isObjectDetectingReady
=
false
;
double
lastBigDetectionDuration
=
1000.0
*
(((
double
)(
getTickCount
()
-
timeWhenDetectingThreadStartedWork
))
/
freq
);
(
void
)(
lastBigDetectionDuration
);
LOGD
(
"DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread: lastBigDetectionDuration=%f ms"
,
(
double
)
lastBigDetectionDuration
);
}
...
...
@@ -482,6 +491,7 @@ void DetectionBasedTracker::process(const Mat& imageGray)
{
double
delta_time_from_prev_call
=
1000.0
*
(((
double
)(
getTickCount
()
-
time_when_last_call_started
))
/
freq
);
(
void
)(
delta_time_from_prev_call
);
LOGD
(
"DetectionBasedTracker::process: time from the previous call is %f ms"
,
(
double
)
delta_time_from_prev_call
);
time_when_last_call_started
=
getTickCount
();
}
...
...
@@ -564,6 +574,17 @@ void cv::DetectionBasedTracker::getObjects(std::vector<Object>& result) const
LOGD
(
"DetectionBasedTracker::process: found a object with SIZE %d x %d, rect={%d, %d, %d x %d}"
,
r
.
width
,
r
.
height
,
r
.
x
,
r
.
y
,
r
.
width
,
r
.
height
);
}
}
void
cv
::
DetectionBasedTracker
::
getObjects
(
std
::
vector
<
ExtObject
>&
result
)
const
{
result
.
clear
();
for
(
size_t
i
=
0
;
i
<
trackedObjects
.
size
();
i
++
)
{
ObjectStatus
status
;
Rect
r
=
calcTrackedObjectPositionToShow
(
i
,
status
);
result
.
push_back
(
ExtObject
(
trackedObjects
[
i
].
id
,
r
,
status
));
LOGD
(
"DetectionBasedTracker::process: found a object with SIZE %d x %d, rect={%d, %d, %d x %d}, status = %d"
,
r
.
width
,
r
.
height
,
r
.
x
,
r
.
y
,
r
.
width
,
r
.
height
,
(
int
)
status
);
}
}
bool
cv
::
DetectionBasedTracker
::
run
()
{
...
...
@@ -699,6 +720,7 @@ void cv::DetectionBasedTracker::updateTrackedObjects(const vector<Rect>& detecte
int
numpos
=
it
->
lastPositions
.
size
();
CV_Assert
(
numpos
>
0
);
Rect
r
=
it
->
lastPositions
[
numpos
-
1
];
(
void
)(
r
);
LOGD
(
"DetectionBasedTracker::updateTrackedObjects: deleted object {%d, %d, %d x %d}"
,
r
.
x
,
r
.
y
,
r
.
width
,
r
.
height
);
it
=
trackedObjects
.
erase
(
it
);
...
...
@@ -718,17 +740,25 @@ int cv::DetectionBasedTracker::addObject(const Rect& location)
}
Rect
cv
::
DetectionBasedTracker
::
calcTrackedObjectPositionToShow
(
int
i
)
const
{
ObjectStatus
status
;
return
calcTrackedObjectPositionToShow
(
i
,
status
);
}
Rect
cv
::
DetectionBasedTracker
::
calcTrackedObjectPositionToShow
(
int
i
,
ObjectStatus
&
status
)
const
{
if
(
(
i
<
0
)
||
(
i
>=
(
int
)
trackedObjects
.
size
())
)
{
LOGE
(
"DetectionBasedTracker::calcTrackedObjectPositionToShow: ERROR: wrong i=%d"
,
i
);
status
=
WRONG_OBJECT
;
return
Rect
();
}
if
(
trackedObjects
[
i
].
numDetectedFrames
<=
innerParameters
.
numStepsToWaitBeforeFirstShow
){
LOGI
(
"DetectionBasedTracker::calcTrackedObjectPositionToShow: trackedObjects[%d].numDetectedFrames=%d <= numStepsToWaitBeforeFirstShow=%d --- return empty Rect()"
,
i
,
trackedObjects
[
i
].
numDetectedFrames
,
innerParameters
.
numStepsToWaitBeforeFirstShow
);
status
=
DETECTED_NOT_SHOWN_YET
;
return
Rect
();
}
if
(
trackedObjects
[
i
].
numFramesNotDetected
>
innerParameters
.
numStepsToShowWithoutDetecting
)
{
status
=
DETECTED_TEMPORARY_LOST
;
return
Rect
();
}
...
...
@@ -737,6 +767,7 @@ Rect cv::DetectionBasedTracker::calcTrackedObjectPositionToShow(int i) const
int
N
=
lastPositions
.
size
();
if
(
N
<=
0
)
{
LOGE
(
"DetectionBasedTracker::calcTrackedObjectPositionToShow: ERROR: no positions for i=%d"
,
i
);
status
=
WRONG_OBJECT
;
return
Rect
();
}
...
...
@@ -795,6 +826,7 @@ Rect cv::DetectionBasedTracker::calcTrackedObjectPositionToShow(int i) const
Rect
res
(
cvRound
(
tl
.
x
),
cvRound
(
tl
.
y
),
cvRound
(
w
),
cvRound
(
h
));
LOGD
(
"DetectionBasedTracker::calcTrackedObjectPositionToShow: Result for i=%d: {%d, %d, %d x %d}"
,
i
,
res
.
x
,
res
.
y
,
res
.
width
,
res
.
height
);
status
=
DETECTED
;
return
res
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录