Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
ba88b2ee
Commit
ba88b2ee
authored
Oct 16, 2010
by
Alexey Polovinkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added error handling in latentsvmdetect sample
parent
f678c8f0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
6 deletions
+28
-6
_lsvm_error.h
modules/objdetect/src/_lsvm_error.h
+1
-0
latentsvmdetector.cpp
modules/objdetect/src/latentsvmdetector.cpp
+3
-1
lsvmparser.cpp
modules/objdetect/src/lsvmparser.cpp
+5
-4
cat.jpg
samples/c/cat.jpg
+0
-0
latentsvmdetect.cpp
samples/c/latentsvmdetect.cpp
+19
-1
No files found.
modules/objdetect/src/_lsvm_error.h
View file @
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
View file @
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
View file @
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
View file @
ba88b2ee
File moved
samples/c/latentsvmdetect.cpp
View file @
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment