Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
ba88b2ee
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,发现更多精彩内容 >>
提交
ba88b2ee
编写于
10月 16, 2010
作者:
A
Alexey Polovinkin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added error handling in latentsvmdetect sample
上级
f678c8f0
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
28 addition
and
6 deletion
+28
-6
modules/objdetect/src/_lsvm_error.h
modules/objdetect/src/_lsvm_error.h
+1
-0
modules/objdetect/src/latentsvmdetector.cpp
modules/objdetect/src/latentsvmdetector.cpp
+3
-1
modules/objdetect/src/lsvmparser.cpp
modules/objdetect/src/lsvmparser.cpp
+5
-4
samples/c/cat.jpg
samples/c/cat.jpg
+0
-0
samples/c/latentsvmdetect.cpp
samples/c/latentsvmdetect.cpp
+19
-1
未找到文件。
modules/objdetect/src/_lsvm_error.h
浏览文件 @
ba88b2ee
...
...
@@ -12,5 +12,6 @@
#define FILTER_OUT_OF_BOUNDARIES -7
#define FFT_OK 2
#define FFT_ERROR -8
#define LSVM_PARSER_FILE_NOT_FOUND -9
#endif
modules/objdetect/src/latentsvmdetector.cpp
浏览文件 @
ba88b2ee
...
...
@@ -22,8 +22,10 @@ CvLatentSvmDetector* cvLoadLatentSvmDetector(const char* filename)
int
*
kPartFilters
=
0
;
float
*
b
=
0
;
float
scoreThreshold
=
0.
f
;
int
err_code
=
0
;
loadModel
(
filename
,
&
filters
,
&
kFilters
,
&
kComponents
,
&
kPartFilters
,
&
b
,
&
scoreThreshold
);
err_code
=
loadModel
(
filename
,
&
filters
,
&
kFilters
,
&
kComponents
,
&
kPartFilters
,
&
b
,
&
scoreThreshold
);
if
(
err_code
!=
LATENT_SVM_OK
)
return
0
;
detector
=
(
CvLatentSvmDetector
*
)
malloc
(
sizeof
(
CvLatentSvmDetector
));
detector
->
filters
=
filters
;
...
...
modules/objdetect/src/lsvmparser.cpp
浏览文件 @
ba88b2ee
...
...
@@ -2,6 +2,7 @@
#include <stdio.h>
#include "string.h"
#include "_lsvmparser.h"
#include "_lsvm_error.h"
int
isMODEL
(
char
*
str
){
char
stag
[]
=
"<Model>"
;
...
...
@@ -736,7 +737,7 @@ int LSVMparser(const char * filename, filterObject *** model, int *last, int *ma
xmlf
=
fopen
(
filename
,
"rb"
);
if
(
xmlf
==
NULL
){
return
-
1
;
return
LSVM_PARSER_FILE_NOT_FOUND
;
}
i
=
0
;
...
...
@@ -767,7 +768,7 @@ int LSVMparser(const char * filename, filterObject *** model, int *last, int *ma
}
}
}
return
0
;
return
LATENT_SVM_OK
;
}
int
loadModel
(
...
...
@@ -789,8 +790,8 @@ int loadModel(
//printf("start_parse\n\n");
err
=
LSVMparser
(
modelPath
,
filters
,
&
last
,
&
max
,
&
comp
,
b
,
&
count
,
&
score
);
if
(
err
!=
0
){
return
-
1
;
if
(
err
!=
LATENT_SVM_OK
){
return
err
;
}
(
*
kFilters
)
=
last
+
1
;
(
*
kComponents
)
=
count
;
...
...
samples/c/
000028
.jpg
→
samples/c/
cat
.jpg
浏览文件 @
ba88b2ee
此差异由.gitattributes 抑制。
samples/c/latentsvmdetect.cpp
浏览文件 @
ba88b2ee
...
...
@@ -6,7 +6,7 @@
using
namespace
cv
;
const
char
*
model_filename
=
"cat.xml"
;
const
char
*
image_filename
=
"
000028
.jpg"
;
const
char
*
image_filename
=
"
cat
.jpg"
;
void
detect_and_draw_objects
(
IplImage
*
image
,
CvLatentSvmDetector
*
detector
)
{
...
...
@@ -35,8 +35,26 @@ void detect_and_draw_objects( IplImage* image, CvLatentSvmDetector* detector)
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
>
2
)
{
image_filename
=
argv
[
1
];
model_filename
=
argv
[
2
];
}
IplImage
*
image
=
cvLoadImage
(
image_filename
);
if
(
!
image
)
{
printf
(
"Unable to load the image
\n
"
"Pass it as the first parameter: latentsvmdetect <path to cat.jpg> <path to cat.xml>
\n
"
);
return
-
1
;
}
CvLatentSvmDetector
*
detector
=
cvLoadLatentSvmDetector
(
model_filename
);
if
(
!
detector
)
{
printf
(
"Unable to load the model
\n
"
"Pass it as the second parameter: latentsvmdetect <path to cat.jpg> <path to cat.xml>
\n
"
);
cvReleaseImage
(
&
image
);
return
-
1
;
}
detect_and_draw_objects
(
image
,
detector
);
cvNamedWindow
(
"test"
,
0
);
cvShowImage
(
"test"
,
image
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录