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
08b7855e
Commit
08b7855e
authored
Nov 15, 2010
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended out << mat/vec operators; added opencv license
parent
f2df7848
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
178 additions
and
116 deletions
+178
-116
core.hpp
modules/core/include/opencv2/core/core.hpp
+0
-1
cvout.hpp
modules/core/include/opencv2/core/cvout.hpp
+0
-79
operations.hpp
modules/core/include/opencv2/core/operations.hpp
+101
-0
cvout.cpp
modules/core/src/cvout.cpp
+0
-0
brief.cpp
modules/features2d/src/brief.cpp
+43
-9
cvout_sample.cpp
samples/cpp/cvout_sample.cpp
+34
-27
No files found.
modules/core/include/opencv2/core/core.hpp
View file @
08b7855e
...
...
@@ -4055,6 +4055,5 @@ public:
#include "opencv2/core/operations.hpp"
#include "opencv2/core/mat.hpp"
#include "opencv2/core/cvout.hpp"
#endif
/*__OPENCV_CORE_HPP__*/
modules/core/include/opencv2/core/cvout.hpp
deleted
100644 → 0
View file @
f2df7848
#ifndef __OPENCV_CORE_CVOUT_HPP__
#define __OPENCV_CORE_CVOUT_HPP__
#ifdef __cplusplus
#ifndef SKIP_INCLUDES
#include <iomanip>
#include <iostream>
#include <vector>
#endif
namespace
cv
{
/** Writes a point to an output stream in Matlab notation
*/
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Point2f
&
p
)
{
out
<<
"[ "
<<
p
.
x
<<
","
<<
p
.
y
<<
" ]"
;
return
out
;
}
/** Writes a point to an output stream in Matlab notation
*/
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Point3f
&
p
)
{
out
<<
"[ "
<<
p
.
x
<<
","
<<
p
.
y
<<
","
<<
p
.
z
<<
" ]"
;
return
out
;
}
/** \brief write points to and output stream
* \param out typically cout
* \param points the points to be written to the stream
* \return the stream
**/
CV_EXPORTS
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
std
::
vector
<
Point2f
>
&
points
);
/** \brief write points to and output stream
* \param out typically cout
* \param points the points to be written to the stream
* \return the stream
**/
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
std
::
vector
<
Point3f
>
&
points
);
/** \brief allows each output of Mat in Matlab for Mat to std::cout
* use like
@verbatim
Mat my_mat = Mat::eye(3,3,CV_32F);
std::cout << my_mat;
@endverbatim
*/
CV_EXPORTS
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Mat
&
mat
);
/** \brief write a Mat in csv compatible for Matlab.
This means that the rows are seperated by newlines and the
columns by commas ....
331.413896619595,0,122.365880226491
0,249.320451610369,122.146722131871
0,0,1
* \param out output stream to write to
* \param Mat write a Mat to a csv
*/
CV_EXPORTS
std
::
ostream
&
writeCSV
(
std
::
ostream
&
out
,
const
Mat
&
mat
);
/** \brief write a vector of points to an
output stream if possible
**/
CV_EXPORTS
std
::
ostream
&
writeCSV
(
std
::
ostream
&
out
,
const
std
::
vector
<
Point2f
>
&
points
);
/** \brief write a vector of points to an
output stream if possible
**/
CV_EXPORTS
std
::
ostream
&
writeCSV
(
std
::
ostream
&
out
,
const
std
::
vector
<
Point3f
>
&
points
);
}
//namespace cv
#endif
#endif
modules/core/include/opencv2/core/operations.hpp
View file @
08b7855e
...
...
@@ -3495,6 +3495,107 @@ public:
return
new
_ClsName
(
*
(
const
_ClsName
*
)
ptr
);
}
};
class
CV_EXPORTS
Formatter
{
public
:
virtual
~
Formatter
()
{}
virtual
void
write
(
std
::
ostream
&
out
,
const
Mat
&
m
,
const
int
*
params
=
0
,
int
nparams
=
0
)
const
=
0
;
virtual
void
write
(
std
::
ostream
&
out
,
const
void
*
data
,
int
nelems
,
int
type
,
const
int
*
params
=
0
,
int
nparams
=
0
)
const
=
0
;
static
const
Formatter
*
get
(
const
char
*
fmt
=
""
);
static
const
Formatter
*
setDefault
(
const
Formatter
*
fmt
);
};
struct
CV_EXPORTS
Formatted
{
Formatted
(
const
Mat
&
m
,
const
Formatter
*
fmt
,
const
vector
<
int
>&
params
);
Formatted
(
const
Mat
&
m
,
const
Formatter
*
fmt
,
const
int
*
params
=
0
);
Mat
mtx
;
const
Formatter
*
fmt
;
vector
<
int
>
params
;
};
/** Writes a point to an output stream in Matlab notation
*/
template
<
typename
_Tp
>
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Point_
<
_Tp
>&
p
)
{
out
<<
"["
<<
p
.
x
<<
", "
<<
p
.
y
<<
"]"
;
return
out
;
}
/** Writes a point to an output stream in Matlab notation
*/
template
<
typename
_Tp
>
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Point3_
<
_Tp
>&
p
)
{
out
<<
"["
<<
p
.
x
<<
", "
<<
p
.
y
<<
", "
<<
p
.
z
<<
"]"
;
return
out
;
}
static
inline
Formatted
format
(
const
Mat
&
mtx
,
const
char
*
fmt
,
const
vector
<
int
>&
params
=
vector
<
int
>
())
{
return
Formatted
(
mtx
,
Formatter
::
get
(
fmt
),
params
);
}
template
<
typename
_Tp
>
static
inline
Formatted
format
(
const
vector
<
Point_
<
_Tp
>
>&
vec
,
const
char
*
fmt
,
const
vector
<
int
>&
params
=
vector
<
int
>
())
{
return
Formatted
(
Mat
(
vec
),
Formatter
::
get
(
fmt
),
params
);
}
template
<
typename
_Tp
>
static
inline
Formatted
format
(
const
vector
<
Point3_
<
_Tp
>
>&
vec
,
const
char
*
fmt
,
const
vector
<
int
>&
params
=
vector
<
int
>
())
{
return
Formatted
(
Mat
(
vec
),
Formatter
::
get
(
fmt
),
params
);
}
/** \brief prints Mat to the output stream in Matlab notation
* use like
@verbatim
Mat my_mat = Mat::eye(3,3,CV_32F);
std::cout << my_mat;
@endverbatim
*/
static
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Mat
&
mtx
)
{
Formatter
::
get
()
->
write
(
out
,
mtx
);
return
out
;
}
/** \brief prints Mat to the output stream allows in the specified notation (see format)
* use like
@verbatim
Mat my_mat = Mat::eye(3,3,CV_32F);
std::cout << my_mat;
@endverbatim
*/
static
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Formatted
&
fmtd
)
{
fmtd
.
fmt
->
write
(
out
,
fmtd
.
mtx
);
return
out
;
}
template
<
typename
_Tp
>
static
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
vector
<
Point_
<
_Tp
>
>&
vec
)
{
Formatter
::
get
()
->
write
(
out
,
Mat
(
vec
));
return
out
;
}
template
<
typename
_Tp
>
static
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
vector
<
Point3_
<
_Tp
>
>&
vec
)
{
Formatter
::
get
()
->
write
(
out
,
Mat
(
vec
));
return
out
;
}
}
...
...
modules/core/src/cvout.cpp
View file @
08b7855e
This diff is collapsed.
Click to expand it.
modules/features2d/src/brief.cpp
View file @
08b7855e
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <algorithm>
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#include <algorithm>
#include <vector>
using
std
::
vector
;
namespace
cv
{
...
...
@@ -362,8 +400,4 @@ unsigned char HammingLUT::byteBitsLookUp(unsigned char b){
return
table
[
b
];
}
}
// namespace cv
samples/cpp/cvout_sample.cpp
View file @
08b7855e
#include "opencv2/core/core.hpp"
#include <iostream>
using
namespace
std
;
using
namespace
cv
;
int
main
()
int
main
(
int
,
char
**
)
{
Mat
i
=
Mat
::
eye
(
4
,
4
,
CV_32F
);
cout
<<
"i = "
<<
i
<<
";"
<<
endl
;
Mat
r
=
Mat
(
10
,
10
,
CV_8UC1
);
randu
(
r
,
Scalar
(
0
),
Scalar
(
255
));
cout
<<
"r = "
<<
r
<<
";"
<<
endl
;
Point2f
p
(
5
,
1
);
cout
<<
"p = "
<<
p
<<
";"
<<
endl
;
Point3f
p3f
(
2
,
6
,
7
);
cout
<<
"p3f = "
<<
p3f
<<
";"
<<
endl
;
vector
<
Point2f
>
points
(
20
);
for
(
size_t
i
=
0
;
i
<
points
.
size
();
++
i
)
{
points
[
i
]
=
Point2f
(
i
*
5
,
i
%
7
);
}
cout
<<
"points = "
<<
points
<<
";"
<<
endl
;
cout
<<
"#csv"
<<
endl
;
writeCSV
(
cout
,
r
);
return
1
;
Mat
i
=
Mat
::
eye
(
4
,
4
,
CV_64F
);
i
.
at
<
double
>
(
1
,
1
)
=
CV_PI
;
cout
<<
"i = "
<<
i
<<
";"
<<
endl
;
Mat
r
=
Mat
(
10
,
3
,
CV_8UC3
);
randu
(
r
,
Scalar
::
all
(
0
),
Scalar
::
all
(
255
));
cout
<<
"r (default) = "
<<
r
<<
";"
<<
endl
<<
endl
;
cout
<<
"r (python) = "
<<
format
(
r
,
"python"
)
<<
";"
<<
endl
<<
endl
;
cout
<<
"r (numpy) = "
<<
format
(
r
,
"numpy"
)
<<
";"
<<
endl
<<
endl
;
cout
<<
"r (csv) = "
<<
format
(
r
,
"csv"
)
<<
";"
<<
endl
<<
endl
;
cout
<<
"r (c) = "
<<
format
(
r
,
"C"
)
<<
";"
<<
endl
<<
endl
;
Point2f
p
(
5
,
1
);
cout
<<
"p = "
<<
p
<<
";"
<<
endl
;
Point3f
p3f
(
2
,
6
,
7
);
cout
<<
"p3f = "
<<
p3f
<<
";"
<<
endl
;
vector
<
float
>
v
;
v
.
push_back
(
1
);
v
.
push_back
(
2
);
v
.
push_back
(
3
);
cout
<<
"shortvec = "
<<
Mat
(
v
)
<<
endl
;
vector
<
Point2f
>
points
(
20
);
for
(
size_t
i
=
0
;
i
<
points
.
size
();
++
i
)
points
[
i
]
=
Point2f
(
i
*
5
,
i
%
7
);
cout
<<
"points = "
<<
points
<<
";"
<<
endl
;
return
0
;
}
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