Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
7c9cff72
Commit
7c9cff72
authored
Apr 23, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: don't use CV_ErrorNoReturn() internally
parent
a4e8622c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
33 deletions
+18
-33
face_alignment.cpp
modules/face/src/face_alignment.cpp
+3
-4
facemark.cpp
modules/face/src/facemark.cpp
+1
-2
regtree.cpp
modules/face/src/regtree.cpp
+4
-8
trainFacemark.cpp
modules/face/src/trainFacemark.cpp
+9
-18
gtrTracker.cpp
modules/tracking/src/gtrTracker.cpp
+1
-1
No files found.
modules/face/src/face_alignment.cpp
View file @
7c9cff72
...
@@ -79,8 +79,7 @@ bool FacemarkKazemiImpl::convertToUnit(Rect r,Mat &warp){
...
@@ -79,8 +79,7 @@ bool FacemarkKazemiImpl::convertToUnit(Rect r,Mat &warp){
bool
FacemarkKazemiImpl
::
setMeanExtreme
(){
bool
FacemarkKazemiImpl
::
setMeanExtreme
(){
if
(
meanshape
.
empty
()){
if
(
meanshape
.
empty
()){
String
error_message
=
"Model not loaded properly.No mean shape found.Aborting..."
;
String
error_message
=
"Model not loaded properly.No mean shape found.Aborting..."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
for
(
size_t
i
=
0
;
i
<
meanshape
.
size
();
i
++
){
for
(
size_t
i
=
0
;
i
<
meanshape
.
size
();
i
++
){
if
(
meanshape
[
i
].
x
>
maxmeanx
)
if
(
meanshape
[
i
].
x
>
maxmeanx
)
...
@@ -98,7 +97,7 @@ bool FacemarkKazemiImpl::calcMeanShape (vector< vector<Point2f> >& trainlandmark
...
@@ -98,7 +97,7 @@ bool FacemarkKazemiImpl::calcMeanShape (vector< vector<Point2f> >& trainlandmark
//clear the loaded meanshape
//clear the loaded meanshape
if
(
trainimages
.
empty
()
||
trainlandmarks
.
size
()
!=
trainimages
.
size
())
{
if
(
trainimages
.
empty
()
||
trainlandmarks
.
size
()
!=
trainimages
.
size
())
{
// throw error if no data (or simply return -1?)
// throw error if no data (or simply return -1?)
CV_Error
NoReturn
(
Error
::
StsBadArg
,
"Number of images is not equal to corresponding landmarks. Aborting..."
);
CV_Error
(
Error
::
StsBadArg
,
"Number of images is not equal to corresponding landmarks. Aborting..."
);
}
}
meanshape
.
clear
();
meanshape
.
clear
();
vector
<
Mat
>
finalimages
;
vector
<
Mat
>
finalimages
;
...
@@ -165,7 +164,7 @@ bool FacemarkKazemiImpl::scaleData( vector< vector<Point2f> > & trainlandmarks,
...
@@ -165,7 +164,7 @@ bool FacemarkKazemiImpl::scaleData( vector< vector<Point2f> > & trainlandmarks,
{
{
if
(
trainimages
.
empty
()
||
trainimages
.
size
()
!=
trainlandmarks
.
size
()){
if
(
trainimages
.
empty
()
||
trainimages
.
size
()
!=
trainlandmarks
.
size
()){
// throw error if no data (or simply return -1?)
// throw error if no data (or simply return -1?)
CV_Error
NoReturn
(
Error
::
StsBadArg
,
"The data is not loaded properly by train function. Aborting..."
);
CV_Error
(
Error
::
StsBadArg
,
"The data is not loaded properly by train function. Aborting..."
);
}
}
float
scalex
,
scaley
;
float
scalex
,
scaley
;
//scale all images and their landmarks according to input size
//scale all images and their landmarks according to input size
...
...
modules/face/src/facemark.cpp
View file @
7c9cff72
...
@@ -228,8 +228,7 @@ bool loadTrainingData(vector<String> filename,vector< vector<Point2f> >
...
@@ -228,8 +228,7 @@ bool loadTrainingData(vector<String> filename,vector< vector<Point2f> >
f1
.
open
(
filename
[
j
].
c_str
(),
ios
::
in
);
f1
.
open
(
filename
[
j
].
c_str
(),
ios
::
in
);
if
(
!
f1
.
is_open
()){
if
(
!
f1
.
is_open
()){
cout
<<
filename
[
j
]
<<
endl
;
cout
<<
filename
[
j
]
<<
endl
;
CV_ErrorNoReturn
(
Error
::
StsError
,
"File can't be opened for reading!"
);
CV_Error
(
Error
::
StsError
,
"File can't be opened for reading!"
);
return
false
;
}
}
//get the path of the image whose landmarks have to be detected
//get the path of the image whose landmarks have to be detected
getline
(
f1
,
img
);
getline
(
f1
,
img
);
...
...
modules/face/src/regtree.cpp
View file @
7c9cff72
...
@@ -113,8 +113,7 @@ bool FacemarkKazemiImpl:: getBestSplit(vector<Point2f> pixel_coordinates, vector
...
@@ -113,8 +113,7 @@ bool FacemarkKazemiImpl:: getBestSplit(vector<Point2f> pixel_coordinates, vector
{
{
if
(
samples
[
0
].
shapeResiduals
.
size
()
!=
samples
[
0
].
current_shape
.
size
()){
if
(
samples
[
0
].
shapeResiduals
.
size
()
!=
samples
[
0
].
current_shape
.
size
()){
String
error_message
=
"Error while generating split.Residuals are not complete.Aborting...."
;
String
error_message
=
"Error while generating split.Residuals are not complete.Aborting...."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
//This vector stores the matrices where each matrix represents
//This vector stores the matrices where each matrix represents
//sum of the residuals of shapes of samples which go to the left
//sum of the residuals of shapes of samples which go to the left
...
@@ -222,13 +221,11 @@ bool FacemarkKazemiImpl :: generateSplit(queue<node_info>& curr,vector<Point2f>
...
@@ -222,13 +221,11 @@ bool FacemarkKazemiImpl :: generateSplit(queue<node_info>& curr,vector<Point2f>
bool
FacemarkKazemiImpl
::
buildRegtree
(
regtree
&
tree
,
vector
<
training_sample
>&
samples
,
vector
<
Point2f
>
pixel_coordinates
){
bool
FacemarkKazemiImpl
::
buildRegtree
(
regtree
&
tree
,
vector
<
training_sample
>&
samples
,
vector
<
Point2f
>
pixel_coordinates
){
if
(
samples
.
size
()
==
0
){
if
(
samples
.
size
()
==
0
){
String
error_message
=
"Error while building regression tree.Empty samples. Aborting...."
;
String
error_message
=
"Error while building regression tree.Empty samples. Aborting...."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
if
(
pixel_coordinates
.
size
()
==
0
){
if
(
pixel_coordinates
.
size
()
==
0
){
String
error_message
=
"Error while building regression tree.No pixel coordinates. Aborting...."
;
String
error_message
=
"Error while building regression tree.No pixel coordinates. Aborting...."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
queue
<
node_info
>
curr
;
queue
<
node_info
>
curr
;
node_info
parent
;
node_info
parent
;
...
@@ -291,8 +288,7 @@ unsigned long FacemarkKazemiImpl::divideSamples (splitr split,vector<training_sa
...
@@ -291,8 +288,7 @@ unsigned long FacemarkKazemiImpl::divideSamples (splitr split,vector<training_sa
{
{
if
(
samples
.
size
()
==
0
){
if
(
samples
.
size
()
==
0
){
String
error_message
=
"Error while dividing samples. Sample array empty. Aborting...."
;
String
error_message
=
"Error while dividing samples. Sample array empty. Aborting...."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
0
;
}
}
unsigned
long
i
=
start
;
unsigned
long
i
=
start
;
training_sample
temp
;
training_sample
temp
;
...
...
modules/face/src/trainFacemark.cpp
View file @
7c9cff72
...
@@ -54,8 +54,7 @@ bool FacemarkKazemiImpl::setTrainingParameters(String filename){
...
@@ -54,8 +54,7 @@ bool FacemarkKazemiImpl::setTrainingParameters(String filename){
fs
.
open
(
filename
,
FileStorage
::
READ
);
fs
.
open
(
filename
,
FileStorage
::
READ
);
if
(
!
fs
.
isOpened
())
if
(
!
fs
.
isOpened
())
{
String
error_message
=
"Error while opening configuration file.Aborting.."
;
{
String
error_message
=
"Error while opening configuration file.Aborting.."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
int
cascade_depth_
;
int
cascade_depth_
;
int
tree_depth_
;
int
tree_depth_
;
...
@@ -105,8 +104,7 @@ unsigned long FacemarkKazemiImpl:: getNearestLandmark(Point2f pixel)
...
@@ -105,8 +104,7 @@ unsigned long FacemarkKazemiImpl:: getNearestLandmark(Point2f pixel)
if
(
meanshape
.
empty
())
{
if
(
meanshape
.
empty
())
{
// throw error if no data (or simply return -1?)
// throw error if no data (or simply return -1?)
String
error_message
=
"The data is not loaded properly by train function. Aborting..."
;
String
error_message
=
"The data is not loaded properly by train function. Aborting..."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
float
dist
=
float
(
INT_MAX
);
float
dist
=
float
(
INT_MAX
);
unsigned
long
index
=
0
;
unsigned
long
index
=
0
;
...
@@ -122,8 +120,7 @@ unsigned long FacemarkKazemiImpl:: getNearestLandmark(Point2f pixel)
...
@@ -122,8 +120,7 @@ unsigned long FacemarkKazemiImpl:: getNearestLandmark(Point2f pixel)
bool
FacemarkKazemiImpl
::
getRelativePixels
(
vector
<
Point2f
>
sample
,
vector
<
Point2f
>&
pixel_coordinates
,
std
::
vector
<
int
>
nearest
){
bool
FacemarkKazemiImpl
::
getRelativePixels
(
vector
<
Point2f
>
sample
,
vector
<
Point2f
>&
pixel_coordinates
,
std
::
vector
<
int
>
nearest
){
if
(
sample
.
size
()
!=
meanshape
.
size
()){
if
(
sample
.
size
()
!=
meanshape
.
size
()){
String
error_message
=
"Error while finding relative shape. Aborting...."
;
String
error_message
=
"Error while finding relative shape. Aborting...."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
Mat
transform_mat
;
Mat
transform_mat
;
transform_mat
=
estimateRigidTransform
(
meanshape
,
sample
,
false
);
transform_mat
=
estimateRigidTransform
(
meanshape
,
sample
,
false
);
...
@@ -146,8 +143,7 @@ bool FacemarkKazemiImpl :: getRelativePixels(vector<Point2f> sample,vector<Point
...
@@ -146,8 +143,7 @@ bool FacemarkKazemiImpl :: getRelativePixels(vector<Point2f> sample,vector<Point
bool
FacemarkKazemiImpl
::
getPixelIntensities
(
Mat
img
,
vector
<
Point2f
>
pixel_coordinates
,
vector
<
int
>&
pixel_intensities
,
Rect
face
){
bool
FacemarkKazemiImpl
::
getPixelIntensities
(
Mat
img
,
vector
<
Point2f
>
pixel_coordinates
,
vector
<
int
>&
pixel_intensities
,
Rect
face
){
if
(
pixel_coordinates
.
size
()
==
0
){
if
(
pixel_coordinates
.
size
()
==
0
){
String
error_message
=
"No pixel coordinates found. Aborting....."
;
String
error_message
=
"No pixel coordinates found. Aborting....."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
Mat
transform_mat
;
Mat
transform_mat
;
convertToActual
(
face
,
transform_mat
);
convertToActual
(
face
,
transform_mat
);
...
@@ -259,13 +255,11 @@ bool FacemarkKazemiImpl :: saveModel(String filename){
...
@@ -259,13 +255,11 @@ bool FacemarkKazemiImpl :: saveModel(String filename){
ofstream
f
(
filename
.
c_str
(),
ios
::
binary
);
ofstream
f
(
filename
.
c_str
(),
ios
::
binary
);
if
(
!
f
.
is_open
()){
if
(
!
f
.
is_open
()){
String
error_message
=
"Error while opening file to write model. Aborting...."
;
String
error_message
=
"Error while opening file to write model. Aborting...."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
if
(
loaded_forests
.
size
()
!=
loaded_pixel_coordinates
.
size
()){
if
(
loaded_forests
.
size
()
!=
loaded_pixel_coordinates
.
size
()){
String
error_message
=
"Incorrect training data. Aborting...."
;
String
error_message
=
"Incorrect training data. Aborting...."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
string
s
(
"cascade_depth"
);
string
s
(
"cascade_depth"
);
uint64_t
len
=
s
.
size
();
uint64_t
len
=
s
.
size
();
...
@@ -306,14 +300,12 @@ void FacemarkKazemiImpl::training(String imageList, String groundTruth){
...
@@ -306,14 +300,12 @@ void FacemarkKazemiImpl::training(String imageList, String groundTruth){
imageList
.
clear
();
imageList
.
clear
();
groundTruth
.
clear
();
groundTruth
.
clear
();
String
error_message
=
"Less arguments than required"
;
String
error_message
=
"Less arguments than required"
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
;
}
}
bool
FacemarkKazemiImpl
::
training
(
vector
<
Mat
>&
images
,
vector
<
vector
<
Point2f
>
>&
landmarks
,
string
filename
,
Size
scale
,
string
modelFilename
){
bool
FacemarkKazemiImpl
::
training
(
vector
<
Mat
>&
images
,
vector
<
vector
<
Point2f
>
>&
landmarks
,
string
filename
,
Size
scale
,
string
modelFilename
){
if
(
!
setTrainingParameters
(
filename
)){
if
(
!
setTrainingParameters
(
filename
)){
String
error_message
=
"Error while loading training parameters"
;
String
error_message
=
"Error while loading training parameters"
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
vector
<
Rect
>
rectangles
;
vector
<
Rect
>
rectangles
;
scaleData
(
landmarks
,
images
,
scale
);
scaleData
(
landmarks
,
images
,
scale
);
...
@@ -321,8 +313,7 @@ bool FacemarkKazemiImpl::training(vector<Mat>& images, vector< vector<Point2f> >
...
@@ -321,8 +313,7 @@ bool FacemarkKazemiImpl::training(vector<Mat>& images, vector< vector<Point2f> >
if
(
images
.
size
()
!=
landmarks
.
size
()){
if
(
images
.
size
()
!=
landmarks
.
size
()){
// throw error if no data (or simply return -1?)
// throw error if no data (or simply return -1?)
String
error_message
=
"The data is not loaded properly. Aborting training function...."
;
String
error_message
=
"The data is not loaded properly. Aborting training function...."
;
CV_ErrorNoReturn
(
Error
::
StsBadArg
,
error_message
);
CV_Error
(
Error
::
StsBadArg
,
error_message
);
return
false
;
}
}
vector
<
training_sample
>
samples
;
vector
<
training_sample
>
samples
;
getTestCoordinates
();
getTestCoordinates
();
...
...
modules/tracking/src/gtrTracker.cpp
View file @
7c9cff72
...
@@ -58,7 +58,7 @@ Ptr<TrackerGOTURN> TrackerGOTURN::create(const TrackerGOTURN::Params ¶meters
...
@@ -58,7 +58,7 @@ Ptr<TrackerGOTURN> TrackerGOTURN::create(const TrackerGOTURN::Params ¶meters
return
Ptr
<
gtr
::
TrackerGOTURNImpl
>
(
new
gtr
::
TrackerGOTURNImpl
(
parameters
));
return
Ptr
<
gtr
::
TrackerGOTURNImpl
>
(
new
gtr
::
TrackerGOTURNImpl
(
parameters
));
#else
#else
(
void
)(
parameters
);
(
void
)(
parameters
);
CV_Error
NoReturn
(
cv
::
Error
::
StsNotImplemented
,
"to use GOTURN, the tracking module needs to be built with opencv_dnn !"
);
CV_Error
(
cv
::
Error
::
StsNotImplemented
,
"to use GOTURN, the tracking module needs to be built with opencv_dnn !"
);
#endif
#endif
}
}
Ptr
<
TrackerGOTURN
>
TrackerGOTURN
::
create
()
Ptr
<
TrackerGOTURN
>
TrackerGOTURN
::
create
()
...
...
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