Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Jeffcarl
fcos
提交
af132c51
F
fcos
项目概览
Jeffcarl
/
fcos
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fcos
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
af132c51
编写于
1月 21, 2019
作者:
A
Aaron Lelevier
提交者:
Francisco Massa
1月 21, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add helper function 'cv2_utils.findContours' to maintain version compatibility (#354)
fixes #339
上级
205fa4e7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
2 deletion
+29
-2
demo/predictor.py
demo/predictor.py
+2
-1
maskrcnn_benchmark/utils/cv2_util.py
maskrcnn_benchmark/utils/cv2_util.py
+24
-0
tools/cityscapes/instances2dict_with_polygons.py
tools/cityscapes/instances2dict_with_polygons.py
+3
-1
未找到文件。
demo/predictor.py
浏览文件 @
af132c51
...
...
@@ -8,6 +8,7 @@ from maskrcnn_benchmark.utils.checkpoint import DetectronCheckpointer
from
maskrcnn_benchmark.structures.image_list
import
to_image_list
from
maskrcnn_benchmark.modeling.roi_heads.mask_head.inference
import
Masker
from
maskrcnn_benchmark
import
layers
as
L
from
maskrcnn_benchmark.utils
import
cv2_util
class
COCODemo
(
object
):
...
...
@@ -287,7 +288,7 @@ class COCODemo(object):
for
mask
,
color
in
zip
(
masks
,
colors
):
thresh
=
mask
[
0
,
:,
:,
None
]
_
,
contours
,
hierarchy
=
cv2
.
findContours
(
contours
,
hierarchy
=
cv2_util
.
findContours
(
thresh
,
cv2
.
RETR_TREE
,
cv2
.
CHAIN_APPROX_SIMPLE
)
image
=
cv2
.
drawContours
(
image
,
contours
,
-
1
,
color
,
3
)
...
...
maskrcnn_benchmark/utils/cv2_util.py
0 → 100644
浏览文件 @
af132c51
"""
Module for cv2 utility functions and maintaining version compatibility
between 3.x and 4.x
"""
import
cv2
def
findContours
(
*
args
,
**
kwargs
):
"""
Wraps cv2.findContours to maintain compatiblity between versions
3 and 4
Returns:
contours, hierarchy
"""
if
cv2
.
__version__
.
startswith
(
'4'
):
contours
,
hierarchy
=
cv2
.
findContours
(
*
args
,
**
kwargs
)
elif
cv2
.
__version__
.
startswith
(
'3'
):
_
,
contours
,
hierarchy
=
cv2
.
findContours
(
*
args
,
**
kwargs
)
else
:
raise
AssertionError
(
'cv2 must be either version 3 or 4 to call this method'
)
return
contours
,
hierarchy
tools/cityscapes/instances2dict_with_polygons.py
浏览文件 @
af132c51
...
...
@@ -13,6 +13,8 @@ from csHelpers import *
from
cityscapesscripts.evaluation.instance
import
*
from
cityscapesscripts.helpers.csHelpers
import
*
import
cv2
from
maskrcnn_benchmark.utils
import
cv2_util
def
instances2dict_with_polygons
(
imageFileList
,
verbose
=
False
):
imgCount
=
0
...
...
@@ -46,7 +48,7 @@ def instances2dict_with_polygons(imageFileList, verbose=False):
#instances[id2label[instanceObj.labelID].name].append(instanceObj.toDict())
if
id2label
[
instanceObj
.
labelID
].
hasInstances
:
mask
=
(
imgNp
==
instanceId
).
astype
(
np
.
uint8
)
im2
,
contour
,
hier
=
cv2
.
findContours
(
contour
,
hier
=
cv2_util
.
findContours
(
mask
.
copy
(),
cv2
.
RETR_EXTERNAL
,
cv2
.
CHAIN_APPROX_NONE
)
polygons
=
[
c
.
reshape
(
-
1
).
tolist
()
for
c
in
contour
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录