提交 426cd8a6 编写于 作者: W wizardforcel

2019-11-18 18:40:47

上级 0eeb5772
# 级联汽车跟
# 使用级联的汽车追
> 原文: [https://pythonspot.com/car-tracking-with-cascades/](https://pythonspot.com/car-tracking-with-cascades/)
......
# Google 环聊视频中的人脸检测
# Google Hangouts 视频中的人脸检测
> 原文: [https://pythonspot.com/face-detection-in-video/](https://pythonspot.com/face-detection-in-video/)
......@@ -6,7 +6,7 @@
使用 OpenCV(Open Computer Vision)库实现面部检测。 最常见的面部检测方法是[提取级联](https://docs.opencv.org/modules/objdetect/doc/cascade_classification.html#haar-feature-based-cascade-classifier-for-object-detection)。 已知该技术可以很好地与人脸检测配合使用。 您需要将级联文件(包含在 OpenCV 中)放在程序所在的目录中。
## 带有 Python OpenCV 的视频
## Python OpenCV 和视频
为了分析输入视频,我们提取每个帧。 每个帧显示的时间很短。 从这个基本程序开始:
......
......@@ -9,7 +9,9 @@
补丁是具有某些功能的小图像。 模板匹配的目的是在图像中找到补丁/模板。
<caption id=”attachment_4826” align=”alignright” width=”948”]![template matching opencv](img/3d85797cd44b2c4b3348bfd4fc8a7795.jpg) Template matching with OpenCV and Python. Template (left), result image (right)
![template matching opencv](img/3d85797cd44b2c4b3348bfd4fc8a7795.jpg)
Template matching with OpenCV and Python. Template (left), result image (right)
[下载代码](https://pythonspot.com/download-vision-examples/)
......
# Netflix 喜欢使用 Python 的缩略图
# Python 和 Netflix 点赞图标
> 原文: [https://pythonspot.com/netflix-like-thumbnails-with-python/](https://pythonspot.com/netflix-like-thumbnails-with-python/)
[Netflix](https://techblog.netflix.com/2016/03/extracting-image-metadata-at-scale.html) 的启发,我们决定实施对焦点算法。 如果您在移动网站上使用生成的缩略图,则可能会增加 YouTube 视频的点击率(CTR)。
Eiterway,这是一个有趣的实验。
## 联络人
## 焦点
所有图像都有一个感兴趣的区域,通常是人或脸。
......@@ -14,9 +14,7 @@ Eiterway,这是一个有趣的实验。
![Netflix like Thumbnails Python](img/4ff0874e193357fd06d6aca13d7dc8c4.jpg)
Netflix like Thumbnails Python. Source: Google videos. **Related course:**
* [使用 OpenCV 掌握计算机视觉](https://gum.co/GQWGG)
Netflix like Thumbnails Python. Source: Google videos.
从要用作缩略图的快照图像开始。 我们使用 Haar 功能查找图像中最有趣的区域。 Haar 级联文件可以在以下位置找到:
......
# 使用 Python 的简单文字游戏
# Python 和简单文字游戏
> 原文: [https://pythonspot.com/simple-text-game](https://pythonspot.com/simple-text-game)
......@@ -13,10 +13,6 @@
Simple text game with Python
## 您可能喜欢
[面向初学者的 Python 游戏开发](https://gum.co/CfzHE)
## 随机数
The user will be asked to guess the random number. We first pick the random number:
......@@ -44,7 +40,7 @@ while guess != x:
```
## Python 猜游戏
## Python 猜游戏
The code below starts the game:
......
......@@ -10,10 +10,6 @@ Pygame Python
在本教程中,我们将解释使用 Pygame 构建游戏的基础。 我们将从基础开始,并教您如何创建基础框架。 在接下来的教程中,您将学习如何制作某些类型的游戏。
## 您可能喜欢
[面向初学者的 Python 游戏开发](https://gum.co/CfzHE)
## PyGame 简介
您将得到一个与右边的程序相似的程序:
......
# 蛇与 Pygame
# Pygame 贪食蛇
> 原文: [https://pythonspot.com/snake-with-pygame/](https://pythonspot.com/snake-with-pygame/)
......@@ -44,7 +44,7 @@ if (keys[K_RIGHT]):
```
完整的代码使我们能够在屏幕上移动播放器
完整的代码使我们能够在屏幕上移动玩家
```py
from pygame.locals import *
......@@ -141,9 +141,9 @@ if __name__ == "__main__" :
pygame example. Move the block around the screen
## 构建播放器(蛇)
## 构建玩家(蛇)
播放器控制具有初始长度的蛇。 按下箭头键时,这条蛇总是在移动并改变其移动方向。 为此,更新播放器类:
玩家控制具有初始长度的蛇。 按下箭头键时,这条蛇总是在移动并改变其移动方向。 为此,更新玩家类:
```py
class Player:
......
# Pygame 中的 Snake AI
# Pygame 中的贪食蛇 AI
> 原文: [https://pythonspot.com/snake-ai-in-pygame/](https://pythonspot.com/snake-ai-in-pygame/)
......@@ -6,14 +6,9 @@
在此游戏(蛇)中,计算机和您都在玩蛇,而计算机蛇会尝试抓住您。 简而言之:对手 AI 会根据您在棋盘上的位置尝试确定并前往目的地。
## 您可能喜欢
## 添加计算机玩家:
* [使用 Python Pygame 开发游戏](https://gum.co/CfzHE)
## 添加计算机播放器:
我们使用名为 Computer 的新类扩展了代码,它将成为我们的计算机播放器。 这包含绘制和移动计算机蛇的例程。
我们使用名为 Computer 的新类扩展了代码,它将成为我们的计算机玩家。 这包含绘制和移动计算机蛇的例程。
```py
class Computer:
......@@ -96,9 +91,9 @@ class Computer:
这将使计算机蛇移动并在屏幕上绘制。 它具有与人类玩家相同的属性。
## 为计算机播放器添加智能
## 为计算机玩家添加智能
因为这是一个简单的游戏,所以我们无需在游戏内部创建完整的思维机。 我们只需要计算机播放器展示一些基本情报即可。 游戏中的智能通常非常有限,因为在大多数情况下,不需要复杂性或根本没有时间实现聪明的算法。
因为这是一个简单的游戏,所以我们无需在游戏内部创建完整的思维机。 我们只需要计算机玩家展示一些基本情报即可。 游戏中的智能通常非常有限,因为在大多数情况下,不需要复杂性或根本没有时间实现聪明的算法。
我们将添加的算法将仅到达目的地。 它将忽略任何障碍(人类玩家)。
......@@ -388,6 +383,6 @@ python snake
## 结论
您学习了如何使用非常简单的 AI 算法创建基本的计算机播放器
您学习了如何使用非常简单的 AI 算法创建基本的计算机玩家
[下一步:学习基本的侧滑器逻辑](https://pythonspot.com/jump-and-run-in-pygame/)
\ No newline at end of file
# 跳并在 Pygame 中运行
# Pygame 中的跳和跑
> 原文: [https://pythonspot.com/jump-and-run-in-pygame/](https://pythonspot.com/jump-and-run-in-pygame/)
在本文中,您将学习如何在 Pygame 中实现跳转和运行逻辑。 为此,我们将实现播放器逻辑。
## 您可能喜欢
[面向初学者的 Python 游戏开发](https://gum.co/CfzHE)
在本文中,您将学习如何在 Pygame 中实现跳和跑逻辑。 为此,我们将实现玩家逻辑。
## 移动
左右移动与上一教程类似,只是意味着更改播放器的(x,y)位置。 对于跳跃,我们使用经典力学中的公式:
左右移动与上一教程类似,只是意味着更改玩家的(x,y)位置。 对于跳跃,我们使用经典力学中的公式:
```py
F = 1/2 * m * v^2
......
......@@ -46,7 +46,7 @@ os.system("mpg321 hello.mp3")
[&lt;picture&gt;&lt;source srcset="/wp-content/uploads/2015/07/gtts.png.webp" type="image/webp"&gt; &lt;source srcset="/wp-content/uploads/2015/07/gtts.png" type="image/jpeg"&gt; ![gtts](img/538e4461fb4b4cc380ce7b29759028f8.jpg)&lt;/picture&gt; ](/wp-content/uploads/2015/07/gtts.png)
### 完程序
### 完程序
The program below will answer spoken questions.
......
......@@ -6,7 +6,7 @@
## 目录列表
我们可以使用列出根目录 这个小片段
我们可以使用这个小片段列出根目录
```py
import ftplib
......
# 阅读电子邮件,pop3
# 读取电子邮件,pop3
> 原文: [https://pythonspot.com/read-email-pop3/](https://pythonspot.com/read-email-pop3/)
[toc]在本教程中,您将学习如何使用 **poplib** 模块来**接收电子邮件**。 邮件服务器需要支持 **pop3** ,但是大多数邮件服务器都支持。 邮局协议(POP3)仅用于接收邮件,发送时需要 SMTP 协议。
在本教程中,您将学习如何使用 **poplib** 模块来**接收电子邮件**。 邮件服务器需要支持 **pop3** ,但是大多数邮件服务器都支持。 邮局协议(POP3)仅用于接收邮件,发送时需要 SMTP 协议。
![pop3-email-server](img/b7a7593691fc70c549881f1570ecc3b1.jpg)
......@@ -20,7 +20,7 @@ Every email will contain many variables, but these are the most important ones:
| 日期 | 日期 |
| 学科 | 电子邮件主题。 |
## 阅读电子邮件示例
## 读取电子邮件示例
You can request messages directly from a mail server using the Post Office Protocol (protocol). You do not have to worry about the internal protocol because you can use the poplib module.
Connect and authenticate with the server using:
......
......@@ -62,7 +62,7 @@ print(links)
```
## 从网页提取链接的功能
## 从网页提取链接的函数
If you repeatingly extract links you can use the function below:
......@@ -85,7 +85,3 @@ def getLinks(url):
print( getLinks("https://arstechnica.com") )
```
## 相关课程:
[使用 Python Selenium 的浏览器自动化](https://gum.co/GjuJxo)
\ No newline at end of file
......@@ -26,7 +26,7 @@ plt.show()
Python histogram
## 完整的 matplotlib python 直方图
## 完整的 matplotlib 直方图
许多东西都可以添加到直方图中,例如拟合线,标签等。 下面的代码创建了更高级的直方图。
......
......@@ -4,7 +4,7 @@
[Matplotlib](https://pythonspot.com/matplotlib/) 可用于创建条形图。 您可能喜欢 [Matplotlib 图库](https://pythonspot.com/matplotlib-gallery/)
## Bar chart code
## 条形图代码
The code below creates a bar chart:
......
......@@ -6,9 +6,9 @@ Matplotlib 对图例具有本机支持。 图例可以放置在各个位置:
legend()方法将图例添加到绘图中。 在本文中,我们将向您展示一些使用 matplotlib 的图例示例。
## Matplotlib 图例位于
## Matplotlib 内部图例
中,要将图例放置在其中,只需调用 legend():
要将图例放置在内部,只需调用 legend():
```py
......@@ -32,7 +32,7 @@ plt.show()
[Matplotlib](https://pythonspot.com/matplotlib/) legend inside
## Matplotlib 图例位于底部
## Matplotlib 底部图例
要将图例置于底部,请将 legend()调用更改为:
......@@ -68,7 +68,7 @@ plt.show()
Legend placed on bottom
## Matplotlib 图例在顶部
## Matplotlib 顶部图例
要将图例放在顶部,请更改 bbox_to_anchor 值:
......@@ -102,9 +102,9 @@ plt.show()
Legend on top
## 右图例之外的
## 外部右侧图例
我们可以通过调整框的大小并相对于图例放置图例来放置图例 ouside
我们可以通过调整框的大小并相对于图例放置图例来在外部放置图例
```py
......
......@@ -2,7 +2,7 @@
> 原文: [https://pythonspot.com/matplotlib-save-figure-to-image-file/](https://pythonspot.com/matplotlib-save-figure-to-image-file/)
## Save figure
## 保存图形
[Matplotlib](https://pythonspot.com/matplotlib/) can save plots directly to a file using savefig().
The method can be used like this:
......
# Matplotlib 更新图
# Matplotlib 更新
> 原文: [https://pythonspot.com/matplotlib-update-plot/](https://pythonspot.com/matplotlib-update-plot/)
更新 [**matplotlib**](https://pythonspot.com/matplotlib/)图非常简单。 创建数据,绘图并循环更新。
更新 [**matplotlib**](https://pythonspot.com/matplotlib/)图非常简单。 创建数据,绘图并循环更新。
启用交互模式至关重要:plt.ion()。 这控制是否通过每个 draw()命令重绘图形。 如果它为 False(默认值),则该图不会自动更新。
## Related course:
* [使用 Matplotlib 和 Python 进行数据可视化](https://gum.co/mpdp)
## 更新图示例
## 更新绘图示例
复制下面的代码以测试交互式绘图。
......
# 常用表达
# 正则表达式
> 原文: [https://pythonspot.com/regular-expressions/](https://pythonspot.com/regular-expressions/)
......@@ -6,7 +6,7 @@
在 Python 中,您需要 **re** 模块来使用正则表达式。 语法概述在此页面的底部。
## 匹配功能
## 匹配函数
The match function is defined as:
......@@ -71,7 +71,7 @@ else:
|
## 搜索功能
## 搜索函数
The search function is defined as:
......
......@@ -45,7 +45,7 @@ Installation path: /usr/lib/python2.7/dist-packages/qutip
## 量子数据结构
在量子系统中,我们需要一个能够封装量子算子和 ket / bra 向量的属性的数据结构,为此我们使用 Qobj 数据结构。 换句话说,为了有效地模拟量子应用,我们需要使用适当的数据结构。 考虑下面的示例:
在量子系统中,我们需要一个能够封装量子运算符和 ket / bra 向量的属性的数据结构,为此我们使用 Qobj 数据结构。 换句话说,为了有效地模拟量子应用,我们需要使用适当的数据结构。 考虑下面的示例:
```py
#!/usr/bin/env python
......@@ -102,13 +102,13 @@ Qobj data =
```
## 量子态和算符
## 量子态和算符
量子系统不是简单的两级系统,它具有多个状态。 QuTip 包括此处列出的[一些预定义状态和量子运算符。](http://qutip.org/docs/2.2.0/guide/guide-basics.html#first-things-first)
## Qubit 和运算符
## 量子位和运算符
我们创建一个 Qubit 来保存数据。 量子位是经典位的量子模拟。 与传统位不同,量子位可以同时处于两种状态的叠加,这是量子计算的基础。 下面的代码将创建一个量子位:
我们创建一个量子位来保存数据。 量子位是经典位的量子模拟。 与传统位不同,量子位可以同时处于两种状态的叠加,这是量子计算的基础。 下面的代码将创建一个量子位:
```py
#!/usr/bin/env python
......
......@@ -89,7 +89,7 @@ We have two options to add Python into a chrome extension:
* 方法 B:使用 Rapydscript(最佳,无服务器,纯扩展)将 Python 编译为 Javascript。
## 方法 A:iframe 中的 Python(Brython)
## 方法 A:`iframe`中的 Python(Brython)
Now that you have the basics right we can add Python to the code. To run Python in the browser you have several options including Brython and emcascripten. We decided to give Brython a try. We will run the Brython script from a server. Change popup.html to:
......@@ -136,7 +136,7 @@ Python inside Google Chrome
该脚本应在您自己的服务器上运行。 您可以从网络运行任何 Brython 脚本。 使用 Brython,您只需在 script 标签内键入 Python 代码。 看看[这个](view-source:http://brython.info/gallery/hello.html) Brython 示例,或者只是[浏览图库](http://brython.info/gallery/gallery_en.html?lang=en)
## 方法 B:将 Python 编译为 Javascript。 (无服务器,纯扩展名
## 方法 B:将 Python 编译为 Javascript(无服务器,纯扩展
There are several tools to compile Python to Javascript. [Rapydscript](http://www.rapydscript.com/) works fine, [Pyjs](http://pyjs.org/) does not work well with chrome (requires special parameter on start).
Install Rapydscript with:
......@@ -185,4 +185,3 @@ console.log('hello from python')
Chrome plugins are created using HTML, JavaScript and CSS. We can use Python to create normal Chrome extensions using a Python to Javascript compiler (Rapydscript).
发表评论:-)
\ No newline at end of file
......@@ -2,10 +2,6 @@
> 原文: [https://pythonspot.com/fun-tricks-with-python/](https://pythonspot.com/fun-tricks-with-python/)
## 您可能会喜欢:
[Python 编程训练营:从零转到英雄](https://gum.co/dcsp)
## 启动简单的 HTTP Web 服务器
可以在几秒钟内启动简单的 HTTP 服务器。
......@@ -44,7 +40,7 @@ import antigravity
```
## 使用 Zip 合并数组
## 使用`zip`合并数组
您可以使用以下命令压缩两个数组:
......@@ -67,7 +63,7 @@ print b
```
## 反字符串
## 反字符串
可以使用以下方法来代替创建反向字符串的方法:
......
......@@ -2,27 +2,23 @@
> 原文: [https://pythonspot.com/speech-engines-with-python-tutorial/](https://pythonspot.com/speech-engines-with-python-tutorial/)
![Text To Speech (TTS)
![Text To Speech (TTS)](/wp-content/uploads/2016/07/tts.png)
](/wp-content/uploads/2016/07/tts.png) Text To Speech (TTS)
Text To Speech (TTS)
用于创建人工语音的计算机系统称为语音合成器,可以在软件或硬件产品中实现。
**文本到语音(TTS)**系统将普通语言文本转换为语音。 我们如何在 Python 中使用语音合成?
## Related courses:
* [针对 Python 开发人员的机器学习入门](https://gum.co/MnRYU)
* [使用 OpenCV 掌握计算机视觉](https://gum.co/GQWGG)
## 派克斯
## Pyttsx
[Pyttsx](https://pypi.python.org/pypi/pyTTS/3.0) is a cross-platform speech (Mac OSX, Windows, and Linux) library. You can set voice metadata such as age, gender, id, language and name. Thee speech engine comes with a large amount of voices.
文字转语音样本:
<audio controls="">Your browser does not support the audio element.</audio>
<https://pythonspot.com/wp-content/uploads/2016/08/pytts.wav>
安装方式:
......@@ -45,7 +41,7 @@ engine.runAndWait()
并使用 python 执行它。
## 说话
## eSpeak
[eSpeak](https://espeak.sourceforge.net/) is a compact open source software speech synthesizer for English and other languages, for Linux and Windows.
......@@ -72,7 +68,7 @@ os.system("espeak 'The quick brown fox'")
它非常易于使用,但是像 pyttsx 一样听起来很机器人。
## 交易
## gTTS
The [**gtts module no longer works**](https://stackoverflow.com/questions/9893175/google-text-to-speech-api).
......
......@@ -42,7 +42,7 @@ The second icon (Editor) will start the Python IDE. It has syntax highlighting a
QPython IDE
## 口译员
## 解释器
You can use the Python interpreter directly on your Android device. This is similar to starting the Python interpreter on Windows or Linux. While useful at times, you probably prefer using the IDE.
......
......@@ -97,9 +97,9 @@ cv2.waitKey(0)
要更改整个图像,您必须更改所有通道:m [py] [px] [0],m [py] [px] [1],m [py] [px] [2]。
## 保存
## 保存
您可以使用以下方法将修改后的像保存到磁盘:
您可以使用以下方法将修改后的像保存到磁盘:
```py
cv2.imwrite('filename.png',m)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册