Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_51672696
opencv-python
提交
6ee82a39
O
opencv-python
项目概览
weixin_51672696
/
opencv-python
与 Fork 源项目一致
Fork自
OpenCV / opencv-python
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv-python
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6ee82a39
编写于
10月 11, 2020
作者:
O
Olli-Pekka Heinisuo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix line endings
上级
1180f1e1
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
759 addition
and
759 deletion
+759
-759
appveyor.yml
appveyor.yml
+191
-191
cv2/__init__.py
cv2/__init__.py
+33
-33
find_version.py
find_version.py
+68
-68
setup.py
setup.py
+450
-450
tests/test.py
tests/test.py
+17
-17
未找到文件。
appveyor.yml
浏览文件 @
6ee82a39
environment
:
USER
:
secure
:
fXgF9uyy6sT0JoVOR7BoqA==
PASS
:
secure
:
0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys=
matrix
:
-
PYTHON
:
"
C:/Python36"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python36-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python37"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python37-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python38"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python38-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python39"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python39-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python36"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python36-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python37"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python37-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python38"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python38-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python39"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python39-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python36"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python36-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python37"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python37-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python38"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python38-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python39"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python39-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python36"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python36-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python37"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python37-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python38"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python38-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python39"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python39-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
matrix
:
fast_finish
:
true
build_script
:
-
cmd
:
|
"%PYTHON%/python.exe" -m pip install --upgrade pip
"%PYTHON%/python.exe" -m pip install --upgrade setuptools
set "CI_BUILD=1" && "%PYTHON%/python.exe" -m pip wheel --wheel-dir=%cd%\dist . --verbose
before_test
:
-
ps
:
|
cd ${Env:APPVEYOR_BUILD_FOLDER}\tests
$env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command"
&"${Env:PYTHON}/python.exe" -m pip install --user --no-warn-script-location (ls "../dist/opencv_*.whl")
if ($LastExitCode -ne 0) {throw $LastExitCode}
test_script
:
-
cmd
:
|
cd %APPVEYOR_BUILD_FOLDER%\tests
"%PYTHON%/python.exe" -m unittest test
artifacts
:
-
path
:
dist\opencv*.whl
name
:
wheels
deploy_script
:
-
ps
:
|
if (${Env:APPVEYOR_REPO_TAG} -eq "true") {
cd ${Env:APPVEYOR_BUILD_FOLDER}
if (${Env:ENABLE_CONTRIB} -eq 0) {
if (${Env:ENABLE_HEADLESS} -eq 0) {
echo "This is a default build. Deployment will be done to PyPI entry opencv-python."
}
else {
echo "This is a headless build. Deployment will be done to PyPI entry opencv-python-headless."
}
}
else {
if (${Env:ENABLE_HEADLESS} -eq 0) {
echo "This is a contrib build. Deployment will be done to PyPI entry opencv-contrib-python."
}
else {
echo "This is a headless contrib build. Deployment will be done to PyPI entry opencv-contrib-python-headless."
}
}
&
"
${Env:PYTHON}/python.exe"
-m pip install twine
&"${Env:PYTHON}/python.exe" -m twine upload -u ${Env:USER} -p ${Env:PASS} --skip-existing dist/opencv*
}
else {
echo "Tag not set, deployment skipped."
}
environment
:
USER
:
secure
:
fXgF9uyy6sT0JoVOR7BoqA==
PASS
:
secure
:
0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys=
matrix
:
-
PYTHON
:
"
C:/Python36"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python36-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python37"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python37-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python38"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python38-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python39"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python39-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python36"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python36-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python37"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python37-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python38"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python38-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python39"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python39-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
0
-
PYTHON
:
"
C:/Python36"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python36-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python37"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python37-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python38"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python38-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python39"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python39-x64"
ENABLE_CONTRIB
:
0
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python36"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python36-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python37"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python37-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python38"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python38-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python39"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
-
PYTHON
:
"
C:/Python39-x64"
ENABLE_CONTRIB
:
1
ENABLE_HEADLESS
:
1
matrix
:
fast_finish
:
true
build_script
:
-
cmd
:
|
"%PYTHON%/python.exe" -m pip install --upgrade pip
"%PYTHON%/python.exe" -m pip install --upgrade setuptools
set "CI_BUILD=1" && "%PYTHON%/python.exe" -m pip wheel --wheel-dir=%cd%\dist . --verbose
before_test
:
-
ps
:
|
cd ${Env:APPVEYOR_BUILD_FOLDER}\tests
$env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command"
&"${Env:PYTHON}/python.exe" -m pip install --user --no-warn-script-location (ls "../dist/opencv_*.whl")
if ($LastExitCode -ne 0) {throw $LastExitCode}
test_script
:
-
cmd
:
|
cd %APPVEYOR_BUILD_FOLDER%\tests
"%PYTHON%/python.exe" -m unittest test
artifacts
:
-
path
:
dist\opencv*.whl
name
:
wheels
deploy_script
:
-
ps
:
|
if (${Env:APPVEYOR_REPO_TAG} -eq "true") {
cd ${Env:APPVEYOR_BUILD_FOLDER}
if (${Env:ENABLE_CONTRIB} -eq 0) {
if (${Env:ENABLE_HEADLESS} -eq 0) {
echo "This is a default build. Deployment will be done to PyPI entry opencv-python."
}
else {
echo "This is a headless build. Deployment will be done to PyPI entry opencv-python-headless."
}
}
else {
if (${Env:ENABLE_HEADLESS} -eq 0) {
echo "This is a contrib build. Deployment will be done to PyPI entry opencv-contrib-python."
}
else {
echo "This is a headless contrib build. Deployment will be done to PyPI entry opencv-contrib-python-headless."
}
}
&"${Env:PYTHON}/python.exe" -m pip install twine
&"${Env:PYTHON}/python.exe" -m twine upload -u ${Env:USER} -p ${Env:PASS} --skip-existing dist/opencv*
}
else {
echo "Tag not set, deployment skipped."
}
cv2/__init__.py
浏览文件 @
6ee82a39
import
importlib
import
os
import
sys
from
.cv2
import
*
from
.data
import
*
# wildcard import above does not import "private" variables like __version__
# this makes them available
globals
().
update
(
importlib
.
import_module
(
"cv2.cv2"
).
__dict__
)
ci_and_not_headless
=
False
try
:
from
.version
import
ci_build
,
headless
ci_and_not_headless
=
ci_build
and
not
headless
except
:
pass
# the Qt plugin is included currently only in the pre-built wheels
if
(
sys
.
platform
==
"darwin"
or
sys
.
platform
.
startswith
(
"linux"
)
)
and
ci_and_not_headless
:
os
.
environ
[
"QT_QPA_PLATFORM_PLUGIN_PATH"
]
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"qt"
,
"plugins"
)
# Qt will throw warning on Linux if fonts are not found
if
sys
.
platform
.
startswith
(
"linux"
)
and
ci_and_not_headless
:
os
.
environ
[
"QT_QPA_FONTDIR"
]
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"qt"
,
"fonts"
)
import
importlib
import
os
import
sys
from
.cv2
import
*
from
.data
import
*
# wildcard import above does not import "private" variables like __version__
# this makes them available
globals
().
update
(
importlib
.
import_module
(
"cv2.cv2"
).
__dict__
)
ci_and_not_headless
=
False
try
:
from
.version
import
ci_build
,
headless
ci_and_not_headless
=
ci_build
and
not
headless
except
:
pass
# the Qt plugin is included currently only in the pre-built wheels
if
(
sys
.
platform
==
"darwin"
or
sys
.
platform
.
startswith
(
"linux"
)
)
and
ci_and_not_headless
:
os
.
environ
[
"QT_QPA_PLATFORM_PLUGIN_PATH"
]
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"qt"
,
"plugins"
)
# Qt will throw warning on Linux if fonts are not found
if
sys
.
platform
.
startswith
(
"linux"
)
and
ci_and_not_headless
:
os
.
environ
[
"QT_QPA_FONTDIR"
]
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"qt"
,
"fonts"
)
find_version.py
浏览文件 @
6ee82a39
import
sys
import
os
import
subprocess
if
__name__
==
"__main__"
:
contrib
=
sys
.
argv
[
1
]
headless
=
sys
.
argv
[
2
]
ci_build
=
sys
.
argv
[
3
]
opencv_version
=
""
# dig out the version from OpenCV sources
version_file_path
=
"opencv/modules/core/include/opencv2/core/version.hpp"
with
open
(
version_file_path
,
"r"
)
as
f
:
for
line
in
f
:
words
=
line
.
split
()
if
"CV_VERSION_MAJOR"
in
words
:
opencv_version
+=
words
[
2
]
opencv_version
+=
"."
if
"CV_VERSION_MINOR"
in
words
:
opencv_version
+=
words
[
2
]
opencv_version
+=
"."
if
"CV_VERSION_REVISION"
in
words
:
opencv_version
+=
words
[
2
]
break
# used in local dev releases
git_hash
=
(
subprocess
.
check_output
([
"git"
,
"rev-parse"
,
"--short"
,
"HEAD"
])
.
splitlines
()[
0
]
.
decode
()
)
# this outputs the annotated tag if we are exactly on a tag, otherwise <tag>-<n>-g<shortened sha-1>
try
:
tag
=
(
subprocess
.
check_output
(
[
"git"
,
"describe"
,
"--tags"
],
stderr
=
subprocess
.
STDOUT
)
.
splitlines
()[
0
]
.
decode
()
.
split
(
"-"
)
)
except
subprocess
.
CalledProcessError
as
e
:
# no tags reachable (e.g. on a topic branch in a fork), see
# https://stackoverflow.com/questions/4916492/git-describe-fails-with-fatal-no-names-found-cannot-describe-anything
if
e
.
output
.
rstrip
()
==
b
"fatal: No names found, cannot describe anything."
:
tag
=
[]
else
:
print
(
e
.
output
)
raise
if
len
(
tag
)
==
1
:
# tag identifies the build and should be a sequential revision number
version
=
tag
[
0
]
opencv_version
+=
".{}"
.
format
(
version
)
else
:
# local version identifier, not to be published on PyPI
version
=
git_hash
opencv_version
+=
"+{}"
.
format
(
version
)
with
open
(
"cv2/version.py"
,
"w"
)
as
f
:
f
.
write
(
'opencv_version = "{}"
\n
'
.
format
(
opencv_version
))
f
.
write
(
"contrib = {}
\n
"
.
format
(
contrib
))
f
.
write
(
"headless = {}
\n
"
.
format
(
headless
))
f
.
write
(
"ci_build = {}"
.
format
(
ci_build
))
import
sys
import
os
import
subprocess
if
__name__
==
"__main__"
:
contrib
=
sys
.
argv
[
1
]
headless
=
sys
.
argv
[
2
]
ci_build
=
sys
.
argv
[
3
]
opencv_version
=
""
# dig out the version from OpenCV sources
version_file_path
=
"opencv/modules/core/include/opencv2/core/version.hpp"
with
open
(
version_file_path
,
"r"
)
as
f
:
for
line
in
f
:
words
=
line
.
split
()
if
"CV_VERSION_MAJOR"
in
words
:
opencv_version
+=
words
[
2
]
opencv_version
+=
"."
if
"CV_VERSION_MINOR"
in
words
:
opencv_version
+=
words
[
2
]
opencv_version
+=
"."
if
"CV_VERSION_REVISION"
in
words
:
opencv_version
+=
words
[
2
]
break
# used in local dev releases
git_hash
=
(
subprocess
.
check_output
([
"git"
,
"rev-parse"
,
"--short"
,
"HEAD"
])
.
splitlines
()[
0
]
.
decode
()
)
# this outputs the annotated tag if we are exactly on a tag, otherwise <tag>-<n>-g<shortened sha-1>
try
:
tag
=
(
subprocess
.
check_output
(
[
"git"
,
"describe"
,
"--tags"
],
stderr
=
subprocess
.
STDOUT
)
.
splitlines
()[
0
]
.
decode
()
.
split
(
"-"
)
)
except
subprocess
.
CalledProcessError
as
e
:
# no tags reachable (e.g. on a topic branch in a fork), see
# https://stackoverflow.com/questions/4916492/git-describe-fails-with-fatal-no-names-found-cannot-describe-anything
if
e
.
output
.
rstrip
()
==
b
"fatal: No names found, cannot describe anything."
:
tag
=
[]
else
:
print
(
e
.
output
)
raise
if
len
(
tag
)
==
1
:
# tag identifies the build and should be a sequential revision number
version
=
tag
[
0
]
opencv_version
+=
".{}"
.
format
(
version
)
else
:
# local version identifier, not to be published on PyPI
version
=
git_hash
opencv_version
+=
"+{}"
.
format
(
version
)
with
open
(
"cv2/version.py"
,
"w"
)
as
f
:
f
.
write
(
'opencv_version = "{}"
\n
'
.
format
(
opencv_version
))
f
.
write
(
"contrib = {}
\n
"
.
format
(
contrib
))
f
.
write
(
"headless = {}
\n
"
.
format
(
headless
))
f
.
write
(
"ci_build = {}"
.
format
(
ci_build
))
setup.py
浏览文件 @
6ee82a39
此差异已折叠。
点击以展开。
tests/test.py
浏览文件 @
6ee82a39
import
unittest
import
sys
class
OpenCVTest
(
unittest
.
TestCase
):
""" Simple functionality tests. """
def
test_import
(
self
):
""" Test that the cv2 module can be imported. """
import
cv2
def
test_video_capture
(
self
):
import
cv2
cap
=
cv2
.
VideoCapture
(
"SampleVideo_1280x720_1mb.mp4"
)
self
.
assertTrue
(
cap
.
isOpened
())
import
unittest
import
sys
class
OpenCVTest
(
unittest
.
TestCase
):
""" Simple functionality tests. """
def
test_import
(
self
):
""" Test that the cv2 module can be imported. """
import
cv2
def
test_video_capture
(
self
):
import
cv2
cap
=
cv2
.
VideoCapture
(
"SampleVideo_1280x720_1mb.mp4"
)
self
.
assertTrue
(
cap
.
isOpened
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录