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
bb4bf7a1
Commit
bb4bf7a1
authored
Nov 18, 2013
by
Roman Donchenko
Committed by
OpenCV Buildbot
Nov 18, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1811 from Nerei:fixed_some_build_errors
parents
b8c46f4c
9e3a2970
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
299 additions
and
264 deletions
+299
-264
HOGfeatures.cpp
apps/traincascade/HOGfeatures.cpp
+1
-0
HOGfeatures.h
apps/traincascade/HOGfeatures.h
+11
-11
boost.cpp
apps/traincascade/boost.cpp
+14
-0
boost.h
apps/traincascade/boost.h
+9
-9
cascadeclassifier.cpp
apps/traincascade/cascadeclassifier.cpp
+1
-0
cascadeclassifier.h
apps/traincascade/cascadeclassifier.h
+13
-13
features.cpp
apps/traincascade/features.cpp
+1
-0
haarfeatures.cpp
apps/traincascade/haarfeatures.cpp
+1
-0
haarfeatures.h
apps/traincascade/haarfeatures.h
+13
-13
imagestorage.cpp
apps/traincascade/imagestorage.cpp
+1
-0
imagestorage.h
apps/traincascade/imagestorage.h
+10
-10
lbpfeatures.cpp
apps/traincascade/lbpfeatures.cpp
+2
-0
lbpfeatures.h
apps/traincascade/lbpfeatures.h
+8
-8
traincascade.cpp
apps/traincascade/traincascade.cpp
+1
-0
traincascade_features.h
apps/traincascade/traincascade_features.h
+15
-15
cap_openni.cpp
modules/highgui/src/cap_openni.cpp
+9
-4
erfilter.cpp
modules/objdetect/src/erfilter.cpp
+7
-3
test_hdr.cpp
modules/photo/test/test_hdr.cpp
+0
-3
test_precomp.hpp
modules/photo/test/test_precomp.hpp
+4
-0
viz.hpp
modules/viz/include/opencv2/viz.hpp
+1
-2
types.hpp
modules/viz/include/opencv2/viz/types.hpp
+20
-2
interactor_style.cpp
modules/viz/src/interactor_style.cpp
+0
-0
interactor_style.h
modules/viz/src/interactor_style.h
+9
-22
precomp.hpp
modules/viz/src/precomp.hpp
+4
-3
types.cpp
modules/viz/src/types.cpp
+0
-20
viz.cpp
modules/viz/src/viz.cpp
+38
-78
viz3d.cpp
modules/viz/src/viz3d.cpp
+1
-2
viz3d_impl.cpp
modules/viz/src/viz3d_impl.cpp
+4
-9
viz3d_impl.hpp
modules/viz/src/viz3d_impl.hpp
+2
-25
test_precomp.hpp
modules/viz/test/test_precomp.hpp
+2
-0
test_tutorial3.cpp
modules/viz/test/test_tutorial3.cpp
+86
-0
test_viz3d.cpp
modules/viz/test/test_viz3d.cpp
+11
-12
No files found.
apps/traincascade/HOGfeatures.cpp
View file @
bb4bf7a1
...
...
@@ -5,6 +5,7 @@
#include "cascadeclassifier.h"
using
namespace
std
;
using
namespace
cv
;
CvHOGFeatureParams
::
CvHOGFeatureParams
()
{
...
...
apps/traincascade/HOGfeatures.h
View file @
bb4bf7a1
...
...
@@ -20,23 +20,23 @@ class CvHOGEvaluator : public CvFeatureEvaluator
public
:
virtual
~
CvHOGEvaluator
()
{}
virtual
void
init
(
const
CvFeatureParams
*
_featureParams
,
int
_maxSampleCount
,
Size
_winSize
);
virtual
void
setImage
(
const
Mat
&
img
,
uchar
clsLabel
,
int
idx
);
int
_maxSampleCount
,
cv
::
Size
_winSize
);
virtual
void
setImage
(
const
cv
::
Mat
&
img
,
uchar
clsLabel
,
int
idx
);
virtual
float
operator
()(
int
varIdx
,
int
sampleIdx
)
const
;
virtual
void
writeFeatures
(
FileStorage
&
fs
,
const
Mat
&
featureMap
)
const
;
virtual
void
writeFeatures
(
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
)
const
;
protected
:
virtual
void
generateFeatures
();
virtual
void
integralHistogram
(
const
Mat
&
img
,
std
::
vector
<
Mat
>
&
histogram
,
Mat
&
norm
,
int
nbins
)
const
;
virtual
void
integralHistogram
(
const
cv
::
Mat
&
img
,
std
::
vector
<
cv
::
Mat
>
&
histogram
,
cv
::
Mat
&
norm
,
int
nbins
)
const
;
class
Feature
{
public
:
Feature
();
Feature
(
int
offset
,
int
x
,
int
y
,
int
cellW
,
int
cellH
);
float
calc
(
const
std
::
vector
<
Mat
>
&
_hists
,
const
Mat
&
_normSum
,
size_t
y
,
int
featComponent
)
const
;
void
write
(
FileStorage
&
fs
)
const
;
void
write
(
FileStorage
&
fs
,
int
varIdx
)
const
;
float
calc
(
const
std
::
vector
<
cv
::
Mat
>
&
_hists
,
const
cv
::
Mat
&
_normSum
,
size_t
y
,
int
featComponent
)
const
;
void
write
(
cv
::
FileStorage
&
fs
)
const
;
void
write
(
cv
::
FileStorage
&
fs
,
int
varIdx
)
const
;
Rect
rect
[
N_CELLS
];
//cells
cv
::
Rect
rect
[
N_CELLS
];
//cells
struct
{
...
...
@@ -45,8 +45,8 @@ protected:
};
std
::
vector
<
Feature
>
features
;
Mat
normSum
;
//for nomalization calculation (L1 or L2)
std
::
vector
<
Mat
>
hist
;
cv
::
Mat
normSum
;
//for nomalization calculation (L1 or L2)
std
::
vector
<
cv
::
Mat
>
hist
;
};
inline
float
CvHOGEvaluator
::
operator
()(
int
varIdx
,
int
sampleIdx
)
const
...
...
@@ -57,7 +57,7 @@ inline float CvHOGEvaluator::operator()(int varIdx, int sampleIdx) const
return
features
[
featureIdx
].
calc
(
hist
,
normSum
,
sampleIdx
,
componentIdx
);
}
inline
float
CvHOGEvaluator
::
Feature
::
calc
(
const
std
::
vector
<
Mat
>&
_hists
,
const
Mat
&
_normSum
,
size_t
y
,
int
featComponent
)
const
inline
float
CvHOGEvaluator
::
Feature
::
calc
(
const
std
::
vector
<
cv
::
Mat
>&
_hists
,
const
cv
::
Mat
&
_normSum
,
size_t
y
,
int
featComponent
)
const
{
float
normFactor
;
float
res
;
...
...
apps/traincascade/boost.cpp
View file @
bb4bf7a1
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
using
cv
::
Size
;
using
cv
::
Mat
;
using
cv
::
Point
;
using
cv
::
FileStorage
;
using
cv
::
Rect
;
using
cv
::
Ptr
;
using
cv
::
FileNode
;
using
cv
::
Mat_
;
using
cv
::
Range
;
using
cv
::
FileNodeIterator
;
using
cv
::
ParallelLoopBody
;
#include "boost.h"
#include "cascadeclassifier.h"
...
...
apps/traincascade/boost.h
View file @
bb4bf7a1
...
...
@@ -13,8 +13,8 @@ struct CvCascadeBoostParams : CvBoostParams
CvCascadeBoostParams
(
int
_boostType
,
float
_minHitRate
,
float
_maxFalseAlarm
,
double
_weightTrimRate
,
int
_maxDepth
,
int
_maxWeakCount
);
virtual
~
CvCascadeBoostParams
()
{}
void
write
(
FileStorage
&
fs
)
const
;
bool
read
(
const
FileNode
&
node
);
void
write
(
cv
::
FileStorage
&
fs
)
const
;
bool
read
(
const
cv
::
FileNode
&
node
);
virtual
void
printDefaults
()
const
;
virtual
void
printAttrs
()
const
;
virtual
bool
scanAttr
(
const
std
::
string
prmName
,
const
std
::
string
val
);
...
...
@@ -45,7 +45,7 @@ struct CvCascadeBoostTrainData : CvDTreeTrainData
virtual
void
free_train_data
();
const
CvFeatureEvaluator
*
featureEvaluator
;
Mat
valCache
;
// precalculated feature values (CV_32FC1)
cv
::
Mat
valCache
;
// precalculated feature values (CV_32FC1)
CvMat
_resp
;
// for casting
int
numPrecalcVal
,
numPrecalcIdx
;
};
...
...
@@ -54,9 +54,9 @@ class CvCascadeBoostTree : public CvBoostTree
{
public
:
virtual
CvDTreeNode
*
predict
(
int
sampleIdx
)
const
;
void
write
(
FileStorage
&
fs
,
const
Mat
&
featureMap
);
void
read
(
const
FileNode
&
node
,
CvBoost
*
_ensemble
,
CvDTreeTrainData
*
_data
);
void
markFeaturesInMap
(
Mat
&
featureMap
);
void
write
(
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
);
void
read
(
const
cv
::
FileNode
&
node
,
CvBoost
*
_ensemble
,
CvDTreeTrainData
*
_data
);
void
markFeaturesInMap
(
cv
::
Mat
&
featureMap
);
protected
:
virtual
void
split_node_data
(
CvDTreeNode
*
n
);
};
...
...
@@ -70,10 +70,10 @@ public:
virtual
float
predict
(
int
sampleIdx
,
bool
returnSum
=
false
)
const
;
float
getThreshold
()
const
{
return
threshold
;
}
void
write
(
FileStorage
&
fs
,
const
Mat
&
featureMap
)
const
;
bool
read
(
const
FileNode
&
node
,
const
CvFeatureEvaluator
*
_featureEvaluator
,
void
write
(
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
)
const
;
bool
read
(
const
cv
::
FileNode
&
node
,
const
CvFeatureEvaluator
*
_featureEvaluator
,
const
CvCascadeBoostParams
&
_params
);
void
markUsedFeaturesInMap
(
Mat
&
featureMap
);
void
markUsedFeaturesInMap
(
cv
::
Mat
&
featureMap
);
protected
:
virtual
bool
set_params
(
const
CvBoostParams
&
_params
);
virtual
void
update_weights
(
CvBoostTree
*
tree
);
...
...
apps/traincascade/cascadeclassifier.cpp
View file @
bb4bf7a1
...
...
@@ -4,6 +4,7 @@
#include <queue>
using
namespace
std
;
using
namespace
cv
;
static
const
char
*
stageTypes
[]
=
{
CC_BOOST
};
static
const
char
*
featureTypes
[]
=
{
CC_HAAR
,
CC_LBP
,
CC_HOG
};
...
...
apps/traincascade/cascadeclassifier.h
View file @
bb4bf7a1
...
...
@@ -72,8 +72,8 @@ public:
CvCascadeParams
();
CvCascadeParams
(
int
_stageType
,
int
_featureType
);
void
write
(
FileStorage
&
fs
)
const
;
bool
read
(
const
FileNode
&
node
);
void
write
(
cv
::
FileStorage
&
fs
)
const
;
bool
read
(
const
cv
::
FileNode
&
node
);
void
printDefaults
()
const
;
void
printAttrs
()
const
;
...
...
@@ -81,7 +81,7 @@ public:
int
stageType
;
int
featureType
;
Size
winSize
;
cv
::
Size
winSize
;
};
class
CvCascadeClassifier
...
...
@@ -104,20 +104,20 @@ private:
bool
updateTrainingSet
(
double
&
acceptanceRatio
);
int
fillPassedSamples
(
int
first
,
int
count
,
bool
isPositive
,
int64
&
consumed
);
void
writeParams
(
FileStorage
&
fs
)
const
;
void
writeStages
(
FileStorage
&
fs
,
const
Mat
&
featureMap
)
const
;
void
writeFeatures
(
FileStorage
&
fs
,
const
Mat
&
featureMap
)
const
;
bool
readParams
(
const
FileNode
&
node
);
bool
readStages
(
const
FileNode
&
node
);
void
writeParams
(
cv
::
FileStorage
&
fs
)
const
;
void
writeStages
(
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
)
const
;
void
writeFeatures
(
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
)
const
;
bool
readParams
(
const
cv
::
FileNode
&
node
);
bool
readStages
(
const
cv
::
FileNode
&
node
);
void
getUsedFeaturesIdxMap
(
Mat
&
featureMap
);
void
getUsedFeaturesIdxMap
(
cv
::
Mat
&
featureMap
);
CvCascadeParams
cascadeParams
;
Ptr
<
CvFeatureParams
>
featureParams
;
Ptr
<
CvCascadeBoostParams
>
stageParams
;
cv
::
Ptr
<
CvFeatureParams
>
featureParams
;
cv
::
Ptr
<
CvCascadeBoostParams
>
stageParams
;
Ptr
<
CvFeatureEvaluator
>
featureEvaluator
;
std
::
vector
<
Ptr
<
CvCascadeBoost
>
>
stageClassifiers
;
cv
::
Ptr
<
CvFeatureEvaluator
>
featureEvaluator
;
std
::
vector
<
cv
::
Ptr
<
CvCascadeBoost
>
>
stageClassifiers
;
CvCascadeImageReader
imgReader
;
int
numStages
,
curNumSamples
;
int
numPos
,
numNeg
;
...
...
apps/traincascade/features.cpp
View file @
bb4bf7a1
...
...
@@ -4,6 +4,7 @@
#include "cascadeclassifier.h"
using
namespace
std
;
using
namespace
cv
;
float
calcNormFactor
(
const
Mat
&
sum
,
const
Mat
&
sqSum
)
{
...
...
apps/traincascade/haarfeatures.cpp
View file @
bb4bf7a1
...
...
@@ -5,6 +5,7 @@
#include "cascadeclassifier.h"
using
namespace
std
;
using
namespace
cv
;
CvHaarFeatureParams
::
CvHaarFeatureParams
()
:
mode
(
BASIC
)
{
...
...
apps/traincascade/haarfeatures.h
View file @
bb4bf7a1
...
...
@@ -18,8 +18,8 @@ public:
CvHaarFeatureParams
(
int
_mode
);
virtual
void
init
(
const
CvFeatureParams
&
fp
);
virtual
void
write
(
FileStorage
&
fs
)
const
;
virtual
bool
read
(
const
FileNode
&
node
);
virtual
void
write
(
cv
::
FileStorage
&
fs
)
const
;
virtual
bool
read
(
const
cv
::
FileNode
&
node
);
virtual
void
printDefaults
()
const
;
virtual
void
printAttrs
()
const
;
...
...
@@ -32,11 +32,11 @@ class CvHaarEvaluator : public CvFeatureEvaluator
{
public
:
virtual
void
init
(
const
CvFeatureParams
*
_featureParams
,
int
_maxSampleCount
,
Size
_winSize
);
virtual
void
setImage
(
const
Mat
&
img
,
uchar
clsLabel
,
int
idx
);
int
_maxSampleCount
,
cv
::
Size
_winSize
);
virtual
void
setImage
(
const
cv
::
Mat
&
img
,
uchar
clsLabel
,
int
idx
);
virtual
float
operator
()(
int
featureIdx
,
int
sampleIdx
)
const
;
virtual
void
writeFeatures
(
FileStorage
&
fs
,
const
Mat
&
featureMap
)
const
;
void
writeFeature
(
FileStorage
&
fs
,
int
fi
)
const
;
// for old file fornat
virtual
void
writeFeatures
(
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
)
const
;
void
writeFeature
(
cv
::
FileStorage
&
fs
,
int
fi
)
const
;
// for old file fornat
protected
:
virtual
void
generateFeatures
();
...
...
@@ -48,13 +48,13 @@ protected:
int
x0
,
int
y0
,
int
w0
,
int
h0
,
float
wt0
,
int
x1
,
int
y1
,
int
w1
,
int
h1
,
float
wt1
,
int
x2
=
0
,
int
y2
=
0
,
int
w2
=
0
,
int
h2
=
0
,
float
wt2
=
0
.
0
F
);
float
calc
(
const
Mat
&
sum
,
const
Mat
&
tilted
,
size_t
y
)
const
;
void
write
(
FileStorage
&
fs
)
const
;
float
calc
(
const
cv
::
Mat
&
sum
,
const
cv
::
Mat
&
tilted
,
size_t
y
)
const
;
void
write
(
cv
::
FileStorage
&
fs
)
const
;
bool
tilted
;
struct
{
Rect
r
;
cv
::
Rect
r
;
float
weight
;
}
rect
[
CV_HAAR_FEATURE_MAX
];
...
...
@@ -65,9 +65,9 @@ protected:
};
std
::
vector
<
Feature
>
features
;
Mat
sum
;
/* sum images (each row represents image) */
Mat
tilted
;
/* tilted sum images (each row represents image) */
Mat
normfactor
;
/* normalization factor */
cv
::
Mat
sum
;
/* sum images (each row represents image) */
cv
::
Mat
tilted
;
/* tilted sum images (each row represents image) */
cv
::
Mat
normfactor
;
/* normalization factor */
};
inline
float
CvHaarEvaluator
::
operator
()(
int
featureIdx
,
int
sampleIdx
)
const
...
...
@@ -76,7 +76,7 @@ inline float CvHaarEvaluator::operator()(int featureIdx, int sampleIdx) const
return
!
nf
?
0
.
0
f
:
(
features
[
featureIdx
].
calc
(
sum
,
tilted
,
sampleIdx
)
/
nf
);
}
inline
float
CvHaarEvaluator
::
Feature
::
calc
(
const
Mat
&
_sum
,
const
Mat
&
_tilted
,
size_t
y
)
const
inline
float
CvHaarEvaluator
::
Feature
::
calc
(
const
cv
::
Mat
&
_sum
,
const
cv
::
Mat
&
_tilted
,
size_t
y
)
const
{
const
int
*
img
=
tilted
?
_tilted
.
ptr
<
int
>
((
int
)
y
)
:
_sum
.
ptr
<
int
>
((
int
)
y
);
float
ret
=
rect
[
0
].
weight
*
(
img
[
fastRect
[
0
].
p0
]
-
img
[
fastRect
[
0
].
p1
]
-
img
[
fastRect
[
0
].
p2
]
+
img
[
fastRect
[
0
].
p3
]
)
+
...
...
apps/traincascade/imagestorage.cpp
View file @
bb4bf7a1
...
...
@@ -8,6 +8,7 @@
#include <fstream>
using
namespace
std
;
using
namespace
cv
;
bool
CvCascadeImageReader
::
create
(
const
string
_posFilename
,
const
string
_negFilename
,
Size
_winSize
)
{
...
...
apps/traincascade/imagestorage.h
View file @
bb4bf7a1
...
...
@@ -3,15 +3,15 @@
#include "highgui.h"
using
namespace
cv
;
class
CvCascadeImageReader
{
public
:
bool
create
(
const
std
::
string
_posFilename
,
const
std
::
string
_negFilename
,
Size
_winSize
);
bool
create
(
const
std
::
string
_posFilename
,
const
std
::
string
_negFilename
,
cv
::
Size
_winSize
);
void
restart
()
{
posReader
.
restart
();
}
bool
getNeg
(
Mat
&
_img
)
{
return
negReader
.
get
(
_img
);
}
bool
getPos
(
Mat
&
_img
)
{
return
posReader
.
get
(
_img
);
}
bool
getNeg
(
cv
::
Mat
&
_img
)
{
return
negReader
.
get
(
_img
);
}
bool
getPos
(
cv
::
Mat
&
_img
)
{
return
posReader
.
get
(
_img
);
}
private
:
class
PosReader
...
...
@@ -20,7 +20,7 @@ private:
PosReader
();
virtual
~
PosReader
();
bool
create
(
const
std
::
string
_filename
);
bool
get
(
Mat
&
_img
);
bool
get
(
cv
::
Mat
&
_img
);
void
restart
();
short
*
vec
;
...
...
@@ -35,18 +35,18 @@ private:
{
public
:
NegReader
();
bool
create
(
const
std
::
string
_filename
,
Size
_winSize
);
bool
get
(
Mat
&
_img
);
bool
create
(
const
std
::
string
_filename
,
cv
::
Size
_winSize
);
bool
get
(
cv
::
Mat
&
_img
);
bool
nextImg
();
Mat
src
,
img
;
cv
::
Mat
src
,
img
;
std
::
vector
<
std
::
string
>
imgFilenames
;
Point
offset
,
point
;
cv
::
Point
offset
,
point
;
float
scale
;
float
scaleFactor
;
float
stepFactor
;
size_t
last
,
round
;
Size
winSize
;
cv
::
Size
winSize
;
}
negReader
;
};
...
...
apps/traincascade/lbpfeatures.cpp
View file @
bb4bf7a1
...
...
@@ -4,6 +4,8 @@
#include "lbpfeatures.h"
#include "cascadeclassifier.h"
using
namespace
cv
;
CvLBPFeatureParams
::
CvLBPFeatureParams
()
{
maxCatCount
=
256
;
...
...
apps/traincascade/lbpfeatures.h
View file @
bb4bf7a1
...
...
@@ -15,11 +15,11 @@ class CvLBPEvaluator : public CvFeatureEvaluator
public
:
virtual
~
CvLBPEvaluator
()
{}
virtual
void
init
(
const
CvFeatureParams
*
_featureParams
,
int
_maxSampleCount
,
Size
_winSize
);
virtual
void
setImage
(
const
Mat
&
img
,
uchar
clsLabel
,
int
idx
);
int
_maxSampleCount
,
cv
::
Size
_winSize
);
virtual
void
setImage
(
const
cv
::
Mat
&
img
,
uchar
clsLabel
,
int
idx
);
virtual
float
operator
()(
int
featureIdx
,
int
sampleIdx
)
const
{
return
(
float
)
features
[
featureIdx
].
calc
(
sum
,
sampleIdx
);
}
virtual
void
writeFeatures
(
FileStorage
&
fs
,
const
Mat
&
featureMap
)
const
;
virtual
void
writeFeatures
(
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
)
const
;
protected
:
virtual
void
generateFeatures
();
...
...
@@ -28,18 +28,18 @@ protected:
public
:
Feature
();
Feature
(
int
offset
,
int
x
,
int
y
,
int
_block_w
,
int
_block_h
);
uchar
calc
(
const
Mat
&
_sum
,
size_t
y
)
const
;
void
write
(
FileStorage
&
fs
)
const
;
uchar
calc
(
const
cv
::
Mat
&
_sum
,
size_t
y
)
const
;
void
write
(
cv
::
FileStorage
&
fs
)
const
;
Rect
rect
;
cv
::
Rect
rect
;
int
p
[
16
];
};
std
::
vector
<
Feature
>
features
;
Mat
sum
;
cv
::
Mat
sum
;
};
inline
uchar
CvLBPEvaluator
::
Feature
::
calc
(
const
Mat
&
_sum
,
size_t
y
)
const
inline
uchar
CvLBPEvaluator
::
Feature
::
calc
(
const
cv
::
Mat
&
_sum
,
size_t
y
)
const
{
const
int
*
psum
=
_sum
.
ptr
<
int
>
((
int
)
y
);
int
cval
=
psum
[
p
[
5
]]
-
psum
[
p
[
6
]]
-
psum
[
p
[
9
]]
+
psum
[
p
[
10
]];
...
...
apps/traincascade/traincascade.cpp
View file @
bb4bf7a1
...
...
@@ -4,6 +4,7 @@
#include "cascadeclassifier.h"
using
namespace
std
;
using
namespace
cv
;
int
main
(
int
argc
,
char
*
argv
[]
)
{
...
...
apps/traincascade/traincascade_features.h
View file @
bb4bf7a1
...
...
@@ -30,13 +30,13 @@
(p3) = (rect).x + (rect).width - (rect).height \
+ (step) * ((rect).y + (rect).width + (rect).height);
float
calcNormFactor
(
const
Mat
&
sum
,
const
Mat
&
sqSum
);
float
calcNormFactor
(
const
cv
::
Mat
&
sum
,
const
cv
::
Mat
&
sqSum
);
template
<
class
Feature
>
void
_writeFeatures
(
const
std
::
vector
<
Feature
>
features
,
FileStorage
&
fs
,
const
Mat
&
featureMap
)
void
_writeFeatures
(
const
std
::
vector
<
Feature
>
features
,
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
)
{
fs
<<
FEATURES
<<
"["
;
const
Mat_
<
int
>&
featureMap_
=
(
const
Mat_
<
int
>&
)
featureMap
;
const
cv
::
Mat_
<
int
>&
featureMap_
=
(
const
cv
::
Mat_
<
int
>&
)
featureMap
;
for
(
int
fi
=
0
;
fi
<
featureMap
.
cols
;
fi
++
)
if
(
featureMap_
(
0
,
fi
)
>=
0
)
{
...
...
@@ -53,8 +53,8 @@ public:
CvParams
();
virtual
~
CvParams
()
{}
// from|to file
virtual
void
write
(
FileStorage
&
fs
)
const
=
0
;
virtual
bool
read
(
const
FileNode
&
node
)
=
0
;
virtual
void
write
(
cv
::
FileStorage
&
fs
)
const
=
0
;
virtual
bool
read
(
const
cv
::
FileNode
&
node
)
=
0
;
// from|to screen
virtual
void
printDefaults
()
const
;
virtual
void
printAttrs
()
const
;
...
...
@@ -68,9 +68,9 @@ public:
enum
{
HAAR
=
0
,
LBP
=
1
,
HOG
=
2
};
CvFeatureParams
();
virtual
void
init
(
const
CvFeatureParams
&
fp
);
virtual
void
write
(
FileStorage
&
fs
)
const
;
virtual
bool
read
(
const
FileNode
&
node
);
static
Ptr
<
CvFeatureParams
>
create
(
int
featureType
);
virtual
void
write
(
cv
::
FileStorage
&
fs
)
const
;
virtual
bool
read
(
const
cv
::
FileNode
&
node
);
static
cv
::
Ptr
<
CvFeatureParams
>
create
(
int
featureType
);
int
maxCatCount
;
// 0 in case of numerical features
int
featSize
;
// 1 in case of simple features (HAAR, LBP) and N_BINS(9)*N_CELLS(4) in case of Dalal's HOG features
};
...
...
@@ -80,25 +80,25 @@ class CvFeatureEvaluator
public
:
virtual
~
CvFeatureEvaluator
()
{}
virtual
void
init
(
const
CvFeatureParams
*
_featureParams
,
int
_maxSampleCount
,
Size
_winSize
);
virtual
void
setImage
(
const
Mat
&
img
,
uchar
clsLabel
,
int
idx
);
virtual
void
writeFeatures
(
FileStorage
&
fs
,
const
Mat
&
featureMap
)
const
=
0
;
int
_maxSampleCount
,
cv
::
Size
_winSize
);
virtual
void
setImage
(
const
cv
::
Mat
&
img
,
uchar
clsLabel
,
int
idx
);
virtual
void
writeFeatures
(
cv
::
FileStorage
&
fs
,
const
cv
::
Mat
&
featureMap
)
const
=
0
;
virtual
float
operator
()(
int
featureIdx
,
int
sampleIdx
)
const
=
0
;
static
Ptr
<
CvFeatureEvaluator
>
create
(
int
type
);
static
cv
::
Ptr
<
CvFeatureEvaluator
>
create
(
int
type
);
int
getNumFeatures
()
const
{
return
numFeatures
;
}
int
getMaxCatCount
()
const
{
return
featureParams
->
maxCatCount
;
}
int
getFeatureSize
()
const
{
return
featureParams
->
featSize
;
}
const
Mat
&
getCls
()
const
{
return
cls
;
}
const
cv
::
Mat
&
getCls
()
const
{
return
cls
;
}
float
getCls
(
int
si
)
const
{
return
cls
.
at
<
float
>
(
si
,
0
);
}
protected
:
virtual
void
generateFeatures
()
=
0
;
int
npos
,
nneg
;
int
numFeatures
;
Size
winSize
;
cv
::
Size
winSize
;
CvFeatureParams
*
featureParams
;
Mat
cls
;
cv
::
Mat
cls
;
};
#endif
modules/highgui/src/cap_openni.cpp
View file @
bb4bf7a1
...
...
@@ -105,7 +105,9 @@ public:
context
(
_context
),
depthGenerator
(
_depthGenerator
),
imageGenerator
(
_imageGenerator
),
maxBufferSize
(
_maxBufferSize
),
isCircleBuffer
(
_isCircleBuffer
),
maxTimeDuration
(
_maxTimeDuration
)
{
#ifdef HAVE_TBB
task
=
0
;
#endif
CV_Assert
(
depthGenerator
.
IsValid
()
);
CV_Assert
(
imageGenerator
.
IsValid
()
);
...
...
@@ -150,7 +152,7 @@ public:
task
=
new
(
tbb
::
task
::
allocate_root
()
)
TBBApproximateSynchronizerTask
(
*
this
);
tbb
::
task
::
enqueue
(
*
task
);
#else
task
=
new
ApproximateSynchronizer
(
*
this
);
task
->
reset
(
new
ApproximateSynchronizer
(
*
this
)
);
#endif
}
...
...
@@ -171,6 +173,9 @@ public:
xn
::
ImageGenerator
&
imageGenerator
;
private
:
ApproximateSyncGrabber
(
const
ApproximateSyncGrabber
&
);
ApproximateSyncGrabber
&
operator
=
(
const
ApproximateSyncGrabber
&
);
int
maxBufferSize
;
bool
isCircleBuffer
;
int
maxTimeDuration
;
...
...
@@ -214,7 +219,7 @@ private:
virtual
bool
grab
(
xn
::
DepthMetaData
&
depthMetaData
,
xn
::
ImageMetaData
&
imageMetaData
)
{
while
(
1
)
for
(;;
)
{
if
(
!
isDepthFilled
)
isDepthFilled
=
popDepthMetaData
(
depth
);
...
...
@@ -951,7 +956,7 @@ double CvCapture_OpenNI::getDepthGeneratorProperty( int propIdx )
propValue
=
depthGenerator
.
GetAlternativeViewPointCap
().
IsViewPointAs
(
imageGenerator
)
?
1.0
:
0.0
;
break
;
case
CV_CAP_PROP_POS_MSEC
:
propValue
=
depthGenerator
.
GetTimestamp
();
propValue
=
(
double
)
depthGenerator
.
GetTimestamp
();
break
;
case
CV_CAP_PROP_POS_FRAMES
:
propValue
=
depthGenerator
.
GetFrameID
();
...
...
@@ -1039,7 +1044,7 @@ double CvCapture_OpenNI::getImageGeneratorProperty( int propIdx )
propValue
=
mode
.
nFPS
;
break
;
case
CV_CAP_PROP_POS_MSEC
:
propValue
=
imageGenerator
.
GetTimestamp
();
propValue
=
(
double
)
imageGenerator
.
GetTimestamp
();
break
;
case
CV_CAP_PROP_POS_FRAMES
:
propValue
=
imageGenerator
.
GetFrameID
();
...
...
modules/objdetect/src/erfilter.cpp
View file @
bb4bf7a1
...
...
@@ -43,9 +43,13 @@
#include "precomp.hpp"
#include <fstream>
#ifndef INT32_MAX
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#if defined _MSC_VER && _MSC_VER == 1500
typedef
int
int_fast32_t
;
#else
#ifndef INT32_MAX
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#endif
#endif
using
namespace
std
;
...
...
modules/photo/test/test_hdr.cpp
View file @
bb4bf7a1
...
...
@@ -40,9 +40,6 @@
//M*/
#include "test_precomp.hpp"
#include <string>
#include <algorithm>
#include <fstream>
using
namespace
cv
;
using
namespace
std
;
...
...
modules/photo/test/test_precomp.hpp
View file @
bb4bf7a1
...
...
@@ -13,5 +13,9 @@
#include "opencv2/ts.hpp"
#include "opencv2/photo.hpp"
#include "opencv2/highgui.hpp"
#include <string>
#include <algorithm>
#include <fstream>
#include <ctime>
#endif
modules/viz/include/opencv2/viz.hpp
View file @
bb4bf7a1
...
...
@@ -108,10 +108,9 @@ namespace cv
void
remove
(
const
String
&
window_name
);
static
VizAccessor
*
instance_
;
static
bool
is_instantiated_
;
struct
VizAccessorImpl
;
static
VizAccessorImpl
*
impl_
;
VizAccessorImpl
*
impl_
;
friend
class
Viz3d
;
};
...
...
modules/viz/include/opencv2/viz/types.hpp
View file @
bb4bf7a1
...
...
@@ -57,7 +57,7 @@ namespace cv
{
namespace
viz
{
class
C
V_EXPORTS
C
olor
:
public
Scalar
class
Color
:
public
Scalar
{
public
:
Color
();
...
...
@@ -169,8 +169,26 @@ namespace cv
Vec2f
principal_point_
;
Vec2f
focal_
;
};
}
/* namespace viz */
}
/* namespace cv */
//////////////////////////////////////////////////////////////////////////////////////////////////////
/// cv::viz::Color
inline
cv
::
viz
::
Color
::
Color
()
:
Scalar
(
0
,
0
,
0
)
{}
inline
cv
::
viz
::
Color
::
Color
(
double
gray
)
:
Scalar
(
gray
,
gray
,
gray
)
{}
inline
cv
::
viz
::
Color
::
Color
(
double
blue
,
double
green
,
double
red
)
:
Scalar
(
blue
,
green
,
red
)
{}
inline
cv
::
viz
::
Color
::
Color
(
const
Scalar
&
color
)
:
Scalar
(
color
)
{}
inline
cv
::
viz
::
Color
cv
::
viz
::
Color
::
black
()
{
return
Color
(
0
,
0
,
0
);
}
inline
cv
::
viz
::
Color
cv
::
viz
::
Color
::
green
()
{
return
Color
(
0
,
255
,
0
);
}
inline
cv
::
viz
::
Color
cv
::
viz
::
Color
::
blue
()
{
return
Color
(
255
,
0
,
0
);
}
inline
cv
::
viz
::
Color
cv
::
viz
::
Color
::
cyan
()
{
return
Color
(
255
,
255
,
0
);
}
inline
cv
::
viz
::
Color
cv
::
viz
::
Color
::
red
()
{
return
Color
(
0
,
0
,
255
);
}
inline
cv
::
viz
::
Color
cv
::
viz
::
Color
::
yellow
()
{
return
Color
(
0
,
255
,
255
);
}
inline
cv
::
viz
::
Color
cv
::
viz
::
Color
::
magenta
()
{
return
Color
(
255
,
0
,
255
);
}
inline
cv
::
viz
::
Color
cv
::
viz
::
Color
::
white
()
{
return
Color
(
255
,
255
,
255
);
}
inline
cv
::
viz
::
Color
cv
::
viz
::
Color
::
gray
()
{
return
Color
(
128
,
128
,
128
);
}
#endif
modules/viz/src/interactor_style.cpp
View file @
bb4bf7a1
This diff is collapsed.
Click to expand it.
modules/viz/src/interactor_style.h
View file @
bb4bf7a1
...
...
@@ -49,8 +49,6 @@
#ifndef __OPENCV_VIZ_INTERACTOR_STYLE_H__
#define __OPENCV_VIZ_INTERACTOR_STYLE_H__
#include <opencv2/viz/types.hpp>
namespace
cv
{
namespace
viz
...
...
@@ -59,16 +57,9 @@ namespace cv
{
public
:
enum
KeyboardModifier
{
KB_MOD_ALT
,
KB_MOD_CTRL
,
KB_MOD_SHIFT
};
enum
KeyboardModifier
{
KB_MOD_ALT
,
KB_MOD_CTRL
,
KB_MOD_SHIFT
};
static
InteractorStyle
*
New
();
InteractorStyle
()
{}
virtual
~
InteractorStyle
()
{}
// this macro defines Superclass, the isA functionality and the safe downcast method
...
...
@@ -77,32 +68,24 @@ namespace cv
/** \brief Initialization routine. Must be called before anything else. */
virtual
void
Initialize
();
inline
void
setWidgetActorMap
(
const
Ptr
<
WidgetActorMap
>&
actors
)
{
widget_actor_map_
=
actors
;
}
void
setWidgetActorMap
(
const
Ptr
<
WidgetActorMap
>&
actors
)
{
widget_actor_map_
=
actors
;
}
void
setRenderer
(
vtkSmartPointer
<
vtkRenderer
>&
ren
)
{
renderer_
=
ren
;
}
void
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
saveScreenshot
(
const
std
::
s
tring
&
file
);
void
saveScreenshot
(
const
S
tring
&
file
);
/** \brief Change the default keyboard modified from ALT to a different special key.*/
inline
void
setKeyboardModifier
(
const
KeyboardModifier
&
modifier
)
{
modifier_
=
modifier
;
}
pr
otected
:
pr
ivate
:
/** \brief Set to true after initialization is complete. */
bool
init_
;
/** \brief Collection of vtkRenderers stored internally. */
vtkSmartPointer
<
vtkRenderer
>
renderer_
;
Ptr
<
WidgetActorMap
>
widget_actor_map_
;
/** \brief Actor map stored internally. */
cv
::
Ptr
<
WidgetActorMap
>
widget_actor_map_
;
/** \brief The current window width/height. */
Vec2i
win_size_
;
/** \brief The current window position x/y. */
Vec2i
win_pos_
;
/** \brief The maximum resizeable window width/height. */
Vec2i
max_win_size_
;
/** \brief A PNG writer for screenshot captures. */
...
...
@@ -145,6 +128,10 @@ namespace cv
void
(
*
mouseCallback_
)(
const
MouseEvent
&
,
void
*
);
void
*
mouse_callback_cookie_
;
bool
getAltKey
();
bool
getControlKey
();
bool
getShiftKey
();
};
}
}
...
...
modules/viz/src/precomp.hpp
View file @
bb4bf7a1
...
...
@@ -126,6 +126,9 @@
#endif
#include <opencv2/core.hpp>
#include <opencv2/viz.hpp>
#include <opencv2/viz/widget_accessor.hpp>
#include <opencv2/core/utility.hpp>
namespace
cv
{
...
...
@@ -135,6 +138,7 @@ namespace cv
}
}
#include "interactor_style.h"
#include "viz3d_impl.hpp"
namespace
cv
...
...
@@ -146,8 +150,5 @@ namespace cv
}
}
#include <opencv2/viz.hpp>
#include <opencv2/viz/types.hpp>
#include "opencv2/viz/widget_accessor.hpp"
#endif
modules/viz/src/types.cpp
View file @
bb4bf7a1
...
...
@@ -48,26 +48,6 @@
#include "precomp.hpp"
//////////////////////////////////////////////////////////////////////////////////////////////////////
/// cv::viz::Color
cv
::
viz
::
Color
::
Color
()
:
Scalar
(
0
,
0
,
0
)
{}
cv
::
viz
::
Color
::
Color
(
double
gray
)
:
Scalar
(
gray
,
gray
,
gray
)
{}
cv
::
viz
::
Color
::
Color
(
double
blue
,
double
green
,
double
red
)
:
Scalar
(
blue
,
green
,
red
)
{}
cv
::
viz
::
Color
::
Color
(
const
Scalar
&
color
)
:
Scalar
(
color
)
{}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
black
()
{
return
Color
(
0
,
0
,
0
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
green
()
{
return
Color
(
0
,
255
,
0
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
blue
()
{
return
Color
(
255
,
0
,
0
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
cyan
()
{
return
Color
(
255
,
255
,
0
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
red
()
{
return
Color
(
0
,
0
,
255
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
yellow
()
{
return
Color
(
0
,
255
,
255
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
magenta
()
{
return
Color
(
255
,
0
,
255
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
white
()
{
return
Color
(
255
,
255
,
255
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
gray
()
{
return
Color
(
128
,
128
,
128
);
}
////////////////////////////////////////////////////////////////////
/// cv::viz::KeyboardEvent
...
...
modules/viz/src/viz.cpp
View file @
bb4bf7a1
...
...
@@ -50,18 +50,9 @@
cv
::
Affine3f
cv
::
viz
::
makeTransformToGlobal
(
const
Vec3f
&
axis_x
,
const
Vec3f
&
axis_y
,
const
Vec3f
&
axis_z
,
const
Vec3f
&
origin
)
{
Affine3f
::
Mat3
R
;
R
.
val
[
0
]
=
axis_x
.
val
[
0
];
R
.
val
[
3
]
=
axis_x
.
val
[
1
];
R
.
val
[
6
]
=
axis_x
.
val
[
2
];
R
.
val
[
1
]
=
axis_y
.
val
[
0
];
R
.
val
[
4
]
=
axis_y
.
val
[
1
];
R
.
val
[
7
]
=
axis_y
.
val
[
2
];
R
.
val
[
2
]
=
axis_z
.
val
[
0
];
R
.
val
[
5
]
=
axis_z
.
val
[
1
];
R
.
val
[
8
]
=
axis_z
.
val
[
2
];
Affine3f
::
Mat3
R
(
axis_x
[
0
],
axis_y
[
0
],
axis_z
[
0
],
axis_x
[
1
],
axis_y
[
1
],
axis_z
[
1
],
axis_x
[
2
],
axis_y
[
2
],
axis_z
[
2
]);
return
Affine3f
(
R
,
origin
);
}
...
...
@@ -73,22 +64,7 @@ cv::Affine3f cv::viz::makeCameraPose(const Vec3f& position, const Vec3f& focal_p
Vec3f
u
=
normalize
(
y_dir
.
cross
(
n
));
Vec3f
v
=
n
.
cross
(
u
);
Matx44f
pose_mat
=
Matx44f
::
zeros
();
pose_mat
(
0
,
0
)
=
u
[
0
];
pose_mat
(
0
,
1
)
=
u
[
1
];
pose_mat
(
0
,
2
)
=
u
[
2
];
pose_mat
(
1
,
0
)
=
v
[
0
];
pose_mat
(
1
,
1
)
=
v
[
1
];
pose_mat
(
1
,
2
)
=
v
[
2
];
pose_mat
(
2
,
0
)
=
n
[
0
];
pose_mat
(
2
,
1
)
=
n
[
1
];
pose_mat
(
2
,
2
)
=
n
[
2
];
pose_mat
(
3
,
0
)
=
position
[
0
];
pose_mat
(
3
,
1
)
=
position
[
1
];
pose_mat
(
3
,
2
)
=
position
[
2
];
pose_mat
(
3
,
3
)
=
1.0
f
;
pose_mat
=
pose_mat
.
t
();
return
pose_mat
;
return
makeTransformToGlobal
(
u
,
v
,
n
,
position
);
}
vtkSmartPointer
<
vtkMatrix4x4
>
cv
::
viz
::
convertToVtkMatrix
(
const
cv
::
Matx44f
&
m
)
...
...
@@ -109,36 +85,31 @@ cv::Matx44f cv::viz::convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matr
return
m
;
}
namespace
cv
namespace
cv
{
namespace
viz
{
namespace
viz
template
<
typename
_Tp
>
Vec
<
_Tp
,
3
>*
vtkpoints_data
(
vtkSmartPointer
<
vtkPoints
>&
points
);
template
<>
Vec3f
*
vtkpoints_data
<
float
>
(
vtkSmartPointer
<
vtkPoints
>&
points
)
{
template
<
typename
_Tp
>
Vec
<
_Tp
,
3
>*
vtkpoints_data
(
vtkSmartPointer
<
vtkPoints
>&
points
);
template
<>
Vec3f
*
vtkpoints_data
<
float
>
(
vtkSmartPointer
<
vtkPoints
>&
points
)
{
CV_Assert
(
points
->
GetDataType
()
==
VTK_FLOAT
);
vtkDataArray
*
data
=
points
->
GetData
();
float
*
pointer
=
static_cast
<
vtkFloatArray
*>
(
data
)
->
GetPointer
(
0
);
return
reinterpret_cast
<
Vec3f
*>
(
pointer
);
}
template
<>
Vec3d
*
vtkpoints_data
<
double
>
(
vtkSmartPointer
<
vtkPoints
>&
points
)
{
CV_Assert
(
points
->
GetDataType
()
==
VTK_DOUBLE
);
vtkDataArray
*
data
=
points
->
GetData
();
double
*
pointer
=
static_cast
<
vtkDoubleArray
*>
(
data
)
->
GetPointer
(
0
);
return
reinterpret_cast
<
Vec3d
*>
(
pointer
);
}
CV_Assert
(
points
->
GetDataType
()
==
VTK_FLOAT
);
vtkDataArray
*
data
=
points
->
GetData
();
float
*
pointer
=
static_cast
<
vtkFloatArray
*>
(
data
)
->
GetPointer
(
0
);
return
reinterpret_cast
<
Vec3f
*>
(
pointer
);
}
}
template
<>
Vec3d
*
vtkpoints_data
<
double
>
(
vtkSmartPointer
<
vtkPoints
>&
points
)
{
CV_Assert
(
points
->
GetDataType
()
==
VTK_DOUBLE
);
vtkDataArray
*
data
=
points
->
GetData
();
double
*
pointer
=
static_cast
<
vtkDoubleArray
*>
(
data
)
->
GetPointer
(
0
);
return
reinterpret_cast
<
Vec3d
*>
(
pointer
);
}
}}
///////////////////////////////////////////////////////////////////////////////////////////////
/// Viz accessor implementation
cv
::
viz
::
VizAccessor
*
cv
::
viz
::
VizAccessor
::
instance_
=
0
;
bool
cv
::
viz
::
VizAccessor
::
is_instantiated_
=
false
;
cv
::
viz
::
VizAccessor
::
VizAccessorImpl
*
cv
::
viz
::
VizAccessor
::
impl_
=
0
;
struct
cv
::
viz
::
VizAccessor
::
VizAccessorImpl
{
...
...
@@ -146,33 +117,22 @@ struct cv::viz::VizAccessor::VizAccessorImpl
};
cv
::
viz
::
VizAccessor
::
VizAccessor
()
{
impl_
=
new
cv
::
viz
::
VizAccessor
::
VizAccessorImpl
;}
cv
::
viz
::
VizAccessor
::~
VizAccessor
()
{
if
(
impl_
)
{
delete
impl_
;
impl_
=
0
;
}
}
cv
::
viz
::
VizAccessor
::~
VizAccessor
()
{
delete
impl_
;
}
cv
::
viz
::
VizAccessor
&
cv
::
viz
::
VizAccessor
::
getInstance
()
{
if
(
!
is_instantiated_
)
{
if
(
!
instance_
)
instance_
=
new
VizAccessor
();
is_instantiated_
=
true
;
}
return
*
instance_
;
}
void
cv
::
viz
::
VizAccessor
::
release
()
{
if
(
i
s_instantiated
_
)
if
(
i
nstance
_
)
{
delete
instance_
;
instance_
=
0
;
is_instantiated_
=
false
;
}
}
...
...
@@ -183,18 +143,15 @@ cv::viz::Viz3d cv::viz::VizAccessor::get(const String & window_name)
generateWindowName
(
window_name
,
name
);
VizMap
::
iterator
vm_itr
=
impl_
->
viz_map
.
find
(
name
);
bool
exists
=
vm_itr
!=
impl_
->
viz_map
.
end
();
if
(
exists
)
return
vm_itr
->
second
;
else
return
Viz3d
(
window_name
);
return
vm_itr
!=
impl_
->
viz_map
.
end
()
?
vm_itr
->
second
:
Viz3d
(
window_name
);
}
void
cv
::
viz
::
VizAccessor
::
add
(
Viz3d
window
)
{
String
window_name
=
window
.
getWindowName
();
VizMap
::
iterator
vm_itr
=
impl_
->
viz_map
.
find
(
window_name
);
bool
exists
=
vm_itr
!=
impl_
->
viz_map
.
end
();
if
(
exists
)
return
;
impl_
->
viz_map
.
insert
(
VizPair
(
window_name
,
window
));
if
(
vm_itr
==
impl_
->
viz_map
.
end
())
impl_
->
viz_map
.
insert
(
VizPair
(
window_name
,
window
));
}
void
cv
::
viz
::
VizAccessor
::
remove
(
const
String
&
window_name
)
...
...
@@ -204,21 +161,24 @@ void cv::viz::VizAccessor::remove(const String &window_name)
generateWindowName
(
window_name
,
name
);
VizMap
::
iterator
vm_itr
=
impl_
->
viz_map
.
find
(
name
);
bool
exists
=
vm_itr
!=
impl_
->
viz_map
.
end
();
if
(
!
exists
)
return
;
impl_
->
viz_map
.
erase
(
vm_itr
);
if
(
vm_itr
!=
impl_
->
viz_map
.
end
())
impl_
->
viz_map
.
erase
(
vm_itr
);
}
void
cv
::
viz
::
VizAccessor
::
generateWindowName
(
const
String
&
window_name
,
String
&
output
)
{
output
=
"Viz"
;
// Already is Viz
if
(
window_name
==
output
)
return
;
if
(
window_name
==
output
)
return
;
String
prefixed
=
output
+
" - "
;
if
(
window_name
.
substr
(
0
,
prefixed
.
length
())
==
prefixed
)
output
=
window_name
;
// Already has "Viz - "
else
if
(
window_name
.
substr
(
0
,
output
.
length
())
==
output
)
output
=
prefixed
+
window_name
;
// Doesn't have prefix
else
output
=
(
window_name
==
""
?
output
:
prefixed
+
window_name
);
if
(
window_name
.
substr
(
0
,
prefixed
.
length
())
==
prefixed
)
output
=
window_name
;
// Already has "Viz - "
else
if
(
window_name
.
substr
(
0
,
output
.
length
())
==
output
)
output
=
prefixed
+
window_name
;
// Doesn't have prefix
else
output
=
(
window_name
==
""
?
output
:
prefixed
+
window_name
);
}
cv
::
viz
::
Viz3d
cv
::
viz
::
get
(
const
String
&
window_name
)
...
...
modules/viz/src/viz3d.cpp
View file @
bb4bf7a1
...
...
@@ -46,8 +46,7 @@
//
//M*/
#include <opencv2/viz/viz3d.hpp>
#include "viz3d_impl.hpp"
#include "precomp.hpp"
cv
::
viz
::
Viz3d
::
Viz3d
(
const
String
&
window_name
)
:
impl_
(
0
)
{
create
(
window_name
);
}
...
...
modules/viz/src/viz3d_impl.cpp
View file @
bb4bf7a1
...
...
@@ -47,10 +47,6 @@
//M*/
#include "precomp.hpp"
#include "viz3d_impl.hpp"
#include "opencv2/core/utility.hpp"
#include <vtkRenderWindowInteractor.h>
#if 1 || !defined __APPLE__
vtkRenderWindowInteractor
*
vtkRenderWindowInteractorFixNew
()
...
...
@@ -61,9 +57,7 @@ vtkRenderWindowInteractor* vtkRenderWindowInteractorFixNew()
/////////////////////////////////////////////////////////////////////////////////////////////
cv
::
viz
::
Viz3d
::
VizImpl
::
VizImpl
(
const
String
&
name
)
:
style_
(
vtkSmartPointer
<
cv
::
viz
::
InteractorStyle
>::
New
())
,
widget_actor_map_
(
new
WidgetActorMap
)
,
s_lastDone_
(
0.0
)
:
style_
(
vtkSmartPointer
<
cv
::
viz
::
InteractorStyle
>::
New
())
,
widget_actor_map_
(
new
WidgetActorMap
),
s_lastDone_
(
0.0
)
{
renderer_
=
vtkSmartPointer
<
vtkRenderer
>::
New
();
...
...
@@ -128,7 +122,8 @@ cv::viz::Viz3d::VizImpl::~VizImpl()
{
if
(
interactor_
)
interactor_
->
DestroyTimer
(
timer_id_
);
if
(
renderer_
)
renderer_
->
Clear
();
if
(
renderer_
)
renderer_
->
Clear
();
}
/////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -395,7 +390,7 @@ cv::viz::Camera cv::viz::Viz3d::VizImpl::getCamera() const
Size
window_size
(
renderer_
->
GetRenderWindow
()
->
GetSize
()[
0
],
renderer_
->
GetRenderWindow
()
->
GetSize
()[
1
]);
double
aspect_ratio
=
static_cast
<
double
>
(
window_size
.
width
)
/
static_cast
<
double
>
(
window_size
.
height
)
;
double
aspect_ratio
=
window_size
.
width
/
(
double
)
window_size
.
height
;
Matx44f
proj_matrix
=
convertToMatx
(
active_camera
.
GetProjectionTransformMatrix
(
aspect_ratio
,
-
1.0
f
,
1.0
f
));
Camera
camera
(
proj_matrix
,
window_size
);
...
...
modules/viz/src/viz3d_impl.hpp
View file @
bb4bf7a1
...
...
@@ -49,9 +49,6 @@
#ifndef __OPENCV_VIZ_VIZ3D_IMPL_HPP__
#define __OPENCV_VIZ_VIZ3D_IMPL_HPP__
#include <opencv2/viz.hpp>
#include "interactor_style.h"
struct
cv
::
viz
::
Viz3d
::
VizImpl
{
public
:
...
...
@@ -127,10 +124,7 @@ private:
struct
ExitMainLoopTimerCallback
:
public
vtkCommand
{
static
ExitMainLoopTimerCallback
*
New
()
{
return
new
ExitMainLoopTimerCallback
;
}
static
ExitMainLoopTimerCallback
*
New
()
{
return
new
ExitMainLoopTimerCallback
;
}
virtual
void
Execute
(
vtkObject
*
vtkNotUsed
(
caller
),
unsigned
long
event_id
,
void
*
call_data
)
{
if
(
event_id
!=
vtkCommand
::
TimerEvent
)
...
...
@@ -149,10 +143,7 @@ private:
struct
ExitCallback
:
public
vtkCommand
{
static
ExitCallback
*
New
()
{
return
new
ExitCallback
;
}
static
ExitCallback
*
New
()
{
return
new
ExitCallback
;
}
virtual
void
Execute
(
vtkObject
*
,
unsigned
long
event_id
,
void
*
)
{
if
(
event_id
==
vtkCommand
::
ExitEvent
)
...
...
@@ -191,21 +182,7 @@ private:
bool
removeActorFromRenderer
(
const
vtkSmartPointer
<
vtkProp
>
&
actor
);
/** \brief Internal method. Creates a vtk actor from a vtk polydata object.
* \param[in] data the vtk polydata object to create an actor for
* \param[out] actor the resultant vtk actor object
* \param[in] use_scalars set scalar properties to the mapper if it exists in the data. Default: true.
*/
void
createActorFromVTKDataSet
(
const
vtkSmartPointer
<
vtkDataSet
>
&
data
,
vtkSmartPointer
<
vtkLODActor
>
&
actor
,
bool
use_scalars
=
true
);
/** \brief Updates a set of cells (vtkIdTypeArray) if the number of points in a cloud changes
* \param[out] cells the vtkIdTypeArray object (set of cells) to update
* \param[out] initcells a previously saved set of cells. If the number of points in the current cloud is
* higher than the number of cells in \a cells, and initcells contains enough data, then a copy from it
* will be made instead of regenerating the entire array.
* \param[in] nr_points the number of points in the new cloud. This dictates how many cells we need to
* generate
*/
void
updateCells
(
vtkSmartPointer
<
vtkIdTypeArray
>
&
cells
,
vtkSmartPointer
<
vtkIdTypeArray
>
&
initcells
,
vtkIdType
nr_points
);
};
...
...
modules/viz/test/test_precomp.hpp
View file @
bb4bf7a1
...
...
@@ -60,6 +60,8 @@
#include "opencv2/ts.hpp"
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/viz.hpp>
#include <iostream>
#include <fstream>
...
...
modules/viz/test/test_tutorial3.cpp
0 → 100644
View file @
bb4bf7a1
#include "test_precomp.hpp"
using
namespace
cv
;
using
namespace
std
;
/**
* @function cvcloud_load
* @brief load bunny.ply
*/
Mat
cvcloud_load
()
{
Mat
cloud
(
1
,
20000
,
CV_32FC3
);
ifstream
ifs
(
"d:/cloud_dragon.ply"
);
string
str
;
for
(
size_t
i
=
0
;
i
<
12
;
++
i
)
getline
(
ifs
,
str
);
Point3f
*
data
=
cloud
.
ptr
<
cv
::
Point3f
>
();
//float dummy1, dummy2;
for
(
size_t
i
=
0
;
i
<
20000
;
++
i
)
ifs
>>
data
[
i
].
x
>>
data
[
i
].
y
>>
data
[
i
].
z
;
// >> dummy1 >> dummy2;
//cloud *= 5.0f;
return
cloud
;
}
/**
* @function main
*/
void
tutorial3
(
bool
camera_pov
)
{
/// Create a window
viz
::
Viz3d
myWindow
(
"Coordinate Frame"
);
/// Add coordinate axes
myWindow
.
showWidget
(
"Coordinate Widget"
,
viz
::
WCoordinateSystem
());
/// Let's assume camera has the following properties
Point3f
cam_pos
(
3.0
f
,
3.0
f
,
3.0
f
),
cam_focal_point
(
3.0
f
,
3.0
f
,
2.0
f
),
cam_y_dir
(
-
1.0
f
,
0.0
f
,
0.0
f
);
/// We can get the pose of the cam using makeCameraPose
Affine3f
cam_pose
=
viz
::
makeCameraPose
(
cam_pos
,
cam_focal_point
,
cam_y_dir
);
/// We can get the transformation matrix from camera coordinate system to global using
/// - makeTransformToGlobal. We need the axes of the camera
Affine3f
transform
=
viz
::
makeTransformToGlobal
(
Vec3f
(
0.0
f
,
-
1.0
f
,
0.0
f
),
Vec3f
(
-
1.0
f
,
0.0
f
,
0.0
f
),
Vec3f
(
0.0
f
,
0.0
f
,
-
1.0
f
),
cam_pos
);
/// Create a cloud widget.
Mat
bunny_cloud
=
cvcloud_load
();
viz
::
WCloud
cloud_widget
(
bunny_cloud
,
viz
::
Color
::
green
());
/// Pose of the widget in camera frame
Affine3f
cloud_pose
=
Affine3f
().
translate
(
Vec3f
(
0.0
f
,
0.0
f
,
3.0
f
));
/// Pose of the widget in global frame
Affine3f
cloud_pose_global
=
transform
*
cloud_pose
;
/// Visualize camera frame
if
(
!
camera_pov
)
{
viz
::
WCameraPosition
cpw
(
0.5
);
// Coordinate axes
viz
::
WCameraPosition
cpw_frustum
(
Vec2f
(
0.889484
,
0.523599
));
// Camera frustum
myWindow
.
showWidget
(
"CPW"
,
cpw
,
cam_pose
);
myWindow
.
showWidget
(
"CPW_FRUSTUM"
,
cpw_frustum
,
cam_pose
);
}
/// Visualize widget
myWindow
.
showWidget
(
"bunny"
,
cloud_widget
,
cloud_pose_global
);
/// Set the viewer pose to that of camera
if
(
camera_pov
)
myWindow
.
setViewerPose
(
cam_pose
);
/// Start event loop.
myWindow
.
spin
();
}
TEST
(
Viz_viz3d
,
DISABLED_tutorial3_global_view
)
{
tutorial3
(
false
);
}
TEST
(
Viz_viz3d
,
DISABLED_tutorial3_camera_view
)
{
tutorial3
(
true
);
}
modules/viz/test/test_viz3d.cpp
View file @
bb4bf7a1
...
...
@@ -40,13 +40,11 @@
//
//M*/
#include "test_precomp.hpp"
#include <opencv2/viz.hpp>
#include <opencv2/highgui.hpp>
#include <string>
using
namespace
cv
;
cv
::
Mat
cvcloud_load
()
static
cv
::
Mat
cvcloud_load
()
{
cv
::
Mat
cloud
(
1
,
20000
,
CV_32FC3
);
std
::
ifstream
ifs
(
"/Users/nerei/cloud_dragon.ply"
);
...
...
@@ -90,7 +88,7 @@ void keyboard_callback(const viz::KeyboardEvent & event, void * cookie)
}
}
TEST
(
Viz_viz3d
,
accuracy
)
TEST
(
Viz_viz3d
,
develop
)
{
cv
::
viz
::
Viz3d
viz
(
"abc"
);
...
...
@@ -98,19 +96,18 @@ TEST(Viz_viz3d, accuracy)
cv
::
viz
::
WMesh
bunny_widget
(
bunny_mesh
);
bunny_widget
.
setColor
(
cv
::
viz
::
Color
::
cyan
());
cam_1
=
cv
::
viz
::
WCameraPosition
(
cv
::
Vec2f
(
0.6
,
0.4
),
0.2
,
cv
::
viz
::
Color
::
green
());
cam_1
=
cv
::
viz
::
WCameraPosition
(
cv
::
Vec2f
(
0.6
f
,
0.4
f
),
0.2
,
cv
::
viz
::
Color
::
green
());
cam_coordinates
=
cv
::
viz
::
WCameraPosition
(
0.2
);
viz
.
showWidget
(
"bunny"
,
bunny_widget
);
viz
.
showWidget
(
"cam_1"
,
cam_1
,
viz
::
makeCameraPose
(
Point3f
(
1.
0
,
0.0
,
0.0
),
Point3f
(
0.0
,
0.0
,
0.0
),
Point3f
(
0.0
,
1.0
,
0.0
)));
viz
.
showWidget
(
"cam_coordinate"
,
cam_coordinates
,
viz
::
makeCameraPose
(
Point3f
(
1.
0
,
0.0
,
0.0
),
Point3f
(
0.0
,
0.0
,
0.0
),
Point3f
(
0.0
,
1.0
,
0.0
)));
viz
.
showWidget
(
"cam_1"
,
cam_1
,
viz
::
makeCameraPose
(
Point3f
(
1.
f
,
0.
f
,
0.
f
),
Point3f
(
0.
f
,
0.
f
,
0.
f
),
Point3f
(
0.
f
,
1.
f
,
0.
f
)));
viz
.
showWidget
(
"cam_coordinate"
,
cam_coordinates
,
viz
::
makeCameraPose
(
Point3f
(
1.
f
,
0.
f
,
0.
f
),
Point3f
(
0.
f
,
0.
f
,
0.
f
),
Point3f
(
0.
f
,
1.
f
,
0.
f
)));
std
::
vector
<
Affine3f
>
cam_path
;
for
(
int
i
=
0
,
j
=
0
;
i
<=
360
;
++
i
,
j
+=
5
)
{
cam_path
.
push_back
(
viz
::
makeCameraPose
(
Point3f
(
0.5
*
cos
(
double
(
i
)
*
CV_PI
/
180.0
),
0.5
*
sin
(
double
(
j
)
*
CV_PI
/
180.0
),
0.5
*
sin
(
double
(
i
)
*
CV_PI
/
180.0
)),
Point3f
(
0.0
,
0.0
,
0.0
),
Point3f
(
0.0
,
1.0
,
0.0
)));
cam_path
.
push_back
(
viz
::
makeCameraPose
(
Vec3d
(
0.5
*
cos
(
i
*
CV_PI
/
180.0
),
0.5
*
sin
(
j
*
CV_PI
/
180.0
),
0.5
*
sin
(
i
*
CV_PI
/
180.0
)),
Vec3f
(
0.
f
,
0.
f
,
0.
f
),
Vec3f
(
0.
f
,
1.
f
,
0.
f
)));
}
int
path_counter
=
0
;
...
...
@@ -133,7 +130,7 @@ TEST(Viz_viz3d, accuracy)
colors
[
col
]
=
Mat
::
zeros
(
img
.
rows
/
downSample
,
1
,
CV_8UC3
);
for
(
int
row
=
0
;
row
<
row_max
;
++
row
)
{
clouds
[
col
].
at
<
Vec3f
>
(
row
)
=
Vec3f
(
downSample
*
float
(
col
)
/
img
.
cols
,
1.
0
-
(
downSample
*
float
(
row
)
/
img
.
rows
),
0.0
);
clouds
[
col
].
at
<
Vec3f
>
(
row
)
=
Vec3f
(
downSample
*
float
(
col
)
/
img
.
cols
,
1.
f
-
(
downSample
*
float
(
row
)
/
img
.
rows
),
0.
f
);
colors
[
col
].
at
<
Vec3b
>
(
row
)
=
img
.
at
<
Vec3b
>
(
row
*
downSample
,
col
*
downSample
);
}
}
...
...
@@ -174,9 +171,11 @@ TEST(Viz_viz3d, accuracy)
{
std
::
stringstream
strstrm
;
strstrm
<<
"cloud_"
<<
i
;
viz
.
setWidgetPose
(
strstrm
.
str
(),
Affine3f
().
translate
(
Vec3f
(
-
0.5
,
0.0
,
-
0.7
+
0.2
*
sin
((
angle
+
i
*
10
)
*
CV_PI
/
180.0
))));
viz
.
setWidgetPose
(
strstrm
.
str
(),
Affine3f
().
translate
(
Vec3f
(
-
0.5
f
,
0.
f
,
(
float
)(
-
0.7
+
0.2
*
sin
((
angle
+
i
*
10
)
*
CV_PI
/
180.0
)
))));
}
angle
+=
10
;
viz
.
spinOnce
(
42
,
true
);
}
volatile
void
*
a
=
(
void
*
)
&
cvcloud_load
;
(
void
)
a
;
//fixing warnings
}
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