Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
e5872cd8
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,发现更多精彩内容 >>
提交
e5872cd8
编写于
6月 01, 2010
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
now C++ classes can be read/written with cvRead/cvWrite/cvLoad/cvSave. Tested on HOGDescriptor
上级
5c4333d6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
108 addition
and
19 deletion
+108
-19
modules/core/include/opencv2/core/operations.hpp
modules/core/include/opencv2/core/operations.hpp
+45
-0
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+9
-0
modules/objdetect/src/hog.cpp
modules/objdetect/src/hog.cpp
+54
-19
未找到文件。
modules/core/include/opencv2/core/operations.hpp
浏览文件 @
e5872cd8
...
@@ -2622,6 +2622,51 @@ template<typename _Tp> inline bool operator != (const SeqIterator<_Tp>& a,
...
@@ -2622,6 +2622,51 @@ template<typename _Tp> inline bool operator != (const SeqIterator<_Tp>& a,
return
!
(
a
==
b
);
return
!
(
a
==
b
);
}
}
template
<
typename
_ClsName
>
struct
CV_EXPORTS
RTTIImpl
{
public:
static
int
isInstance
(
const
void
*
ptr
)
{
static
_ClsName
dummy
;
return
*
(
const
void
**
)
&
dummy
==
*
(
const
void
**
)
ptr
;
}
static
void
release
(
void
**
dbptr
)
{
if
(
dbptr
&&
*
dbptr
)
{
delete
(
_ClsName
*
)
*
dbptr
;
*
dbptr
=
0
;
}
}
static
void
*
read
(
CvFileStorage
*
fs
,
CvFileNode
*
n
)
{
FileNode
fn
(
fs
,
n
);
_ClsName
*
obj
=
new
_ClsName
;
if
(
obj
->
read
(
fn
))
return
obj
;
delete
obj
;
return
0
;
}
static
void
write
(
CvFileStorage
*
_fs
,
const
char
*
name
,
const
void
*
ptr
,
CvAttrList
)
{
if
(
ptr
&&
_fs
)
{
FileStorage
fs
(
_fs
);
fs
.
fs
.
addref
();
((
const
_ClsName
*
)
ptr
)
->
write
(
fs
,
string
(
name
));
}
}
static
void
*
clone
(
const
void
*
ptr
)
{
if
(
!
ptr
)
return
0
;
return
new
_ClsName
(
*
(
const
_ClsName
*
)
ptr
);
}
};
}
}
#endif // __cplusplus
#endif // __cplusplus
...
...
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
浏览文件 @
e5872cd8
...
@@ -257,6 +257,11 @@ public:
...
@@ -257,6 +257,11 @@ public:
load
(
filename
);
load
(
filename
);
}
}
HOGDescriptor
(
const
HOGDescriptor
&
d
)
{
d
.
copyTo
(
*
this
);
}
virtual
~
HOGDescriptor
()
{}
virtual
~
HOGDescriptor
()
{}
size_t
getDescriptorSize
()
const
;
size_t
getDescriptorSize
()
const
;
...
@@ -265,8 +270,12 @@ public:
...
@@ -265,8 +270,12 @@ public:
virtual
void
setSVMDetector
(
const
vector
<
float
>&
_svmdetector
);
virtual
void
setSVMDetector
(
const
vector
<
float
>&
_svmdetector
);
virtual
bool
read
(
FileNode
&
fn
);
virtual
void
write
(
FileStorage
&
fs
,
const
String
&
objname
)
const
;
virtual
bool
load
(
const
String
&
filename
,
const
String
&
objname
=
String
());
virtual
bool
load
(
const
String
&
filename
,
const
String
&
objname
=
String
());
virtual
void
save
(
const
String
&
filename
,
const
String
&
objname
=
String
())
const
;
virtual
void
save
(
const
String
&
filename
,
const
String
&
objname
=
String
())
const
;
virtual
void
copyTo
(
HOGDescriptor
&
c
)
const
;
virtual
void
compute
(
const
Mat
&
img
,
virtual
void
compute
(
const
Mat
&
img
,
vector
<
float
>&
descriptors
,
vector
<
float
>&
descriptors
,
...
...
modules/objdetect/src/hog.cpp
浏览文件 @
e5872cd8
...
@@ -87,10 +87,10 @@ void HOGDescriptor::setSVMDetector(const vector<float>& _svmDetector)
...
@@ -87,10 +87,10 @@ void HOGDescriptor::setSVMDetector(const vector<float>& _svmDetector)
CV_Assert
(
checkDetectorSize
()
);
CV_Assert
(
checkDetectorSize
()
);
}
}
bool
HOGDescriptor
::
load
(
const
String
&
filename
,
const
String
&
objname
)
#define CV_TYPE_NAME_HOG_DESCRIPTOR "opencv-object-detector-hog"
bool
HOGDescriptor
::
read
(
FileNode
&
obj
)
{
{
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
FileNode
obj
=
!
objname
.
empty
()
?
fs
[
objname
]
:
fs
.
getFirstTopLevelNode
();
if
(
!
obj
.
isMap
()
)
if
(
!
obj
.
isMap
()
)
return
false
;
return
false
;
FileNodeIterator
it
=
obj
[
"winSize"
].
begin
();
FileNodeIterator
it
=
obj
[
"winSize"
].
begin
();
...
@@ -107,7 +107,7 @@ bool HOGDescriptor::load(const String& filename, const String& objname)
...
@@ -107,7 +107,7 @@ bool HOGDescriptor::load(const String& filename, const String& objname)
obj
[
"histogramNormType"
]
>>
histogramNormType
;
obj
[
"histogramNormType"
]
>>
histogramNormType
;
obj
[
"L2HysThreshold"
]
>>
L2HysThreshold
;
obj
[
"L2HysThreshold"
]
>>
L2HysThreshold
;
obj
[
"gammaCorrection"
]
>>
gammaCorrection
;
obj
[
"gammaCorrection"
]
>>
gammaCorrection
;
FileNode
vecNode
=
obj
[
"SVMDetector"
];
FileNode
vecNode
=
obj
[
"SVMDetector"
];
if
(
vecNode
.
isSeq
()
)
if
(
vecNode
.
isSeq
()
)
{
{
...
@@ -116,27 +116,56 @@ bool HOGDescriptor::load(const String& filename, const String& objname)
...
@@ -116,27 +116,56 @@ bool HOGDescriptor::load(const String& filename, const String& objname)
}
}
return
true
;
return
true
;
}
}
void
HOGDescriptor
::
save
(
const
String
&
filename
,
const
String
&
objName
)
const
void
HOGDescriptor
::
write
(
FileStorage
&
fs
,
const
String
&
objName
)
const
{
{
FileStorage
fs
(
filename
,
FileStorage
::
WRITE
);
if
(
!
objName
.
empty
()
)
fs
<<
(
!
objName
.
empty
()
?
objName
:
FileStorage
::
getDefaultObjectName
(
filename
))
<<
"{"
;
fs
<<
objName
;
fs
<<
"winSize"
<<
winSize
fs
<<
"{"
CV_TYPE_NAME_HOG_DESCRIPTOR
<<
"blockSize"
<<
blockSize
<<
"winSize"
<<
winSize
<<
"blockStride"
<<
blockStride
<<
"blockSize"
<<
blockSize
<<
"cellSize"
<<
cellSize
<<
"blockStride"
<<
blockStride
<<
"nbins"
<<
nbins
<<
"cellSize"
<<
cellSize
<<
"derivAperture"
<<
derivAperture
<<
"nbins"
<<
nbins
<<
"winSigma"
<<
getWinSigma
()
<<
"derivAperture"
<<
derivAperture
<<
"histogramNormType"
<<
histogramNormType
<<
"winSigma"
<<
getWinSigma
()
<<
"L2HysThreshold"
<<
L2HysThreshold
<<
"histogramNormType"
<<
histogramNormType
<<
"gammaCorrection"
<<
gammaCorrection
;
<<
"L2HysThreshold"
<<
L2HysThreshold
<<
"gammaCorrection"
<<
gammaCorrection
;
if
(
!
svmDetector
.
empty
()
)
if
(
!
svmDetector
.
empty
()
)
fs
<<
"SVMDetector"
<<
"[:"
<<
svmDetector
<<
"]"
;
fs
<<
"SVMDetector"
<<
"[:"
<<
svmDetector
<<
"]"
;
fs
<<
"}"
;
fs
<<
"}"
;
}
}
bool
HOGDescriptor
::
load
(
const
String
&
filename
,
const
String
&
objname
)
{
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
FileNode
obj
=
!
objname
.
empty
()
?
fs
[
objname
]
:
fs
.
getFirstTopLevelNode
();
return
read
(
obj
);
}
void
HOGDescriptor
::
save
(
const
String
&
filename
,
const
String
&
objName
)
const
{
FileStorage
fs
(
filename
,
FileStorage
::
WRITE
);
write
(
fs
,
!
objName
.
empty
()
?
objName
:
FileStorage
::
getDefaultObjectName
(
filename
));
}
void
HOGDescriptor
::
copyTo
(
HOGDescriptor
&
c
)
const
{
c
.
winSize
=
winSize
;
c
.
blockSize
=
blockSize
;
c
.
blockStride
=
blockStride
;
c
.
cellSize
=
cellSize
;
c
.
nbins
=
nbins
;
c
.
derivAperture
=
derivAperture
;
c
.
winSigma
=
winSigma
;
c
.
histogramNormType
=
histogramNormType
;
c
.
L2HysThreshold
=
L2HysThreshold
;
c
.
gammaCorrection
=
gammaCorrection
;
c
.
svmDetector
=
svmDetector
;
}
void
HOGDescriptor
::
computeGradient
(
const
Mat
&
img
,
Mat
&
grad
,
Mat
&
qangle
,
void
HOGDescriptor
::
computeGradient
(
const
Mat
&
img
,
Mat
&
grad
,
Mat
&
qangle
,
Size
paddingTL
,
Size
paddingBR
)
const
Size
paddingTL
,
Size
paddingBR
)
const
{
{
...
@@ -870,6 +899,12 @@ void HOGDescriptor::detectMultiScale(
...
@@ -870,6 +899,12 @@ void HOGDescriptor::detectMultiScale(
groupRectangles
(
foundLocations
,
groupThreshold
,
0.2
);
groupRectangles
(
foundLocations
,
groupThreshold
,
0.2
);
}
}
typedef
RTTIImpl
<
HOGDescriptor
>
HOGRTTI
;
CvType
hog_type
(
CV_TYPE_NAME_HOG_DESCRIPTOR
,
HOGRTTI
::
isInstance
,
HOGRTTI
::
release
,
HOGRTTI
::
read
,
HOGRTTI
::
write
,
HOGRTTI
::
clone
);
vector
<
float
>
HOGDescriptor
::
getDefaultPeopleDetector
()
vector
<
float
>
HOGDescriptor
::
getDefaultPeopleDetector
()
{
{
static
const
float
detector
[]
=
{
static
const
float
detector
[]
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录