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
5e7ab8ba
Commit
5e7ab8ba
authored
Mar 27, 2013
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move cv::Scalar_ to types.hpp
parent
6ceca90c
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
131 additions
and
110 deletions
+131
-110
calibinit.cpp
modules/calib3d/src/calibinit.cpp
+8
-8
core.hpp
modules/core/include/opencv2/core.hpp
+0
-52
operations.hpp
modules/core/include/opencv2/core/operations.hpp
+4
-16
types.hpp
modules/core/include/opencv2/core/types.hpp
+62
-0
types_c.h
modules/core/include/opencv2/core/types_c.h
+16
-0
array.cpp
modules/core/src/array.cpp
+4
-4
test_math.cpp
modules/core/test/test_math.cpp
+1
-1
test_templmatch.cpp
modules/imgproc/test/test_templmatch.cpp
+2
-2
3dtracker.cpp
modules/legacy/src/3dtracker.cpp
+11
-9
calibfilter.cpp
modules/legacy/src/calibfilter.cpp
+7
-7
subdiv2.cpp
modules/legacy/src/subdiv2.cpp
+1
-1
cv2.cpp
modules/python/src2/cv2.cpp
+5
-0
find_obj.cpp
samples/c/find_obj.cpp
+10
-10
No files found.
modules/calib3d/src/calibinit.cpp
View file @
5e7ab8ba
...
...
@@ -1833,7 +1833,7 @@ cvDrawChessboardCorners( CvArr* _image, CvSize pattern_size,
if
(
!
found
)
{
CvScalar
color
=
{{
0
,
0
,
255
}}
;
CvScalar
color
(
0
,
0
,
255
,
0
)
;
if
(
cn
==
1
)
color
=
cvScalarAll
(
200
);
color
.
val
[
0
]
*=
scale
;
...
...
@@ -1860,13 +1860,13 @@ cvDrawChessboardCorners( CvArr* _image, CvSize pattern_size,
const
int
line_max
=
7
;
static
const
CvScalar
line_colors
[
line_max
]
=
{
{{
0
,
0
,
255
}}
,
{{
0
,
128
,
255
}}
,
{{
0
,
200
,
200
}}
,
{{
0
,
255
,
0
}}
,
{{
200
,
200
,
0
}}
,
{{
255
,
0
,
0
}}
,
{{
255
,
0
,
255
}}
CvScalar
(
0
,
0
,
255
)
,
CvScalar
(
0
,
128
,
255
)
,
CvScalar
(
0
,
200
,
200
)
,
CvScalar
(
0
,
255
,
0
)
,
CvScalar
(
200
,
200
,
0
)
,
CvScalar
(
255
,
0
,
0
)
,
CvScalar
(
255
,
0
,
255
)
};
for
(
y
=
0
,
i
=
0
;
y
<
pattern_size
.
height
;
y
++
)
...
...
modules/core/include/opencv2/core.hpp
View file @
5e7ab8ba
...
...
@@ -455,8 +455,6 @@ public:
Vec
cross
(
const
Vec
&
v
)
const
;
//! convertion to another data type
template
<
typename
T2
>
operator
Vec
<
T2
,
cn
>
()
const
;
//! conversion to 4-element CvScalar.
operator
CvScalar
()
const
;
/*! element access */
const
_Tp
&
operator
[](
int
i
)
const
;
...
...
@@ -503,43 +501,6 @@ typedef Vec<double, 4> Vec4d;
typedef
Vec
<
double
,
6
>
Vec6d
;
//////////////////////////////// Scalar_ ///////////////////////////////
/*!
The template scalar class.
This is partially specialized cv::Vec class with the number of elements = 4, i.e. a short vector of four elements.
Normally, cv::Scalar ~ cv::Scalar_<double> is used.
*/
template
<
typename
_Tp
>
class
CV_EXPORTS
Scalar_
:
public
Vec
<
_Tp
,
4
>
{
public
:
//! various constructors
Scalar_
();
Scalar_
(
_Tp
v0
,
_Tp
v1
,
_Tp
v2
=
0
,
_Tp
v3
=
0
);
Scalar_
(
const
CvScalar
&
s
);
Scalar_
(
_Tp
v0
);
//! returns a scalar with all elements set to v0
static
Scalar_
<
_Tp
>
all
(
_Tp
v0
);
//! conversion to the old-style CvScalar
operator
CvScalar
()
const
;
//! conversion to another data type
template
<
typename
T2
>
operator
Scalar_
<
T2
>
()
const
;
//! per-element product
Scalar_
<
_Tp
>
mul
(
const
Scalar_
<
_Tp
>&
t
,
double
scale
=
1
)
const
;
// returns (v0, -v1, -v2, -v3)
Scalar_
<
_Tp
>
conj
()
const
;
// returns true iff v1 == v2 == v3 == 0
bool
isReal
()
const
;
};
typedef
Scalar_
<
double
>
Scalar
;
CV_EXPORTS
void
scalarToRawData
(
const
Scalar
&
s
,
void
*
buf
,
int
type
,
int
unroll_to
=
0
);
...
...
@@ -570,19 +531,6 @@ public:
};
template
<
typename
_Tp
>
class
DataType
<
Scalar_
<
_Tp
>
>
{
public
:
typedef
Scalar_
<
_Tp
>
value_type
;
typedef
Scalar_
<
typename
DataType
<
_Tp
>::
work_type
>
work_type
;
typedef
_Tp
channel_type
;
enum
{
generic_type
=
0
,
depth
=
DataDepth
<
channel_type
>::
value
,
channels
=
4
,
fmt
=
((
channels
-
1
)
<<
8
)
+
DataDepth
<
channel_type
>::
fmt
,
type
=
CV_MAKETYPE
(
depth
,
channels
)
};
typedef
Vec
<
channel_type
,
channels
>
vec_type
;
};
//////////////////// generic_type ref-counting pointer class for C/C++ objects ////////////////////////
/*!
...
...
modules/core/include/opencv2/core/operations.hpp
View file @
5e7ab8ba
...
...
@@ -1171,15 +1171,6 @@ inline Vec<_Tp, cn>::operator Vec<T2, cn>() const
return
v
;
}
template
<
typename
_Tp
,
int
cn
>
inline
Vec
<
_Tp
,
cn
>::
operator
CvScalar
()
const
{
CvScalar
s
=
{{
0
,
0
,
0
,
0
}};
int
i
;
for
(
i
=
0
;
i
<
std
::
min
(
cn
,
4
);
i
++
)
s
.
val
[
i
]
=
this
->
val
[
i
];
for
(
;
i
<
4
;
i
++
)
s
.
val
[
i
]
=
0
;
return
s
;
}
template
<
typename
_Tp
,
int
cn
>
inline
const
_Tp
&
Vec
<
_Tp
,
cn
>::
operator
[](
int
i
)
const
{
CV_DbgAssert
(
(
unsigned
)
i
<
(
unsigned
)
cn
);
...
...
@@ -1894,12 +1885,11 @@ template<typename _Tp> inline Scalar_<_Tp>::Scalar_()
template
<
typename
_Tp
>
inline
Scalar_
<
_Tp
>::
Scalar_
(
_Tp
v0
,
_Tp
v1
,
_Tp
v2
,
_Tp
v3
)
{
this
->
val
[
0
]
=
v0
;
this
->
val
[
1
]
=
v1
;
this
->
val
[
2
]
=
v2
;
this
->
val
[
3
]
=
v3
;
}
template
<
typename
_Tp
>
inline
Scalar_
<
_Tp
>::
Scalar_
(
const
CvScalar
&
s
)
template
<
typename
_Tp
>
template
<
typename
_Tp2
,
int
cn
>
inline
Scalar_
<
_Tp
>::
Scalar_
(
const
Vec
<
_Tp2
,
cn
>&
v
)
{
this
->
val
[
0
]
=
saturate_cast
<
_Tp
>
(
s
.
val
[
0
]);
this
->
val
[
1
]
=
saturate_cast
<
_Tp
>
(
s
.
val
[
1
]);
this
->
val
[
2
]
=
saturate_cast
<
_Tp
>
(
s
.
val
[
2
]);
this
->
val
[
3
]
=
saturate_cast
<
_Tp
>
(
s
.
val
[
3
]);
int
i
;
for
(
i
=
0
;
i
<
(
cn
<
4
?
cn
:
4
);
i
++
)
this
->
val
[
i
]
=
cv
::
saturate_cast
<
_Tp
>
(
v
.
val
[
i
]);
for
(
;
i
<
4
;
i
++
)
this
->
val
[
i
]
=
0
;
}
template
<
typename
_Tp
>
inline
Scalar_
<
_Tp
>::
Scalar_
(
_Tp
v0
)
...
...
@@ -1907,8 +1897,6 @@ template<typename _Tp> inline Scalar_<_Tp>::Scalar_(_Tp v0)
template
<
typename
_Tp
>
inline
Scalar_
<
_Tp
>
Scalar_
<
_Tp
>::
all
(
_Tp
v0
)
{
return
Scalar_
<
_Tp
>
(
v0
,
v0
,
v0
,
v0
);
}
template
<
typename
_Tp
>
inline
Scalar_
<
_Tp
>::
operator
CvScalar
()
const
{
return
cvScalar
(
this
->
val
[
0
],
this
->
val
[
1
],
this
->
val
[
2
],
this
->
val
[
3
]);
}
template
<
typename
_Tp
>
template
<
typename
T2
>
inline
Scalar_
<
_Tp
>::
operator
Scalar_
<
T2
>
()
const
{
...
...
modules/core/include/opencv2/core/types.hpp
View file @
5e7ab8ba
...
...
@@ -521,6 +521,68 @@ public:
//////////////////////////////// Scalar_ ///////////////////////////////
/*!
The template scalar class.
This is partially specialized cv::Vec class with the number of elements = 4, i.e. a short vector of four elements.
Normally, cv::Scalar ~ cv::Scalar_<double> is used.
*/
template
<
typename
_Tp
>
class
CV_EXPORTS
Scalar_
:
public
Vec
<
_Tp
,
4
>
{
public
:
//! various constructors
Scalar_
();
Scalar_
(
_Tp
v0
,
_Tp
v1
,
_Tp
v2
=
0
,
_Tp
v3
=
0
);
Scalar_
(
_Tp
v0
);
template
<
typename
_Tp2
,
int
cn
>
Scalar_
(
const
Vec
<
_Tp2
,
cn
>&
v
);
//! returns a scalar with all elements set to v0
static
Scalar_
<
_Tp
>
all
(
_Tp
v0
);
//! conversion to another data type
template
<
typename
T2
>
operator
Scalar_
<
T2
>
()
const
;
//! per-element product
Scalar_
<
_Tp
>
mul
(
const
Scalar_
<
_Tp
>&
t
,
double
scale
=
1
)
const
;
// returns (v0, -v1, -v2, -v3)
Scalar_
<
_Tp
>
conj
()
const
;
// returns true iff v1 == v2 == v3 == 0
bool
isReal
()
const
;
};
/*!
\typedef
*/
typedef
Scalar_
<
double
>
Scalar
;
/*!
traits
*/
template
<
typename
_Tp
>
class
DataType
<
Scalar_
<
_Tp
>
>
{
public
:
typedef
Scalar_
<
_Tp
>
value_type
;
typedef
Scalar_
<
typename
DataType
<
_Tp
>::
work_type
>
work_type
;
typedef
_Tp
channel_type
;
enum
{
generic_type
=
0
,
depth
=
DataType
<
channel_type
>::
value
,
channels
=
4
,
fmt
=
DataType
<
channel_type
>::
fmt
+
((
channels
-
1
)
<<
8
),
type
=
CV_MAKETYPE
(
depth
,
channels
)
};
typedef
Vec
<
channel_type
,
channels
>
vec_type
;
};
/////////////////////////////// KeyPoint ////////////////////////////////
/*!
...
...
modules/core/include/opencv2/core/types_c.h
View file @
5e7ab8ba
...
...
@@ -1014,6 +1014,22 @@ CV_INLINE CvSlice cvSlice( int start, int end )
typedef
struct
CvScalar
{
double
val
[
4
];
#ifdef __cplusplus
CvScalar
()
{}
CvScalar
(
double
d0
,
double
d1
=
0
,
double
d2
=
0
,
double
d3
=
0
)
{
val
[
0
]
=
d0
;
val
[
1
]
=
d1
;
val
[
2
]
=
d2
;
val
[
3
]
=
d3
;
}
template
<
typename
_Tp
>
CvScalar
(
const
cv
::
Scalar_
<
_Tp
>&
s
)
{
val
[
0
]
=
s
.
val
[
0
];
val
[
1
]
=
s
.
val
[
1
];
val
[
2
]
=
s
.
val
[
2
];
val
[
3
]
=
s
.
val
[
3
];
}
template
<
typename
_Tp
>
operator
cv
::
Scalar_
<
_Tp
>
()
const
{
return
cv
::
Scalar_
<
_Tp
>
(
cv
::
saturate_cast
<
_Tp
>
(
val
[
0
]),
cv
::
saturate_cast
<
_Tp
>
(
val
[
1
]),
cv
::
saturate_cast
<
_Tp
>
(
val
[
2
]),
cv
::
saturate_cast
<
_Tp
>
(
val
[
3
]));
}
template
<
typename
_Tp
,
int
cn
>
CvScalar
(
const
cv
::
Vec
<
_Tp
,
cn
>&
v
)
{
int
i
;
for
(
i
=
0
;
i
<
(
cn
<
4
?
cn
:
4
);
i
++
)
val
[
i
]
=
v
.
val
[
i
];
for
(
;
i
<
4
;
i
++
)
val
[
i
]
=
0
;
}
#endif
}
CvScalar
;
...
...
modules/core/src/array.cpp
View file @
5e7ab8ba
...
...
@@ -1910,7 +1910,7 @@ cvPtrND( const CvArr* arr, const int* idx, int* _type,
CV_IMPL
CvScalar
cvGet1D
(
const
CvArr
*
arr
,
int
idx
)
{
CvScalar
scalar
=
{{
0
,
0
,
0
,
0
}}
;
CvScalar
scalar
(
0
)
;
int
type
=
0
;
uchar
*
ptr
;
...
...
@@ -1945,7 +1945,7 @@ cvGet1D( const CvArr* arr, int idx )
CV_IMPL
CvScalar
cvGet2D
(
const
CvArr
*
arr
,
int
y
,
int
x
)
{
CvScalar
scalar
=
{{
0
,
0
,
0
,
0
}}
;
CvScalar
scalar
(
0
)
;
int
type
=
0
;
uchar
*
ptr
;
...
...
@@ -1979,7 +1979,7 @@ cvGet2D( const CvArr* arr, int y, int x )
CV_IMPL
CvScalar
cvGet3D
(
const
CvArr
*
arr
,
int
z
,
int
y
,
int
x
)
{
CvScalar
scalar
=
{{
0
,
0
,
0
,
0
}}
;
CvScalar
scalar
(
0
)
;
int
type
=
0
;
uchar
*
ptr
;
...
...
@@ -2001,7 +2001,7 @@ cvGet3D( const CvArr* arr, int z, int y, int x )
CV_IMPL
CvScalar
cvGetND
(
const
CvArr
*
arr
,
const
int
*
idx
)
{
CvScalar
scalar
=
{{
0
,
0
,
0
,
0
}}
;
CvScalar
scalar
(
0
)
;
int
type
=
0
;
uchar
*
ptr
;
...
...
modules/core/test/test_math.cpp
View file @
5e7ab8ba
...
...
@@ -545,7 +545,7 @@ void Core_CrossProductTest::run_func()
void
Core_CrossProductTest
::
prepare_to_validation
(
int
)
{
CvScalar
a
=
{{
0
,
0
,
0
,
0
}},
b
=
{{
0
,
0
,
0
,
0
}},
c
=
{{
0
,
0
,
0
,
0
}}
;
CvScalar
a
(
0
),
b
(
0
),
c
(
0
)
;
if
(
test_mat
[
INPUT
][
0
].
rows
>
1
)
{
...
...
modules/imgproc/test/test_templmatch.cpp
View file @
5e7ab8ba
...
...
@@ -192,8 +192,8 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu
{
for
(
j
=
0
;
j
<
result
->
cols
;
j
++
)
{
CvScalar
a_sum
=
{{
0
,
0
,
0
,
0
}},
a_sum2
=
{{
0
,
0
,
0
,
0
}}
;
CvScalar
ccorr
=
{{
0
,
0
,
0
,
0
}}
;
CvScalar
a_sum
(
0
),
a_sum2
(
0
)
;
CvScalar
ccorr
(
0
)
;
double
value
=
0.
;
if
(
depth
==
CV_8U
)
...
...
modules/legacy/src/3dtracker.cpp
View file @
5e7ab8ba
...
...
@@ -322,16 +322,18 @@ static void DrawEtalon(IplImage *img, CvPoint2D32f *corners,
int
i
;
int
x
,
y
;
CvPoint
prev_pt
;
static
const
CvScalar
rgb_colors
[]
=
{
{{
0
,
0
,
255
}},
{{
0
,
128
,
255
}},
{{
0
,
200
,
200
}},
{{
0
,
255
,
0
}},
{{
200
,
200
,
0
}},
{{
255
,
0
,
0
}},
{{
255
,
0
,
255
}}
};
static
const
CvScalar
rgb_colors
[]
=
{
CvScalar
(
0
,
0
,
255
),
CvScalar
(
0
,
128
,
255
),
CvScalar
(
0
,
200
,
200
),
CvScalar
(
0
,
255
,
0
),
CvScalar
(
200
,
200
,
0
),
CvScalar
(
255
,
0
,
0
),
CvScalar
(
255
,
0
,
255
)
};
static
const
CvScalar
gray_colors
[]
=
{
{{
80
}},
{{
120
}},
{{
160
}},
{{
200
}},
{{
100
}},
{{
140
}},
{{
180
}}
CvScalar
(
80
),
CvScalar
(
120
),
CvScalar
(
160
),
CvScalar
(
200
),
CvScalar
(
100
),
CvScalar
(
140
),
CvScalar
(
180
)
};
const
CvScalar
*
colors
=
img
->
nChannels
==
3
?
rgb_colors
:
gray_colors
;
...
...
modules/legacy/src/calibfilter.cpp
View file @
5e7ab8ba
...
...
@@ -546,13 +546,13 @@ void CvCalibFilter::DrawPoints( CvMat** dstarr )
static
const
CvScalar
line_colors
[]
=
{
{{
0
,
0
,
255
}}
,
{{
0
,
128
,
255
}}
,
{{
0
,
200
,
200
}}
,
{{
0
,
255
,
0
}}
,
{{
200
,
200
,
0
}}
,
{{
255
,
0
,
0
}}
,
{{
255
,
0
,
255
}}
CvScalar
(
0
,
0
,
255
)
,
CvScalar
(
0
,
128
,
255
)
,
CvScalar
(
0
,
200
,
200
)
,
CvScalar
(
0
,
255
,
0
)
,
CvScalar
(
200
,
200
,
0
)
,
CvScalar
(
255
,
0
,
0
)
,
CvScalar
(
255
,
0
,
255
)
};
const
int
colorCount
=
sizeof
(
line_colors
)
/
sizeof
(
line_colors
[
0
]);
...
...
modules/legacy/src/subdiv2.cpp
View file @
5e7ab8ba
...
...
@@ -833,7 +833,7 @@ draw_subdiv_facet( CvSubdiv2D * subdiv, IplImage * dst, IplImage * src, CvSubdiv
{
CvSubdiv2DPoint
*
pt
=
cvSubdiv2DEdgeDst
(
cvSubdiv2DRotateEdge
(
edge
,
1
));
CvPoint
ip
=
cvPoint
(
cvRound
(
pt
->
pt
.
x
),
cvRound
(
pt
->
pt
.
y
));
CvScalar
color
=
{{
0
,
0
,
0
,
0
}}
;
CvScalar
color
(
0
)
;
//printf("count = %d, (%d,%d)\n", ip.x, ip.y );
...
...
modules/python/src2/cv2.cpp
View file @
5e7ab8ba
...
...
@@ -684,6 +684,11 @@ static inline PyObject* pyopencv_from(const Vec3d& v)
return
Py_BuildValue
(
"(ddd)"
,
v
[
0
],
v
[
1
],
v
[
2
]);
}
static
inline
PyObject
*
pyopencv_from
(
const
Vec2d
&
v
)
{
return
Py_BuildValue
(
"(dd)"
,
v
[
0
],
v
[
1
]);
}
static
inline
PyObject
*
pyopencv_from
(
const
Point2d
&
p
)
{
return
Py_BuildValue
(
"(dd)"
,
p
.
x
,
p
.
y
);
...
...
samples/c/find_obj.cpp
View file @
5e7ab8ba
...
...
@@ -231,17 +231,17 @@ int main(int argc, char** argv)
cvNamedWindow
(
"Object"
,
1
);
cvNamedWindow
(
"Object Correspond"
,
1
);
static
Cv
Scalar
colors
[]
=
static
cv
::
Scalar
colors
[]
=
{
{{
0
,
0
,
255
}}
,
{{
0
,
128
,
255
}}
,
{{
0
,
255
,
255
}}
,
{{
0
,
255
,
0
}}
,
{{
255
,
128
,
0
}}
,
{{
255
,
255
,
0
}}
,
{{
255
,
0
,
0
}}
,
{{
255
,
0
,
255
}}
,
{{
255
,
255
,
255
}}
cv
::
Scalar
(
0
,
0
,
255
)
,
cv
::
Scalar
(
0
,
128
,
255
)
,
cv
::
Scalar
(
0
,
255
,
255
)
,
cv
::
Scalar
(
0
,
255
,
0
)
,
cv
::
Scalar
(
255
,
128
,
0
)
,
cv
::
Scalar
(
255
,
255
,
0
)
,
cv
::
Scalar
(
255
,
0
,
0
)
,
cv
::
Scalar
(
255
,
0
,
255
)
,
cv
::
Scalar
(
255
,
255
,
255
)
};
IplImage
*
object_color
=
cvCreateImage
(
cvGetSize
(
object
),
8
,
3
);
...
...
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