Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
6dc7ae0f
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6dc7ae0f
编写于
6月 06, 2011
作者:
A
Alexander Mordvintsev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added some constants to python cv2 api
上级
cd2f3786
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
20 deletion
+21
-20
modules/python/src2/cv2.cpp
modules/python/src2/cv2.cpp
+8
-0
samples/python2/browse.py
samples/python2/browse.py
+6
-6
samples/python2/gaussian_mix.py
samples/python2/gaussian_mix.py
+2
-2
samples/python2/letter_recog.py
samples/python2/letter_recog.py
+5
-12
未找到文件。
modules/python/src2/cv2.cpp
浏览文件 @
6dc7ae0f
...
...
@@ -856,6 +856,14 @@ void initcv2()
PUBLISH
(
GC_INIT_WITH_MASK
);
PUBLISH
(
GC_EVAL
);
PUBLISH
(
CV_ROW_SAMPLE
);
PUBLISH
(
CV_VAR_NUMERICAL
);
PUBLISH
(
CV_VAR_ORDERED
);
PUBLISH
(
CV_VAR_CATEGORICAL
);
PUBLISH
(
CV_AA
);
#include "pyopencv_generated_const_reg.h"
}
samples/python2/browse.py
浏览文件 @
6dc7ae0f
...
...
@@ -16,14 +16,14 @@ if len(sys.argv) > 1:
img
=
cv2
.
imread
(
fn
)
else
:
sz
=
4096
print
'generating %dx%d pr
e
cudural image ...'
%
(
sz
,
sz
)
print
'generating %dx%d pr
o
cudural image ...'
%
(
sz
,
sz
)
img
=
np
.
zeros
((
sz
,
sz
),
np
.
uint8
)
track
=
np
.
cumsum
(
np
.
random
.
rand
(
10
00000
,
2
)
-
0.5
,
axis
=
0
)
track
=
np
.
int32
(
track
*
2
0
+
(
sz
/
2
,
sz
/
2
))
track
=
np
.
cumsum
(
np
.
random
.
rand
(
5
00000
,
2
)
-
0.5
,
axis
=
0
)
track
=
np
.
int32
(
track
*
1
0
+
(
sz
/
2
,
sz
/
2
))
cv2
.
polylines
(
img
,
[
track
],
0
,
255
,
1
,
cv
.
CV_AA
)
small
=
img
for
i
in
xrange
(
4
):
for
i
in
xrange
(
3
):
small
=
cv2
.
pyrDown
(
small
)
def
onmouse
(
event
,
x
,
y
,
flags
,
param
):
...
...
@@ -33,6 +33,6 @@ def onmouse(event, x, y, flags, param):
zoom
=
cv2
.
getRectSubPix
(
img
,
(
800
,
600
),
(
x
+
0.5
,
y
+
0.5
))
cv2
.
imshow
(
'zoom'
,
zoom
)
cv2
.
imshow
(
'
small
'
,
small
)
cv
.
SetMouseCallback
(
'
small
'
,
onmouse
,
None
)
cv2
.
imshow
(
'
preview
'
,
small
)
cv
.
SetMouseCallback
(
'
preview
'
,
onmouse
,
None
)
cv2
.
waitKey
()
samples/python2/gaussian_mix.py
浏览文件 @
6dc7ae0f
import
numpy
as
np
from
numpy
import
random
import
cv2
,
cv
import
cv2
def
make_gaussians
(
cluster_n
,
img_size
):
...
...
@@ -22,7 +22,7 @@ def draw_gaussain(img, mean, cov, color):
w
,
u
,
vt
=
cv2
.
SVDecomp
(
cov
)
ang
=
np
.
rad2deg
(
np
.
arctan2
(
u
[
1
,
0
],
u
[
0
,
0
])
)
s1
,
s2
=
np
.
sqrt
(
w
)
*
3.0
cv2
.
ellipse
(
img
,
(
x
,
y
),
(
s1
,
s2
),
ang
,
0
,
360
,
color
,
1
,
cv
.
CV_AA
)
cv2
.
ellipse
(
img
,
(
x
,
y
),
(
s1
,
s2
),
ang
,
0
,
360
,
color
,
1
,
cv
2
.
CV_AA
)
if
__name__
==
'__main__'
:
...
...
samples/python2/letter_recog.py
浏览文件 @
6dc7ae0f
...
...
@@ -6,13 +6,6 @@ def load_base(fn):
samples
,
responses
=
a
[:,
1
:],
a
[:,
0
]
return
samples
,
responses
# TODO move these to cv2
CV_ROW_SAMPLE
=
1
CV_VAR_NUMERICAL
=
0
CV_VAR_ORDERED
=
0
CV_VAR_CATEGORICAL
=
1
class
LetterStatModel
(
object
):
train_ratio
=
0.5
def
load
(
self
,
fn
):
...
...
@@ -26,10 +19,10 @@ class RTrees(LetterStatModel):
def
train
(
self
,
samples
,
responses
):
sample_n
,
var_n
=
samples
.
shape
var_types
=
np
.
array
([
CV_VAR_NUMERICAL
]
*
var_n
+
[
CV_VAR_CATEGORICAL
],
np
.
uint8
)
var_types
=
np
.
array
([
cv2
.
CV_VAR_NUMERICAL
]
*
var_n
+
[
cv2
.
CV_VAR_CATEGORICAL
],
np
.
uint8
)
#CvRTParams(10,10,0,false,15,0,true,4,100,0.01f,CV_TERMCRIT_ITER));
params
=
dict
(
max_depth
=
10
)
self
.
model
.
train
(
samples
,
CV_ROW_SAMPLE
,
responses
,
varType
=
var_types
,
params
=
params
)
self
.
model
.
train
(
samples
,
cv2
.
CV_ROW_SAMPLE
,
responses
,
varType
=
var_types
,
params
=
params
)
def
predict
(
self
,
samples
):
return
np
.
float32
(
[
self
.
model
.
predict
(
s
)
for
s
in
samples
]
)
...
...
@@ -56,10 +49,10 @@ class Boost(LetterStatModel):
sample_n
,
var_n
=
samples
.
shape
new_samples
=
self
.
unroll_samples
(
samples
)
new_responses
=
self
.
unroll_responses
(
responses
)
var_types
=
np
.
array
([
CV_VAR_NUMERICAL
]
*
var_n
+
[
CV_VAR_CATEGORICAL
,
CV_VAR_CATEGORICAL
],
np
.
uint8
)
var_types
=
np
.
array
([
cv2
.
CV_VAR_NUMERICAL
]
*
var_n
+
[
cv2
.
CV_VAR_CATEGORICAL
,
cv2
.
CV_VAR_CATEGORICAL
],
np
.
uint8
)
#CvBoostParams(CvBoost::REAL, 100, 0.95, 5, false, 0 )
params
=
dict
(
max_depth
=
5
)
#, use_surrogates=False)
self
.
model
.
train
(
new_samples
,
CV_ROW_SAMPLE
,
new_responses
,
varType
=
var_types
,
params
=
params
)
self
.
model
.
train
(
new_samples
,
cv2
.
CV_ROW_SAMPLE
,
new_responses
,
varType
=
var_types
,
params
=
params
)
def
predict
(
self
,
samples
):
new_samples
=
self
.
unroll_samples
(
samples
)
...
...
@@ -105,7 +98,7 @@ if __name__ == '__main__':
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-model'
,
default
=
'rtrees'
,
choices
=
models
.
keys
())
parser
.
add_argument
(
'-data'
,
nargs
=
1
,
default
=
'letter-recognition.data'
)
parser
.
add_argument
(
'-data'
,
nargs
=
1
,
default
=
'
../cpp/
letter-recognition.data'
)
parser
.
add_argument
(
'-load'
,
nargs
=
1
)
parser
.
add_argument
(
'-save'
,
nargs
=
1
)
args
=
parser
.
parse_args
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录