Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
48073e6d
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,发现更多精彩内容 >>
提交
48073e6d
编写于
11月 01, 2019
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pylint: eliminate warnings
上级
469addec
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
41 deletion
+41
-41
modules/python/test/test_cuda.py
modules/python/test/test_cuda.py
+22
-22
samples/python/dis_opt_flow.py
samples/python/dis_opt_flow.py
+3
-3
samples/python/stitching.py
samples/python/stitching.py
+1
-1
samples/python/stitching_detailed.py
samples/python/stitching_detailed.py
+15
-15
未找到文件。
modules/python/test/test_cuda.py
浏览文件 @
48073e6d
...
...
@@ -95,8 +95,8 @@ class cuda_test(NewOpenCVTests):
def
test_cudabgsegm_existence
(
self
):
#Test at least the existence of wrapped functions for now
bgsub
=
cv
.
cuda
.
createBackgroundSubtractorMOG
()
bgsub
=
cv
.
cuda
.
createBackgroundSubtractorMOG2
()
_
bgsub
=
cv
.
cuda
.
createBackgroundSubtractorMOG
()
_
bgsub
=
cv
.
cuda
.
createBackgroundSubtractorMOG2
()
self
.
assertTrue
(
True
)
#It is sufficient that no exceptions have been there
...
...
@@ -104,8 +104,8 @@ class cuda_test(NewOpenCVTests):
#Test at least the existence of wrapped functions for now
try
:
writer
=
cv
.
cudacodec
.
createVideoWriter
(
"tmp"
,
(
128
,
128
),
30
)
reader
=
cv
.
cudacodec
.
createVideoReader
(
"tmp"
)
_
writer
=
cv
.
cudacodec
.
createVideoWriter
(
"tmp"
,
(
128
,
128
),
30
)
_
reader
=
cv
.
cudacodec
.
createVideoReader
(
"tmp"
)
except
cv
.
error
as
e
:
self
.
assertEqual
(
e
.
code
,
cv
.
Error
.
StsNotImplemented
)
self
.
skipTest
(
"NVCUVENC is not installed"
)
...
...
@@ -125,11 +125,11 @@ class cuda_test(NewOpenCVTests):
cuMat2
=
cv
.
cuda
.
cvtColor
(
cuMat2
,
cv
.
COLOR_RGB2GRAY
)
fast
=
cv
.
cuda_FastFeatureDetector
.
create
()
kps
=
fast
.
detectAsync
(
cuMat1
)
_
kps
=
fast
.
detectAsync
(
cuMat1
)
orb
=
cv
.
cuda_ORB
.
create
()
kps1
,
descs1
=
orb
.
detectAndComputeAsync
(
cuMat1
,
None
)
kps2
,
descs2
=
orb
.
detectAndComputeAsync
(
cuMat2
,
None
)
_
kps1
,
descs1
=
orb
.
detectAndComputeAsync
(
cuMat1
,
None
)
_
kps2
,
descs2
=
orb
.
detectAndComputeAsync
(
cuMat2
,
None
)
bf
=
cv
.
cuda_DescriptorMatcher
.
createBFMatcher
(
cv
.
NORM_HAMMING
)
matches
=
bf
.
match
(
descs1
,
descs2
)
...
...
@@ -144,20 +144,20 @@ class cuda_test(NewOpenCVTests):
def
test_cudafilters_existence
(
self
):
#Test at least the existence of wrapped functions for now
filter
=
cv
.
cuda
.
createBoxFilter
(
cv
.
CV_8UC1
,
-
1
,
(
3
,
3
))
filter
=
cv
.
cuda
.
createLinearFilter
(
cv
.
CV_8UC4
,
-
1
,
np
.
eye
(
3
))
filter
=
cv
.
cuda
.
createLaplacianFilter
(
cv
.
CV_16UC1
,
-
1
,
ksize
=
3
)
filter
=
cv
.
cuda
.
createSeparableLinearFilter
(
cv
.
CV_8UC1
,
-
1
,
np
.
eye
(
3
),
np
.
eye
(
3
))
filter
=
cv
.
cuda
.
createDerivFilter
(
cv
.
CV_8UC1
,
-
1
,
1
,
1
,
3
)
filter
=
cv
.
cuda
.
createSobelFilter
(
cv
.
CV_8UC1
,
-
1
,
1
,
1
)
filter
=
cv
.
cuda
.
createScharrFilter
(
cv
.
CV_8UC1
,
-
1
,
1
,
0
)
filter
=
cv
.
cuda
.
createGaussianFilter
(
cv
.
CV_8UC1
,
-
1
,
(
3
,
3
),
16
)
filter
=
cv
.
cuda
.
createMorphologyFilter
(
cv
.
MORPH_DILATE
,
cv
.
CV_32FC1
,
np
.
eye
(
3
))
filter
=
cv
.
cuda
.
createBoxMaxFilter
(
cv
.
CV_8UC1
,
(
3
,
3
))
filter
=
cv
.
cuda
.
createBoxMinFilter
(
cv
.
CV_8UC1
,
(
3
,
3
))
filter
=
cv
.
cuda
.
createRowSumFilter
(
cv
.
CV_8UC1
,
cv
.
CV_32FC1
,
3
)
filter
=
cv
.
cuda
.
createColumnSumFilter
(
cv
.
CV_8UC1
,
cv
.
CV_32FC1
,
3
)
filter
=
cv
.
cuda
.
createMedianFilter
(
cv
.
CV_8UC1
,
3
)
_
filter
=
cv
.
cuda
.
createBoxFilter
(
cv
.
CV_8UC1
,
-
1
,
(
3
,
3
))
_
filter
=
cv
.
cuda
.
createLinearFilter
(
cv
.
CV_8UC4
,
-
1
,
np
.
eye
(
3
))
_
filter
=
cv
.
cuda
.
createLaplacianFilter
(
cv
.
CV_16UC1
,
-
1
,
ksize
=
3
)
_
filter
=
cv
.
cuda
.
createSeparableLinearFilter
(
cv
.
CV_8UC1
,
-
1
,
np
.
eye
(
3
),
np
.
eye
(
3
))
_
filter
=
cv
.
cuda
.
createDerivFilter
(
cv
.
CV_8UC1
,
-
1
,
1
,
1
,
3
)
_
filter
=
cv
.
cuda
.
createSobelFilter
(
cv
.
CV_8UC1
,
-
1
,
1
,
1
)
_
filter
=
cv
.
cuda
.
createScharrFilter
(
cv
.
CV_8UC1
,
-
1
,
1
,
0
)
_
filter
=
cv
.
cuda
.
createGaussianFilter
(
cv
.
CV_8UC1
,
-
1
,
(
3
,
3
),
16
)
_
filter
=
cv
.
cuda
.
createMorphologyFilter
(
cv
.
MORPH_DILATE
,
cv
.
CV_32FC1
,
np
.
eye
(
3
))
_
filter
=
cv
.
cuda
.
createBoxMaxFilter
(
cv
.
CV_8UC1
,
(
3
,
3
))
_
filter
=
cv
.
cuda
.
createBoxMinFilter
(
cv
.
CV_8UC1
,
(
3
,
3
))
_
filter
=
cv
.
cuda
.
createRowSumFilter
(
cv
.
CV_8UC1
,
cv
.
CV_32FC1
,
3
)
_
filter
=
cv
.
cuda
.
createColumnSumFilter
(
cv
.
CV_8UC1
,
cv
.
CV_32FC1
,
3
)
_
filter
=
cv
.
cuda
.
createMedianFilter
(
cv
.
CV_8UC1
,
3
)
self
.
assertTrue
(
True
)
#It is sufficient that no exceptions have been there
...
...
@@ -195,7 +195,7 @@ class cuda_test(NewOpenCVTests):
cv
.
cuda
.
meanShiftSegmentation
(
cuC4
,
10
,
5
,
5
).
download
()
clahe
=
cv
.
cuda
.
createCLAHE
()
clahe
.
apply
(
cuC1
,
cv
.
cuda_Stream
.
Null
())
;
clahe
.
apply
(
cuC1
,
cv
.
cuda_Stream
.
Null
())
histLevels
=
cv
.
cuda
.
histEven
(
cuC3
,
20
,
0
,
255
)
cv
.
cuda
.
histRange
(
cuC1
,
histLevels
)
...
...
samples/python/dis_opt_flow.py
浏览文件 @
48073e6d
...
...
@@ -30,7 +30,7 @@ def draw_flow(img, flow, step=16):
lines
=
np
.
int32
(
lines
+
0.5
)
vis
=
cv
.
cvtColor
(
img
,
cv
.
COLOR_GRAY2BGR
)
cv
.
polylines
(
vis
,
lines
,
0
,
(
0
,
255
,
0
))
for
(
x1
,
y1
),
(
x2
,
y2
)
in
lines
:
for
(
x1
,
y1
),
(
_x2
,
_
y2
)
in
lines
:
cv
.
circle
(
vis
,
(
x1
,
y1
),
1
,
(
0
,
255
,
0
),
-
1
)
return
vis
...
...
@@ -66,7 +66,7 @@ def main():
fn
=
0
cam
=
video
.
create_capture
(
fn
)
ret
,
prev
=
cam
.
read
()
_
ret
,
prev
=
cam
.
read
()
prevgray
=
cv
.
cvtColor
(
prev
,
cv
.
COLOR_BGR2GRAY
)
show_hsv
=
False
show_glitch
=
False
...
...
@@ -78,7 +78,7 @@ def main():
flow
=
None
while
True
:
ret
,
img
=
cam
.
read
()
_
ret
,
img
=
cam
.
read
()
gray
=
cv
.
cvtColor
(
img
,
cv
.
COLOR_BGR2GRAY
)
if
flow
is
not
None
and
use_temporal_propagation
:
#warp previous flow to get an initial approximation for the current flow:
...
...
samples/python/stitching.py
浏览文件 @
48073e6d
...
...
@@ -50,7 +50,7 @@ def main():
print
(
"Can't stitch images, error code = %d"
%
status
)
sys
.
exit
(
-
1
)
cv
.
imwrite
(
args
.
output
,
pano
)
;
cv
.
imwrite
(
args
.
output
,
pano
)
print
(
"stitching completed successfully. %s saved!"
%
args
.
output
)
print
(
'Done'
)
...
...
samples/python/stitching_detailed.py
浏览文件 @
48073e6d
...
...
@@ -48,7 +48,7 @@ def main():
args
=
parser
.
parse_args
()
img_names
=
args
.
img_names
print
(
img_names
)
preview
=
args
.
preview
_
preview
=
args
.
preview
try_cuda
=
args
.
try_cuda
work_megapix
=
args
.
work_megapix
seam_megapix
=
args
.
seam_megapix
...
...
@@ -84,7 +84,7 @@ def main():
print
(
"Bad exposure compensation method"
)
exit
()
expos_comp_nr_feeds
=
args
.
expos_comp_nr_feeds
expos_comp_nr_filtering
=
args
.
expos_comp_nr_filtering
_
expos_comp_nr_filtering
=
args
.
expos_comp_nr_filtering
expos_comp_block_size
=
args
.
expos_comp_block_size
match_conf
=
args
.
match_conf
seam_find_type
=
args
.
seam
...
...
@@ -118,7 +118,7 @@ def main():
images
=
[]
is_work_scale_set
=
False
is_seam_scale_set
=
False
is_compose_scale_set
=
False
;
is_compose_scale_set
=
False
for
name
in
img_names
:
full_img
=
cv
.
imread
(
cv
.
samples
.
findFile
(
name
))
if
full_img
is
None
:
...
...
@@ -163,9 +163,9 @@ def main():
img_names_subset
.
append
(
img_names
[
indices
[
i
,
0
]])
img_subset
.
append
(
images
[
indices
[
i
,
0
]])
full_img_sizes_subset
.
append
(
full_img_sizes
[
indices
[
i
,
0
]])
images
=
img_subset
;
img_names
=
img_names_subset
;
full_img_sizes
=
full_img_sizes_subset
;
images
=
img_subset
img_names
=
img_names_subset
full_img_sizes
=
full_img_sizes_subset
num_images
=
len
(
img_names
)
if
num_images
<
2
:
print
(
"Need more images"
)
...
...
@@ -266,7 +266,7 @@ def main():
if
seam_find_type
==
"no"
:
seam_finder
=
cv
.
detail
.
SeamFinder_createDefault
(
cv
.
detail
.
SeamFinder_NO
)
elif
seam_find_type
==
"voronoi"
:
seam_finder
=
cv
.
detail
.
SeamFinder_createDefault
(
cv
.
detail
.
SeamFinder_VORONOI_SEAM
)
;
seam_finder
=
cv
.
detail
.
SeamFinder_createDefault
(
cv
.
detail
.
SeamFinder_VORONOI_SEAM
)
elif
seam_find_type
==
"gc_color"
:
seam_finder
=
cv
.
detail_GraphCutSeamFinder
(
"COST_COLOR"
)
elif
seam_find_type
==
"gc_colorgrad"
:
...
...
@@ -279,7 +279,7 @@ def main():
print
(
"Can't create the following seam finder "
,
seam_find_type
)
exit
()
seam_finder
.
find
(
images_warped_f
,
corners
,
masks_warped
)
imgListe
=
[]
_
imgListe
=
[]
compose_scale
=
1
corners
=
[]
sizes
=
[]
...
...
@@ -294,8 +294,8 @@ def main():
if
not
is_compose_scale_set
:
if
compose_megapix
>
0
:
compose_scale
=
min
(
1.0
,
np
.
sqrt
(
compose_megapix
*
1e6
/
(
full_img
.
shape
[
0
]
*
full_img
.
shape
[
1
])))
is_compose_scale_set
=
True
;
compose_work_aspect
=
compose_scale
/
work_scale
;
is_compose_scale_set
=
True
compose_work_aspect
=
compose_scale
/
work_scale
warped_image_scale
*=
compose_work_aspect
warper
=
cv
.
PyRotationWarper
(
warp_type
,
warped_image_scale
)
for
i
in
range
(
0
,
len
(
img_names
)):
...
...
@@ -304,14 +304,14 @@ def main():
cameras
[
i
].
ppy
*=
compose_work_aspect
sz
=
(
full_img_sizes
[
i
][
0
]
*
compose_scale
,
full_img_sizes
[
i
][
1
]
*
compose_scale
)
K
=
cameras
[
i
].
K
().
astype
(
np
.
float32
)
roi
=
warper
.
warpRoi
(
sz
,
K
,
cameras
[
i
].
R
)
;
roi
=
warper
.
warpRoi
(
sz
,
K
,
cameras
[
i
].
R
)
corners
.
append
(
roi
[
0
:
2
])
sizes
.
append
(
roi
[
2
:
4
])
if
abs
(
compose_scale
-
1
)
>
1e-1
:
img
=
cv
.
resize
(
src
=
full_img
,
dsize
=
None
,
fx
=
compose_scale
,
fy
=
compose_scale
,
interpolation
=
cv
.
INTER_LINEAR_EXACT
)
else
:
img
=
full_img
;
img_size
=
(
img
.
shape
[
1
],
img
.
shape
[
0
]);
img
=
full_img
_img_size
=
(
img
.
shape
[
1
],
img
.
shape
[
0
])
K
=
cameras
[
idx
].
K
().
astype
(
np
.
float32
)
corner
,
image_warped
=
warper
.
warp
(
img
,
K
,
cameras
[
idx
].
R
,
cv
.
INTER_LINEAR
,
cv
.
BORDER_REFLECT
)
mask
=
255
*
np
.
ones
((
img
.
shape
[
0
],
img
.
shape
[
1
]),
np
.
uint8
)
...
...
@@ -341,9 +341,9 @@ def main():
if
timelapse
:
matones
=
np
.
ones
((
image_warped_s
.
shape
[
0
],
image_warped_s
.
shape
[
1
]),
np
.
uint8
)
timelapser
.
process
(
image_warped_s
,
matones
,
corners
[
idx
])
pos_s
=
img_names
[
idx
].
rfind
(
"/"
)
;
pos_s
=
img_names
[
idx
].
rfind
(
"/"
)
if
pos_s
==
-
1
:
fixedFileName
=
"fixed_"
+
img_names
[
idx
]
;
fixedFileName
=
"fixed_"
+
img_names
[
idx
]
else
:
fixedFileName
=
img_names
[
idx
][:
pos_s
+
1
]
+
"fixed_"
+
img_names
[
idx
][
pos_s
+
1
:
]
cv
.
imwrite
(
fixedFileName
,
timelapser
.
getDst
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录