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
73d4d5d4
Commit
73d4d5d4
authored
Nov 25, 2010
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deleted obsolete scripts
parent
8967a128
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
661 deletions
+0
-661
check_doc.py
utils/check_doc.py
+0
-184
cvarr_operators.py
utils/cvarr_operators.py
+0
-103
extract_aliases.py
utils/extract_aliases.py
+0
-28
extract_constants.py
utils/extract_constants.py
+0
-30
extract_doublepointers.py
utils/extract_doublepointers.py
+0
-73
extract_macros.py
utils/extract_macros.py
+0
-180
make_index.py
utils/make_index.py
+0
-63
No files found.
utils/check_doc.py
deleted
100644 → 0
View file @
8967a128
#!/usr/bin/env python
"""
Usage: check_doc.py > log.txt
The script parses different opencv modules
(that are described by instances of class Comp below) and
checks for typical errors in headers and docs, for consistence and for completeness.
Due to its simplicity, it falsely reports some bugs, that should be
just ignored.
"""
import
sys
,
os
,
re
,
glob
comps
=
[]
class
Comp
:
def
__init__
(
self
,
comp_name
):
self
.
name
=
comp_name
cxcore
=
Comp
(
'cxcore'
)
cxcore
.
header_path
=
'../cxcore/include'
cxcore
.
headers
=
[
'cxcore.h'
,
'cxtypes.h'
]
cxcore
.
ext_macro
=
'CVAPI'
cxcore
.
inline_macro
=
'CV_INLINE'
cxcore
.
func_prefix
=
'cv'
cxcore
.
doc_path
=
'../docs/ref'
cxcore
.
docs
=
[
'opencvref_cxcore.htm'
]
comps
.
append
(
cxcore
)
cv
=
Comp
(
'cv'
)
cv
.
header_path
=
'../cv/include'
cv
.
headers
=
[
'cv.h'
,
'cvtypes.h'
]
cv
.
ext_macro
=
'CVAPI'
cv
.
inline_macro
=
'CV_INLINE'
cv
.
func_prefix
=
'cv'
cv
.
doc_path
=
'../docs/ref'
cv
.
docs
=
[
'opencvref_cv.htm'
]
comps
.
append
(
cv
)
highgui
=
Comp
(
'highgui'
)
highgui
.
header_path
=
'../otherlibs/highgui'
highgui
.
headers
=
[
'highgui.h'
]
highgui
.
ext_macro
=
'CVAPI'
highgui
.
inline_macro
=
'CV_INLINE'
highgui
.
func_prefix
=
'cv'
highgui
.
doc_path
=
'../docs/ref'
highgui
.
docs
=
[
'opencvref_highgui.htm'
]
comps
.
append
(
highgui
)
def
normalize_decl
(
decl
):
decl
=
re
.
sub
(
r'^\((.+?)\)'
,
r'\1'
,
decl
)
decl
=
re
.
sub
(
r' CV_DEFAULT\((.+?)\)(,|( *\);))'
,
r'=\1\2'
,
decl
)
decl
=
re
.
sub
(
r'\);'
,
r' );'
,
decl
)
decl
=
re
.
sub
(
r'\('
,
r'( '
,
decl
)
decl
=
re
.
sub
(
r'/\*.+?\*/'
,
r''
,
decl
)
decl
=
re
.
sub
(
r'\binline\b'
,
r''
,
decl
)
decl
=
re
.
sub
(
r' +'
,
r' '
,
decl
)
decl
=
re
.
sub
(
r' ?= ?'
,
r'='
,
decl
)
return
decl
.
strip
()
def
print_report
(
filename
,
line_no
,
msg
):
print
'
%
s(
%
d):
%
s'
%
(
filename
,
line_no
,
msg
)
for
comp
in
comps
:
print
"==================================================="
print
'Checking
%
s...'
%
(
comp
.
name
,)
header_path
=
comp
.
header_path
func_list
=
{}
if
not
header_path
.
endswith
(
'/'
)
and
not
header_path
.
endswith
(
'
\\
'
):
header_path
+=
'/'
for
header_glob
in
comp
.
headers
:
glob_expr
=
header_path
+
header_glob
for
header
in
glob
.
glob
(
glob_expr
):
f
=
open
(
header
,
'r'
)
func_name
=
""
mode
=
line_no
=
0
# mode - outside func declaration (0) or inside (1)
for
l
in
f
.
xreadlines
():
line_no
+=
1
ll
=
""
#if re.findall(r'\b([abd-z]|([c][a-uw-z]))[a-z]*[A-Z]', l):
# print_report(header,line_no,"Bad-style identifier:\n\t"+l)
if
mode
==
0
:
if
l
.
startswith
(
comp
.
ext_macro
):
ll
=
l
[
len
(
comp
.
ext_macro
):]
decl
=
""
mode
=
1
elif
l
.
startswith
(
comp
.
inline_macro
):
temp_func_name
=
re
.
findall
(
r'^.+?\b('
+
comp
.
func_prefix
+
'
\
w+)'
,
l
)
if
temp_func_name
and
temp_func_name
[
0
]
!=
func_name
:
ll
=
l
[
len
(
comp
.
inline_macro
):]
decl
=
""
mode
=
1
else
:
ll
=
l
if
ll
:
decl
+=
ll
.
rstrip
(
'
\n
'
)
+
' '
if
ll
.
find
(
';'
)
>=
0
:
mode
=
0
decl
=
normalize_decl
(
decl
)
func_name
=
re
.
findall
(
r'^.+?\b('
+
comp
.
func_prefix
+
'
\
w+)'
,
decl
)[
0
]
if
func_list
.
get
(
func_name
,[]):
print_report
(
header
,
line_no
,
"Duplicated declaration of "
+
\
func_name
+
"... ignored"
)
else
:
func_list
[
func_name
]
=
[
decl
,
header
,
line_no
,
0
]
else
:
mode
=
1
f
.
close
()
doc_path
=
comp
.
doc_path
if
not
doc_path
.
endswith
(
'/'
)
and
not
doc_path
.
endswith
(
'
\\
'
):
doc_path
+=
'/'
blurb_re
=
re
.
compile
(
r'^<p class="Blurb"'
)
for
doc_glob
in
comp
.
docs
:
glob_expr
=
doc_path
+
doc_glob
for
doc
in
glob
.
glob
(
glob_expr
):
f
=
open
(
doc
,
'r'
)
mode
=
line_no
=
0
# mode - 0 outside function declaration, 2 - inside,
# 1 transitional state ('cause <pre> is used not only
# for declaring functions)
for
l
in
f
.
xreadlines
():
line_no
+=
1
#if re.findall(r'\b([abd-z]|([c][a-uw-z]))[a-z]*[A-Z]', l):
# print_report(doc,line_no,"Bad-style identifier:\n\t" + l)
if
mode
==
0
:
if
blurb_re
.
match
(
l
):
mode
=
1
elif
mode
==
1
:
if
l
.
endswith
(
'<pre>
\n
'
):
mode
=
2
decl
=
""
elif
mode
==
2
:
if
l
.
startswith
(
'</pre>'
):
mode
=
0
if
decl
.
find
(
'CV_DEFAULT'
)
>=
0
:
print_report
(
doc
,
line_no
,
'CV_DEFAULT is used in documentation'
)
decl
=
normalize_decl
(
decl
)
decl_list
=
decl
.
split
(
';'
)
for
decl
in
decl_list
:
decl
=
decl
.
strip
()
if
decl
:
decl
=
decl
+
';'
#print '***', decl
func_name
=
re
.
findall
(
r'^.+?\b('
+
comp
.
func_prefix
+
'
\
w+)
\
('
,
decl
)
if
not
func_name
:
continue
func_name
=
func_name
[
0
]
decl_info
=
func_list
.
get
(
func_name
,[])
if
decl_info
:
if
decl_info
[
3
]
==
0
:
if
decl_info
[
0
]
!=
decl
:
print_report
(
doc
,
line_no
,
'Incorrect documentation on '
+
func_name
+
':'
)
print
' hdr: '
+
decl_info
[
0
]
print
' doc: '
+
decl
decl_info
[
3
]
=
1
else
:
print_report
(
doc
,
line_no
,
'Duplicated documentation on '
+
func_name
)
else
:
print_report
(
doc
,
line_no
,
'The function '
+
func_name
+
' is not declared'
)
elif
not
l
.
startswith
(
'#define'
):
decl
+=
l
.
rstrip
(
'
\n
'
)
f
.
close
()
print
"---------------------------------------------------"
keys
=
func_list
.
keys
()
undocumented_funcs
=
[]
for
k
in
keys
:
decl_info
=
func_list
[
k
]
if
decl_info
[
3
]
==
0
:
undocumented_funcs
.
append
((
decl_info
[
1
],
decl_info
[
2
],
k
))
undocumented_funcs
.
sort
()
for
decl_info
in
undocumented_funcs
:
print_report
(
decl_info
[
0
],
decl_info
[
1
],
'Undocumented function '
+
decl_info
[
2
])
utils/cvarr_operators.py
deleted
100644 → 0
View file @
8967a128
#!/usr/bin/python
BINARY_OPERATORS
=
{
'+'
:
'cvAdd'
,
'-'
:
'cvSub'
,
'/'
:
'cvDiv'
,
'*'
:
'cvMul'
,
'^'
:
'cvXor'
,
'&'
:
'cvAnd'
,
'|'
:
'cvOr'
,
}
SCALAR_OPERATORS
=
{
'+'
:
'cvAddS'
,
'-'
:
'cvSubS'
,
'&'
:
'cvAndS'
,
'|'
:
'cvOrS'
,
'^'
:
'cvXorS'
,
}
SCALE_OPERATORS
=
{
'*'
:
'val'
,
'/'
:
'1.0/val'
}
CMP_OPERATORS
=
{
'=='
:
'CV_CMP_EQ'
,
'!='
:
'CV_CMP_NE'
,
'>='
:
'CV_CMP_GE'
,
'>'
:
'CV_CMP_GT'
,
'<='
:
'CV_CMP_LE'
,
'<'
:
'CV_CMP_LT'
,
}
ARR
=
{
'CvMat'
:
'cvCreateMat(self->rows, self->cols, self->type)'
,
'IplImage'
:
'cvCreateImage(cvGetSize(self), self->depth, self->nChannels)'
}
CMP_ARR
=
{
'CvMat'
:
'cvCreateMat(self->rows, self->cols, CV_8U)'
,
'IplImage'
:
'cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1)'
}
def
scalar_scale_operator
(
arr
,
op
,
arg
):
print
'
\t
%
s * operator
%
s (double val){'
%
(
arr
,
op
)
print
'
\t\t
%
s * res =
%
s;'
%
(
arr
,
ARR
[
arr
]
)
print
'
\t\t
cvScale(self, res,
%
s);'
%
arg
print
'
\t\t
return res;'
print
'
\t
}'
print
'
\t
%
s * operator
%
s (double val){'
%
(
arr
,
op
)
print
'
\t\t
%
s * res =
%
s;'
%
(
arr
,
ARR
[
arr
]
)
print
'
\t\t
cvScale(self, res,
%
s);'
%
arg
print
'
\t\t
return res;'
print
'
\t
}'
print
"/** This file was automatically generated using util/cvarr_operators.py script */"
for
arr
in
ARR
:
print
'
%%
extend
%
s {'
%
arr
for
op
in
BINARY_OPERATORS
:
print
'
\t
%%
newobject operator
%
s;'
%
(
op
)
print
'
\t
%
s * operator
%
s (CvArr * src){'
%
(
arr
,
op
)
print
'
\t\t
%
s * res =
%
s;'
%
(
arr
,
ARR
[
arr
]
)
print
'
\t\t
%
s(self, src, res);'
%
(
BINARY_OPERATORS
[
op
]
)
print
'
\t\t
return res;'
print
'
\t
}'
print
'
\t
%
s * operator
%
s= (CvArr * src){'
%
(
arr
,
op
)
print
'
\t\t
%
s(self, src, self);'
%
(
BINARY_OPERATORS
[
op
]
)
print
'
\t\t
return self;'
print
'
\t
}'
for
op
in
SCALAR_OPERATORS
:
print
'
\t
%%
newobject operator
%
s;'
%
(
op
)
print
'
\t
%
s * operator
%
s (CvScalar val){'
%
(
arr
,
op
)
print
'
\t\t
%
s * res =
%
s;'
%
(
arr
,
ARR
[
arr
]
)
print
'
\t\t
%
s(self, val, res);'
%
(
SCALAR_OPERATORS
[
op
]
)
print
'
\t\t
return res;'
print
'
\t
}'
print
'
\t
%
s * operator
%
s= (CvScalar val){'
%
(
arr
,
op
)
print
'
\t\t
%
s(self, val, self);'
%
(
SCALAR_OPERATORS
[
op
]
)
print
'
\t\t
return self;'
print
'
\t
}'
for
op
in
CMP_OPERATORS
:
print
'
\t
%%
newobject operator
%
s;'
%
(
op
)
print
'
\t
%
s * operator
%
s (CvArr * src){'
%
(
arr
,
op
)
print
'
\t\t
%
s * res =
%
s;'
%
(
arr
,
CMP_ARR
[
arr
]
)
print
'
\t\t
cvCmp(self, src, res,
%
s);'
%
(
CMP_OPERATORS
[
op
]
)
print
'
\t\t
return res;'
print
'
\t
}'
print
'
\t
%
s * operator
%
s (double val){'
%
(
arr
,
op
)
print
'
\t\t
%
s * res =
%
s;'
%
(
arr
,
CMP_ARR
[
arr
]
)
print
'
\t\t
cvCmpS(self, val, res,
%
s);'
%
(
CMP_OPERATORS
[
op
]
)
print
'
\t\t
return res;'
print
'
\t
}'
for
op
in
SCALE_OPERATORS
:
print
'
\t
%%
newobject operator
%
s;'
%
(
op
)
print
'
\t
%
s * operator
%
s (double val){'
%
(
arr
,
op
)
print
'
\t\t
%
s * res =
%
s;'
%
(
arr
,
ARR
[
arr
]
)
print
'
\t\t
cvScale(self, res,
%
s);'
%
SCALE_OPERATORS
[
op
]
print
'
\t\t
return res;'
print
'
\t
}'
print
'
\t
%
s * operator
%
s= (double val){'
%
(
arr
,
op
)
print
'
\t\t
cvScale(self, self,
%
s);'
%
SCALE_OPERATORS
[
op
]
print
'
\t\t
return self;'
print
'
\t
}'
print
'} /* extend
%
s */
\n
'
%
arr
utils/extract_aliases.py
deleted
100755 → 0
View file @
8967a128
#! /usr/bin/env python
"""
This script extracts macros #defines from those OpenCV headers that can't be
directly parsed by current SWIG versions and must be pre-filtered by
the C preprocessor (that erases all #defines). Type information is missing in the
macros, so C code can't be regenerated. Instead, try to convert C to Python code.
C macros too complicated to represent in python using regexes are listed in EXCLUDE
"""
import
sys
,
re
EXCLUDE
=
{
}
# force this to be part of cv module
# otherwise becomes cv.cvmacros
print
"/** This file was automatically generated using util/extract_aliases.py script */"
print
"
%
module cv"
print
"
%
pythoncode
%
{"
for
fn
in
sys
.
argv
[
1
:]:
f
=
open
(
fn
,
"r"
)
in_define
=
0
for
l
in
f
.
xreadlines
():
m
=
re
.
match
(
r"^#define\s+((?:CV_|IPL_|cv)\w+)\s+((?:CV|IPL|cv)\w*)\s*$"
,
l
)
if
m
and
not
l
.
endswith
(
"
\\\n
"
)
and
not
EXCLUDE
.
has_key
(
m
.
group
(
1
)):
print
"
%
s=
%
s"
%
(
m
.
group
(
1
),
m
.
group
(
2
))
f
.
close
()
print
"
%
}"
utils/extract_constants.py
deleted
100755 → 0
View file @
8967a128
#! /usr/bin/env python
"""
This script extracts #defines from those OpenCV headers that can't be
directly parsed by current SWIG versions and must be pre-filtered by
the C preprocessor (that erases all #defines).
"""
import
sys
,
re
for
fn
in
sys
.
argv
[
1
:]:
f
=
open
(
fn
,
"r"
)
in_define
=
0
for
l
in
f
.
xreadlines
():
if
re
.
match
(
r"^#define\s+(CV_|IPL_|cv)\w+\s+"
,
l
):
in_define
=
1
if
re
.
match
(
r"^#define\s+CV_MAKETYPE"
,
l
):
in_define
=
1
if
re
.
match
(
r"^#define\s+CV_CN"
,
l
):
in_define
=
1
if
re
.
match
(
r"^#define\s+CV_MAT_TYPE"
,
l
):
in_define
=
1
if
re
.
match
(
r"^#define\s+CV_MAT_DEPTH"
,
l
):
in_define
=
1
if
in_define
:
print
l
[:
l
.
find
(
'/*'
)]
if
not
l
.
endswith
(
"
\\\n
"
):
in_define
=
0
print
f
.
close
()
utils/extract_doublepointers.py
deleted
100755 → 0
View file @
8967a128
#! /usr/bin/env python
"""
This script checks the OpenCV headers to find methods that take double pointers
to OpenCV data structures as in/out parameters.
These methods need a special treatment and therefore SWIG typemaps are generated.
"""
import
sys
def
convert_name
(
str
):
count
=
0
if
(
str
[
0
:
2
]
==
"_p"
):
p
,
s
=
convert_name
(
str
[
2
:])
return
((
'*'
+
p
),
s
)
return
(
''
,
str
[
1
:])
if
(
sys
.
argv
.
__len__
()
<
1
):
sys
.
exit
(
1
)
infile
=
open
(
sys
.
argv
[
1
],
'r'
)
lines
=
infile
.
readlines
()
infile
.
close
()
foundit
=
0
mytypes
=
[]
for
line
in
lines
:
if
(
foundit
==
0
):
if
(
line
.
find
(
'TYPES TABLE (BEGIN'
)
>
-
1
):
foundit
=
1
else
:
if
(
line
.
find
(
'TYPES TABLE (END)'
)
>
-
1
):
foundit
=
0
else
:
stuff
=
line
.
split
()
if
(
stuff
.
__len__
()
>=
3
):
if
(
stuff
[
0
]
==
"#define"
):
mytypes
.
append
(
stuff
[
1
][
8
:])
print
"""
/*//////////////////////////////////////////////////////////////////////////////////////////////////
// This file was automatically generated from the extract_doublepointers.py script found in the
// 'utils' subdirectory of the OpenCV distribution. Run it on the .cpp file generated by swig to
// generate the double pointer typemaps
/////////////////////////////////////////////////////////////////////////////////////////////////M*/
"""
for
mytype
in
mytypes
:
p
,
s
=
convert_name
(
mytype
)
if
(
p
.
__len__
()
>=
2
):
print
'
%
typemap(in)'
,
s
,
p
,
' (void * vptr, $*1_ltype buffer) {'
print
'
\t
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){'
print
'
\t\t
SWIG_fail;'
;
print
'
\t
}'
print
'
\t
buffer = ($*1_ltype) vptr;'
print
'
\t
$1=&buffer;'
print
'}'
#rez = "" + s + " " + p + 'getPtrTo' + s + '( ' + s + ' ' + p[1:] + 'input)'
#sys.stdout.write(rez)
#sys.stdout.write('\n{\n\t' + s + ' ' + p + 'rez = new ' + s + p[1:] + '();')
#sys.stdout.write('\n\t*rez =input;\n\treturn(rez);\n}\n')
#sys.stdout.write(rez)
#sys.stdout.write(';\n')
# else:
# print '/* No conversions needed for type ', s, ' */'
utils/extract_macros.py
deleted
100755 → 0
View file @
8967a128
#! /usr/bin/env python
"""
This script extracts macros functions from the OpenCV headers and attempts to generate
standard C function prototypes. Type information is missing in the macros, so SWIG
cannot generate C code for them unless we provide this.
"""
import
sys
,
re
ARG_MAP
=
{
"mat"
:
"CvMat*"
,
"type"
:
"int"
,
"flags"
:
"int"
,
"img"
:
"CvArr *"
,
"image"
:
"IplImage *"
,
"mat1"
:
"CvMat*"
,
"mat2"
:
"CvMat*"
,
"seq"
:
"CvSeq*"
,
"elem_ptr"
:
"void *"
,
"elem"
:
"CvPoint"
,
"elem_type"
:
"ignore"
,
"elemtype"
:
"ignore"
,
"elem_size"
:
"int"
,
"edge"
:
"CvGraphEdge *"
,
"vertex"
:
"CvGraphVtx *"
,
"contour"
:
"CvSeq *"
,
"vtx"
:
"CvGraphVtx *"
,
"reader"
:
"CvSeqReader"
,
"writer"
:
"CvSeqWriter"
,
"hist"
:
"CvHistogram *"
,
"ptr"
:
"void *"
,
"arr"
:
"CvArr *"
,
"header"
:
"CvMat *"
,
"src"
:
"CvArr *"
,
"src1"
:
"CvArr *"
,
"src2"
:
"CvArr *"
,
"src3"
:
"CvArr *"
,
"dst"
:
"CvArr *"
,
"pt1"
:
"CvPoint"
,
"pt2"
:
"CvPoint"
,
"_pt"
:
"CvPoint"
,
"index"
:
"int"
,
"idx"
:
"int"
,
"set"
:
"CvSet *"
,
"n"
:
"int"
,
"a"
:
"int"
,
"b"
:
"int"
,
"t"
:
"int"
,
"value"
:
"double"
,
"row"
:
"int"
,
"col"
:
"int"
,
"cn"
:
"int"
,
"new_cn"
:
"int"
,
"pix_size"
:
"int"
,
"depth"
:
"int"
,
"node"
:
"CvSparseNode *"
,
"storage"
:
"CvMemStorage *"
,
"new_dims"
:
"int"
,
"new_sizes"
:
"int *"
,
"A"
:
"CvArr *"
,
"B"
:
"CvArr *"
,
"C"
:
"CvArr *"
,
"real_scalar"
:
"double"
,
"graph"
:
"CvGraph *"
,
"r"
:
"double"
,
"g"
:
"double"
,
# "b":"double",
"line_iterator"
:
"CvLineIterator"
,
"deltas"
:
"double *"
,
"step"
:
"int"
,
"haar"
:
"void *"
,
# "contour":"const void*", # handled as a special case in cvshadow
"range"
:
"CvSize"
,
"nch"
:
"int"
,
"method"
:
"int"
,
"factor"
:
"double"
}
RET_MAP
=
{
"cvContourPerimeter"
:
"double"
,
"CV_RGB"
:
"CvScalar"
,
"CV_NEXT_GRAPH_EDGE"
:
"CvGraphEdge *"
,
"CV_IMIN"
:
"int"
,
"CV_IMAX"
:
"int"
,
"CV_IABS"
:
"int"
,
"CV_MAT_CN"
:
"int"
,
"CV_MAT_DEPTH"
:
"int"
,
"CV_NEXT_LINE_POINT"
:
"void"
,
}
# special cases
MACROS
=
{
#"CV_MAKETYPE":"", # SWIG 1.3.29 doesn't like this one for some indeterminant reason
"CV_TURN_ON_IPL_COMPATIBILITY"
:
""
,
"CV_MAT_ELEM_PTR_FAST"
:
"void * CV_MAT_ELEM_PTR_FAST(CvMat mat,int row,int col,int pix_size);"
,
"CV_MAT_ELEM_PTR"
:
"void * CV_MAT_ELEM_PTR(CvMat mat,int row,int col);"
,
"CV_NODE_VAL"
:
"void * CV_NODE_VAL(CvSparseMat* mat,CvSparseNode * node);"
,
"CV_NODE_IDX"
:
"int * CV_NODE_IDX(CvSparseMat* mat,CvSparseNode * node);"
,
"CV_READ_CHAIN_POINT"
:
"void CV_READ_CHAIN_POINT(CvPoint _pt, CvChainPtReader reader);"
,
"CV_SUBDIV2D_NEXT_EDGE"
:
"CvQuadEdge2D* CV_SUBDIV2D_NEXT_EDGE(CvSubdiv2DEdge edge);"
,
"cvFree"
:
"void cvFree(void ** ptr);"
,
}
print
"""
/*//////////////////////////////////////////////////////////////////////////////////////////////////
// This file is automatically generated from the extract_macros.py script found in the 'utils'
// subdirectory of the OpenCV distribution. If the generated function prototypes are missing or
// incorrect, it is likely that a name->type mapping will have to be added to the script
/////////////////////////////////////////////////////////////////////////////////////////////////M*/
"""
print
"// This file was generated from the following header files: "
print
"//
%
s"
%
"
\n
// "
.
join
(
sys
.
argv
[
1
:])
def
determine_return_type
(
name
,
arguments
):
if
RET_MAP
.
has_key
(
name
):
return
RET_MAP
[
name
]
if
name
.
find
(
"_IS_"
)
>=
0
or
\
name
.
find
(
"_HAS_"
)
>=
0
or
\
name
.
find
(
"_KIND"
)
>=
0
or
\
name
.
find
(
"_ARE_"
)
>=
0
or
\
name
.
find
(
"_SIZE"
)
>=
0
or
\
name
.
find
(
"Idx"
)
>=
0
or
\
name
.
find
(
"Count"
)
>=
0
or
\
(
name
.
find
(
"TYPE"
)
>=
0
and
not
name
.
find
(
"TYPES"
)
>=
0
):
return
"int"
if
re
.
match
(
r"CV_(?:8|16|32|64)(?:U|S|F)C"
,
name
):
return
"int"
if
len
(
arguments
)
is
1
and
arguments
[
0
]
.
startswith
(
"double"
):
return
"double"
if
name
.
find
(
"_PTR"
)
>=
0
:
return
"void *"
if
name
.
endswith
(
"POINT"
):
return
"CvPoint"
return
"void"
for
m
in
MACROS
:
print
MACROS
[
m
]
for
fn
in
sys
.
argv
[
1
:]:
f
=
open
(
fn
,
"r"
)
in_define
=
False
fstr
=
""
macro_name
=
""
for
l
in
f
.
xreadlines
():
m
=
re
.
match
(
r"^#define\s+((?:CV_|IPL_|cv)\w+)\s*\(([_, a-zA-Z0-9]*)\)\s*(.*)"
,
l
)
if
m
and
not
m
.
group
(
1
)
.
endswith
(
"FIELDS"
)
and
not
MACROS
.
has_key
(
m
.
group
(
1
)):
macro_name
=
m
.
group
(
1
)
args
=
m
.
group
(
2
)
.
strip
()
.
split
(
","
)
# assign return type
ret
=
determine_return_type
(
macro_name
,
args
)
# assign type to each argument
no_args
=
len
(
args
)
is
0
typed_args
=
[]
ignore
=
False
for
arg
in
args
:
arg
=
arg
.
strip
()
if
len
(
arg
)
is
0
:
no_args
=
True
break
if
ARG_MAP
.
has_key
(
arg
):
if
ARG_MAP
[
arg
]
is
"ignore"
:
ignore
=
True
break
typed_args
.
append
(
"
%
s
%
s"
%
(
ARG_MAP
[
arg
],
arg
)
)
else
:
sys
.
stderr
.
write
(
"
\"
%
s
\"
:
\"
?
\"
, in macro '
%
s'
\n
"
%
(
arg
,
macro_name
)
)
typed_args
=
[]
break
if
not
ignore
and
(
no_args
or
len
(
typed_args
)
>
0
):
decl
=
"
%
s
%
s(
%
s);"
%
(
ret
,
macro_name
,
","
.
join
(
typed_args
)
)
MACROS
[
macro_name
]
=
decl
print
decl
f
.
close
()
utils/make_index.py
deleted
100644 → 0
View file @
8967a128
#!/usr/bin/env python
"""
Usage: make_index.py <html_ref_file> [ > <output_func_index_file> ]
This script parses html reference file, creates alphabetical list of
functions and list of examples ]
"""
import
sys
,
re
,
string
f
=
open
(
sys
.
argv
[
1
])
func_list
=
{}
struct_list
=
[]
func_decl_re
=
re
.
compile
(
r'<a name="decl_(.+?)"'
)
for
l
in
f
.
xreadlines
():
llist
=
func_decl_re
.
findall
(
l
)
if
llist
:
ll
=
llist
[
0
]
if
ll
.
startswith
(
'Cv'
):
struct_list
.
append
(
ll
)
elif
ll
.
startswith
(
'Ipl'
):
struct_list
.
append
(
ll
)
elif
ll
.
startswith
(
'cvm'
):
sublist
=
func_list
.
get
(
ll
[
3
],
[])
sublist
.
append
(
ll
)
func_list
[
ll
[
3
]]
=
sublist
elif
ll
.
startswith
(
'cv'
):
sublist
=
func_list
.
get
(
ll
[
2
],
[])
sublist
.
append
(
ll
)
func_list
[
ll
[
2
]]
=
sublist
f
.
close
()
struct_list
.
sort
()
func_letters
=
func_list
.
keys
()
func_letters
.
sort
()
print
"<html><body>"
columns
=
3
for
letter
in
func_letters
:
print
'<hr><h3>
%
s</h3>
\n
<table width="100
%%
">'
%
letter
sublist
=
func_list
[
letter
]
sublist
.
sort
()
col_len
=
(
len
(
sublist
)
+
columns
-
1
)
/
columns
#if col_len*columns > len(sublist):
# sublist.append( "" * (col_len*columns - len(sublist)) )
for
i
in
range
(
col_len
):
print
'<tr>'
for
j
in
range
(
columns
):
if
i
+
j
*
col_len
<
len
(
sublist
):
fn
=
sublist
[
i
+
j
*
col_len
]
fn_short
=
fn
.
lstrip
(
string
.
lowercase
)
print
'<td width="25
%%
"><a href="#decl_
%
s">
%
s</a></td>'
%
(
fn
,
fn_short
)
else
:
print
'<td width="25
%%
"></td>'
print
'</tr>'
print
"</table>"
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