Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
0c504b42
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,发现更多精彩内容 >>
提交
0c504b42
编写于
5月 17, 2011
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
copied helper modules from doc to modules/python/test
上级
62569f69
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
90 addition
and
0 deletion
+90
-0
modules/python/test/calchist.py
modules/python/test/calchist.py
+53
-0
modules/python/test/findstereocorrespondence.py
modules/python/test/findstereocorrespondence.py
+23
-0
modules/python/test/precornerdetect.py
modules/python/test/precornerdetect.py
+14
-0
未找到文件。
modules/python/test/calchist.py
0 → 100644
浏览文件 @
0c504b42
# Calculating and displaying 2D Hue-Saturation histogram of a color image
import
sys
import
cv
def
hs_histogram
(
src
):
# Convert to HSV
hsv
=
cv
.
CreateImage
(
cv
.
GetSize
(
src
),
8
,
3
)
cv
.
CvtColor
(
src
,
hsv
,
cv
.
CV_BGR2HSV
)
# Extract the H and S planes
h_plane
=
cv
.
CreateMat
(
src
.
rows
,
src
.
cols
,
cv
.
CV_8UC1
)
s_plane
=
cv
.
CreateMat
(
src
.
rows
,
src
.
cols
,
cv
.
CV_8UC1
)
cv
.
Split
(
hsv
,
h_plane
,
s_plane
,
None
,
None
)
planes
=
[
h_plane
,
s_plane
]
h_bins
=
30
s_bins
=
32
hist_size
=
[
h_bins
,
s_bins
]
# hue varies from 0 (~0 deg red) to 180 (~360 deg red again */
h_ranges
=
[
0
,
180
]
# saturation varies from 0 (black-gray-white) to
# 255 (pure spectrum color)
s_ranges
=
[
0
,
255
]
ranges
=
[
h_ranges
,
s_ranges
]
scale
=
10
hist
=
cv
.
CreateHist
([
h_bins
,
s_bins
],
cv
.
CV_HIST_ARRAY
,
ranges
,
1
)
cv
.
CalcHist
([
cv
.
GetImage
(
i
)
for
i
in
planes
],
hist
)
(
_
,
max_value
,
_
,
_
)
=
cv
.
GetMinMaxHistValue
(
hist
)
hist_img
=
cv
.
CreateImage
((
h_bins
*
scale
,
s_bins
*
scale
),
8
,
3
)
for
h
in
range
(
h_bins
):
for
s
in
range
(
s_bins
):
bin_val
=
cv
.
QueryHistValue_2D
(
hist
,
h
,
s
)
intensity
=
cv
.
Round
(
bin_val
*
255
/
max_value
)
cv
.
Rectangle
(
hist_img
,
(
h
*
scale
,
s
*
scale
),
((
h
+
1
)
*
scale
-
1
,
(
s
+
1
)
*
scale
-
1
),
cv
.
RGB
(
intensity
,
intensity
,
intensity
),
cv
.
CV_FILLED
)
return
hist_img
if
__name__
==
'__main__'
:
src
=
cv
.
LoadImageM
(
sys
.
argv
[
1
])
cv
.
NamedWindow
(
"Source"
,
1
)
cv
.
ShowImage
(
"Source"
,
src
)
cv
.
NamedWindow
(
"H-S Histogram"
,
1
)
cv
.
ShowImage
(
"H-S Histogram"
,
hs_histogram
(
src
))
cv
.
WaitKey
(
0
)
modules/python/test/findstereocorrespondence.py
0 → 100644
浏览文件 @
0c504b42
import
sys
import
cv
def
findstereocorrespondence
(
image_left
,
image_right
):
# image_left and image_right are the input 8-bit single-channel images
# from the left and the right cameras, respectively
(
r
,
c
)
=
(
image_left
.
rows
,
image_left
.
cols
)
disparity_left
=
cv
.
CreateMat
(
r
,
c
,
cv
.
CV_16S
)
disparity_right
=
cv
.
CreateMat
(
r
,
c
,
cv
.
CV_16S
)
state
=
cv
.
CreateStereoGCState
(
16
,
2
)
cv
.
FindStereoCorrespondenceGC
(
image_left
,
image_right
,
disparity_left
,
disparity_right
,
state
,
0
)
return
(
disparity_left
,
disparity_right
)
if
__name__
==
'__main__'
:
(
l
,
r
)
=
[
cv
.
LoadImageM
(
f
,
cv
.
CV_LOAD_IMAGE_GRAYSCALE
)
for
f
in
sys
.
argv
[
1
:]]
(
disparity_left
,
disparity_right
)
=
findstereocorrespondence
(
l
,
r
)
disparity_left_visual
=
cv
.
CreateMat
(
l
.
rows
,
l
.
cols
,
cv
.
CV_8U
)
cv
.
ConvertScale
(
disparity_left
,
disparity_left_visual
,
-
16
)
cv
.
SaveImage
(
"disparity.pgm"
,
disparity_left_visual
)
modules/python/test/precornerdetect.py
0 → 100644
浏览文件 @
0c504b42
import
cv
def
precornerdetect
(
image
):
# assume that the image is floating-point
corners
=
cv
.
CloneMat
(
image
)
cv
.
PreCornerDetect
(
image
,
corners
,
3
)
dilated_corners
=
cv
.
CloneMat
(
image
)
cv
.
Dilate
(
corners
,
dilated_corners
,
None
,
1
)
corner_mask
=
cv
.
CreateMat
(
image
.
rows
,
image
.
cols
,
cv
.
CV_8UC1
)
cv
.
Sub
(
corners
,
dilated_corners
,
corners
)
cv
.
CmpS
(
corners
,
0
,
corner_mask
,
cv
.
CV_CMP_GE
)
return
(
corners
,
corner_mask
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录