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
2c1b4f57
Commit
2c1b4f57
authored
7 years ago
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9795 from IgWod:refactor-scalar-to-raw-data
parents
d25ee8a2
ffb95547
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
50 deletions
+17
-50
matrix.cpp
modules/core/src/matrix.cpp
+17
-50
No files found.
modules/core/src/matrix.cpp
View file @
2c1b4f57
...
...
@@ -1140,78 +1140,45 @@ int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) con
?
(
int
)(
total
()
*
channels
()
/
_elemChannels
)
:
-
1
;
}
template
<
typename
T
>
static
inline
void
scalarToRawData
(
const
Scalar
&
s
,
T
*
const
buf
,
const
int
cn
,
const
int
unroll_to
)
{
int
i
=
0
;
for
(;
i
<
cn
;
i
++
)
buf
[
i
]
=
saturate_cast
<
T
>
(
s
.
val
[
i
]);
for
(;
i
<
unroll_to
;
i
++
)
buf
[
i
]
=
buf
[
i
-
cn
];
}
void
scalarToRawData
(
const
Scalar
&
s
,
void
*
_buf
,
int
type
,
int
unroll_to
)
{
CV_INSTRUMENT_REGION
()
int
i
,
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
const
int
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
CV_Assert
(
cn
<=
4
);
switch
(
depth
)
{
case
CV_8U
:
{
uchar
*
buf
=
(
uchar
*
)
_buf
;
for
(
i
=
0
;
i
<
cn
;
i
++
)
buf
[
i
]
=
saturate_cast
<
uchar
>
(
s
.
val
[
i
]);
for
(;
i
<
unroll_to
;
i
++
)
buf
[
i
]
=
buf
[
i
-
cn
];
}
scalarToRawData
<
uchar
>
(
s
,
(
uchar
*
)
_buf
,
cn
,
unroll_to
);
break
;
case
CV_8S
:
{
schar
*
buf
=
(
schar
*
)
_buf
;
for
(
i
=
0
;
i
<
cn
;
i
++
)
buf
[
i
]
=
saturate_cast
<
schar
>
(
s
.
val
[
i
]);
for
(;
i
<
unroll_to
;
i
++
)
buf
[
i
]
=
buf
[
i
-
cn
];
}
scalarToRawData
<
schar
>
(
s
,
(
schar
*
)
_buf
,
cn
,
unroll_to
);
break
;
case
CV_16U
:
{
ushort
*
buf
=
(
ushort
*
)
_buf
;
for
(
i
=
0
;
i
<
cn
;
i
++
)
buf
[
i
]
=
saturate_cast
<
ushort
>
(
s
.
val
[
i
]);
for
(;
i
<
unroll_to
;
i
++
)
buf
[
i
]
=
buf
[
i
-
cn
];
}
scalarToRawData
<
ushort
>
(
s
,
(
ushort
*
)
_buf
,
cn
,
unroll_to
);
break
;
case
CV_16S
:
{
short
*
buf
=
(
short
*
)
_buf
;
for
(
i
=
0
;
i
<
cn
;
i
++
)
buf
[
i
]
=
saturate_cast
<
short
>
(
s
.
val
[
i
]);
for
(;
i
<
unroll_to
;
i
++
)
buf
[
i
]
=
buf
[
i
-
cn
];
}
scalarToRawData
<
short
>
(
s
,
(
short
*
)
_buf
,
cn
,
unroll_to
);
break
;
case
CV_32S
:
{
int
*
buf
=
(
int
*
)
_buf
;
for
(
i
=
0
;
i
<
cn
;
i
++
)
buf
[
i
]
=
saturate_cast
<
int
>
(
s
.
val
[
i
]);
for
(;
i
<
unroll_to
;
i
++
)
buf
[
i
]
=
buf
[
i
-
cn
];
}
scalarToRawData
<
int
>
(
s
,
(
int
*
)
_buf
,
cn
,
unroll_to
);
break
;
case
CV_32F
:
{
float
*
buf
=
(
float
*
)
_buf
;
for
(
i
=
0
;
i
<
cn
;
i
++
)
buf
[
i
]
=
saturate_cast
<
float
>
(
s
.
val
[
i
]);
for
(;
i
<
unroll_to
;
i
++
)
buf
[
i
]
=
buf
[
i
-
cn
];
}
scalarToRawData
<
float
>
(
s
,
(
float
*
)
_buf
,
cn
,
unroll_to
);
break
;
case
CV_64F
:
{
double
*
buf
=
(
double
*
)
_buf
;
for
(
i
=
0
;
i
<
cn
;
i
++
)
buf
[
i
]
=
saturate_cast
<
double
>
(
s
.
val
[
i
]);
for
(;
i
<
unroll_to
;
i
++
)
buf
[
i
]
=
buf
[
i
-
cn
];
scalarToRawData
<
double
>
(
s
,
(
double
*
)
_buf
,
cn
,
unroll_to
);
break
;
}
default
:
CV_Error
(
CV_StsUnsupportedFormat
,
""
);
}
...
...
This diff is collapsed.
Click to expand it.
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