简单的opencv 3.x图像处理函数
opencvutils的Python项目详细描述
opencv实用程序
这是一组opencv实用程序,应该使使用opencv a 稍微容易一点。我用叉子叉了这个,为我在春天教的一门课增加了一些东西 2018年。你应该使用阿德里安的图书馆,链接如下。
原作者:adrian rosebrock
原始名称:imutils
安装
首选的安装方式是使用pip
:
pip install opencvutils
其他库
您需要同时使用numpy
和opencv3
才能正常工作。使用你的操作系统
要安装的包管理器。不幸的是,这不是很快,numpy
安装需要编译一些东西,所以去喝杯咖啡什么的
在你等待的时候。
对于macos(请注意,brew
人们一直在改变这个!):
pip install numpy
brew install opencv
开发
要提交git拉取,请克隆存储库并按如下方式设置:
git clone https://github.com/walchko/opencvutils
cd opencvutils
pip install -e .
文档
参见Jupyter Notebooks了解 如何使用此库的示例。它包含了很多常见的图像 操纵。
视频编码
您可以制作这样的视频:
importcv2fromopencvutils.CameraimportSaveVideoshape=(240,320)# rows (height), cols (width)sv=SaveVideo()# you can change the default encoder using a four_cc# string, but not all of them work!# sv.encoder('H264')# sv.encoder('MP4V')# sv.encoder('x264')sv.open(filename,shape[1],shape[0])# order is backwards from opencv!!!foriinrange(100):ret,img=camera.read()# grab imagesv.write(img)sv.release()
脚本
pi@raspberry ~ $ mjpeg_server.py -h usage: mjpeg_server.py [-h] [-v] [-p PORT] [-c CAMERA] [-t TYPE] [-s SIZE SIZE] A simple mjpeg server Example: mjpeg-server -p 8080 --camera 4 optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit -p PORT, --port PORT mjpeg publisher port, default is 9000 -c CAMERA, --camera CAMERA set opencv camera number, ex. -c 1 -t TYPE, --type TYPE set camera type, either pi or cv, ex. -t pi -s SIZE SIZE, --size SIZE SIZE set size
然后您可以:
pi@raspberry ~ $ mjpeg_server.py -t pi -s 640 480
现在导航到您的计算机(主机名:9000),您将看到
MJPG流。注意,如果您使用-p
参数更改了端口号,
然后使用那个端口号。
更改日志
Data | Version | Notes |
---|---|---|
2018-07-19 | 0.9.4 | simple clean-up and updating some things |
2017-10-29 | 0.9.3 | bug fixes |
2017-04-09 | 0.9.0 | initial python 3 support |
2017-03-31 | 0.7.0 | refactored and got rid of things I don't need |
2017-01-29 | 0.6.0 | added video capture (video and images) program |
2016-12-30 | 0.5.3 | typo fix |
2016-12-30 | 0.5.1 | refactored |
2016-12-11 | 0.5.0 | published to PyPi |
麻省理工学院许可证
版权所有(C)2016 Kevin J.Walchko 版权所有(c)2014 Adrian Rosebrock
特此免费向任何获得 本软件和相关文档文件的副本 “软件”),无限制地处理软件,包括 但不限于使用、复制、修改、合并、发布, 分发、再授权和/或出售软件副本,以及 允许向其提供软件的人员这样做,但须遵守 以下条件:
上述版权公告及本许可公告须包括在内 在软件的所有副本或大部分中。
软件按“原样”提供,不作任何保证, 明示或默示,包括但不限于 适销性、适合特定目的和不侵权。 在任何情况下,作者或版权持有人均不对任何 索赔、损害赔偿或其他责任,无论是在合同诉讼中, 侵权行为或其他,由 软件或软件中的使用或其他交易。