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
707d3e0a
Commit
707d3e0a
authored
Mar 20, 2013
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Python wrapper is adapted for cv::String
parent
2ad7b97f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
11 deletions
+24
-11
CMakeLists.txt
modules/python/CMakeLists.txt
+2
-0
cv2.cpp
modules/python/src2/cv2.cpp
+8
-10
hdr_parser.py
modules/python/src2/hdr_parser.py
+1
-1
test2.py
modules/python/test/test2.py
+13
-0
No files found.
modules/python/CMakeLists.txt
View file @
707d3e0a
...
@@ -65,6 +65,8 @@ add_custom_command(
...
@@ -65,6 +65,8 @@ add_custom_command(
DEPENDS
${
opencv_hdrs
}
)
DEPENDS
${
opencv_hdrs
}
)
add_library
(
${
the_module
}
SHARED src2/cv2.cpp
${
CMAKE_CURRENT_BINARY_DIR
}
/generated0.i
${
cv2_generated_hdrs
}
src2/cv2.cv.hpp
)
add_library
(
${
the_module
}
SHARED src2/cv2.cpp
${
CMAKE_CURRENT_BINARY_DIR
}
/generated0.i
${
cv2_generated_hdrs
}
src2/cv2.cv.hpp
)
set_target_properties
(
${
the_module
}
PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL
)
if
(
PYTHON_DEBUG_LIBRARIES AND NOT PYTHON_LIBRARIES MATCHES
"optimized.*debug"
)
if
(
PYTHON_DEBUG_LIBRARIES AND NOT PYTHON_LIBRARIES MATCHES
"optimized.*debug"
)
target_link_libraries
(
${
the_module
}
debug
${
PYTHON_DEBUG_LIBRARIES
}
optimized
${
PYTHON_LIBRARIES
}
)
target_link_libraries
(
${
the_module
}
debug
${
PYTHON_DEBUG_LIBRARIES
}
optimized
${
PYTHON_LIBRARIES
}
)
else
()
else
()
...
...
modules/python/src2/cv2.cpp
View file @
707d3e0a
...
@@ -100,8 +100,6 @@ catch (const cv::Exception &e) \
...
@@ -100,8 +100,6 @@ catch (const cv::Exception &e) \
using
namespace
cv
;
using
namespace
cv
;
typedef
cv
::
softcascade
::
ChannelFeatureBuilder
softcascade_ChannelFeatureBuilder
;
typedef
cv
::
softcascade
::
ChannelFeatureBuilder
softcascade_ChannelFeatureBuilder
;
typedef
std
::
string
string
;
typedef
std
::
vector
<
uchar
>
vector_uchar
;
typedef
std
::
vector
<
uchar
>
vector_uchar
;
typedef
std
::
vector
<
int
>
vector_int
;
typedef
std
::
vector
<
int
>
vector_int
;
typedef
std
::
vector
<
float
>
vector_float
;
typedef
std
::
vector
<
float
>
vector_float
;
...
@@ -117,7 +115,7 @@ typedef std::vector<Rect> vector_Rect;
...
@@ -117,7 +115,7 @@ typedef std::vector<Rect> vector_Rect;
typedef
std
::
vector
<
KeyPoint
>
vector_KeyPoint
;
typedef
std
::
vector
<
KeyPoint
>
vector_KeyPoint
;
typedef
std
::
vector
<
Mat
>
vector_Mat
;
typedef
std
::
vector
<
Mat
>
vector_Mat
;
typedef
std
::
vector
<
DMatch
>
vector_DMatch
;
typedef
std
::
vector
<
DMatch
>
vector_DMatch
;
typedef
std
::
vector
<
std
::
string
>
vector_s
tring
;
typedef
std
::
vector
<
cv
::
String
>
vector_S
tring
;
typedef
std
::
vector
<
std
::
vector
<
Point
>
>
vector_vector_Point
;
typedef
std
::
vector
<
std
::
vector
<
Point
>
>
vector_vector_Point
;
typedef
std
::
vector
<
std
::
vector
<
Point2f
>
>
vector_vector_Point2f
;
typedef
std
::
vector
<
std
::
vector
<
Point2f
>
>
vector_vector_Point2f
;
typedef
std
::
vector
<
std
::
vector
<
Point3f
>
>
vector_vector_Point3f
;
typedef
std
::
vector
<
std
::
vector
<
Point3f
>
>
vector_vector_Point3f
;
...
@@ -550,12 +548,12 @@ static PyObject* pyopencv_from(int64 value)
...
@@ -550,12 +548,12 @@ static PyObject* pyopencv_from(int64 value)
return
PyLong_FromLongLong
(
value
);
return
PyLong_FromLongLong
(
value
);
}
}
static
PyObject
*
pyopencv_from
(
const
std
::
s
tring
&
value
)
static
PyObject
*
pyopencv_from
(
const
cv
::
S
tring
&
value
)
{
{
return
PyString_FromString
(
value
.
empty
()
?
""
:
value
.
c_str
());
return
PyString_FromString
(
value
.
empty
()
?
""
:
value
.
c_str
());
}
}
static
bool
pyopencv_to
(
PyObject
*
obj
,
std
::
s
tring
&
value
,
const
char
*
name
=
"<unknown>"
)
static
bool
pyopencv_to
(
PyObject
*
obj
,
cv
::
S
tring
&
value
,
const
char
*
name
=
"<unknown>"
)
{
{
(
void
)
name
;
(
void
)
name
;
if
(
!
obj
||
obj
==
Py_None
)
if
(
!
obj
||
obj
==
Py_None
)
...
@@ -563,7 +561,7 @@ static bool pyopencv_to(PyObject* obj, std::string& value, const char* name = "<
...
@@ -563,7 +561,7 @@ static bool pyopencv_to(PyObject* obj, std::string& value, const char* name = "<
char
*
str
=
PyString_AsString
(
obj
);
char
*
str
=
PyString_AsString
(
obj
);
if
(
!
str
)
if
(
!
str
)
return
false
;
return
false
;
value
=
std
::
s
tring
(
str
);
value
=
cv
::
S
tring
(
str
);
return
true
;
return
true
;
}
}
...
@@ -906,14 +904,14 @@ template<> struct pyopencvVecConverter<DMatch>
...
@@ -906,14 +904,14 @@ template<> struct pyopencvVecConverter<DMatch>
}
}
};
};
template
<>
struct
pyopencvVecConverter
<
std
::
s
tring
>
template
<>
struct
pyopencvVecConverter
<
cv
::
S
tring
>
{
{
static
bool
to
(
PyObject
*
obj
,
std
::
vector
<
std
::
s
tring
>&
value
,
const
ArgInfo
info
)
static
bool
to
(
PyObject
*
obj
,
std
::
vector
<
cv
::
S
tring
>&
value
,
const
ArgInfo
info
)
{
{
return
pyopencv_to_generic_vec
(
obj
,
value
,
info
);
return
pyopencv_to_generic_vec
(
obj
,
value
,
info
);
}
}
static
PyObject
*
from
(
const
std
::
vector
<
std
::
s
tring
>&
value
)
static
PyObject
*
from
(
const
std
::
vector
<
cv
::
S
tring
>&
value
)
{
{
return
pyopencv_from_generic_vec
(
value
);
return
pyopencv_from_generic_vec
(
value
);
}
}
...
@@ -994,7 +992,7 @@ static bool pyopencv_to(PyObject *o, cv::flann::IndexParams& p, const char *name
...
@@ -994,7 +992,7 @@ static bool pyopencv_to(PyObject *o, cv::flann::IndexParams& p, const char *name
PyObject
*
item
=
PyList_GET_ITEM
(
values
,
i
);
PyObject
*
item
=
PyList_GET_ITEM
(
values
,
i
);
if
(
!
PyString_Check
(
key
)
)
if
(
!
PyString_Check
(
key
)
)
break
;
break
;
std
::
s
tring
k
=
PyString_AsString
(
key
);
cv
::
S
tring
k
=
PyString_AsString
(
key
);
if
(
PyString_Check
(
item
)
)
if
(
PyString_Check
(
item
)
)
{
{
const
char
*
value
=
PyString_AsString
(
item
);
const
char
*
value
=
PyString_AsString
(
item
);
...
...
modules/python/src2/hdr_parser.py
View file @
707d3e0a
...
@@ -335,7 +335,7 @@ class CppHeaderParser(object):
...
@@ -335,7 +335,7 @@ class CppHeaderParser(object):
if
pos
>=
0
:
if
pos
>=
0
:
aname
=
arg
[
pos
+
1
:]
.
strip
()
aname
=
arg
[
pos
+
1
:]
.
strip
()
atype
=
arg
[:
pos
+
1
]
.
strip
()
atype
=
arg
[:
pos
+
1
]
.
strip
()
if
aname
.
endswith
(
"&"
)
or
aname
.
endswith
(
"*"
)
or
(
aname
in
[
"int"
,
"
s
tring"
,
"Mat"
]):
if
aname
.
endswith
(
"&"
)
or
aname
.
endswith
(
"*"
)
or
(
aname
in
[
"int"
,
"
S
tring"
,
"Mat"
]):
atype
=
(
atype
+
" "
+
aname
)
.
strip
()
atype
=
(
atype
+
" "
+
aname
)
.
strip
()
aname
=
""
aname
=
""
else
:
else
:
...
...
modules/python/test/test2.py
View file @
707d3e0a
...
@@ -32,6 +32,19 @@ class NewOpenCVTests(unittest.TestCase):
...
@@ -32,6 +32,19 @@ class NewOpenCVTests(unittest.TestCase):
""" Compute a hash for an image, useful for image comparisons """
""" Compute a hash for an image, useful for image comparisons """
return
hashlib
.
md5
(
im
.
tostring
())
.
digest
()
return
hashlib
.
md5
(
im
.
tostring
())
.
digest
()
if
sys
.
version_info
[:
2
]
==
(
2
,
6
):
def
assertLess
(
self
,
a
,
b
,
msg
=
None
):
if
not
a
<
b
:
self
.
fail
(
'
%
s not less than
%
s'
%
(
repr
(
a
),
repr
(
b
)))
def
assertLessEqual
(
self
,
a
,
b
,
msg
=
None
):
if
not
a
<=
b
:
self
.
fail
(
'
%
s not less than or equal to
%
s'
%
(
repr
(
a
),
repr
(
b
)))
def
assertGreater
(
self
,
a
,
b
,
msg
=
None
):
if
not
a
>
b
:
self
.
fail
(
'
%
s not greater than
%
s'
%
(
repr
(
a
),
repr
(
b
)))
# Tests to run first; check the handful of basic operations that the later tests rely on
# Tests to run first; check the handful of basic operations that the later tests rely on
class
Hackathon244Tests
(
NewOpenCVTests
):
class
Hackathon244Tests
(
NewOpenCVTests
):
...
...
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