|
@@ -1,6 +1,6 @@
|
|
-# 人工智能
|
|
|
|
|
|
+# 人工智慧
|
|
|
|
|
|
-## 自定义模型识别
|
|
|
|
|
|
+## 自訂模型識別
|
|
|
|
|
|
```python
|
|
```python
|
|
from AI import CustomModel
|
|
from AI import CustomModel
|
|
@@ -11,46 +11,46 @@ from AI import CustomModel
|
|
CustomModel(labels,path)
|
|
CustomModel(labels,path)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| labels | list | 标签列表,必填 |
|
|
|
|
-| path | str | 模型路径,必填 |
|
|
|
|
|
|
+| labels | 列表 | 標籤列表,必填 |
|
|
|
|
+| path | 字串 | 模型路徑,必填 |
|
|
|
|
|
|
-### 加载识别
|
|
|
|
|
|
+### 載入識別
|
|
```python
|
|
```python
|
|
loadModel(img)
|
|
loadModel(img)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| img | image.Image() | 要识别的Image对象,必填 |
|
|
|
|
|
|
+| img | 圖片 | 要識別的Image對象,必填 |
|
|
|
|
|
|
-### 样例
|
|
|
|
|
|
+### 樣例
|
|
```python
|
|
```python
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import CustomModel
|
|
from AI import CustomModel
|
|
|
|
|
|
-Screen = Screen() # 画布初始化
|
|
|
|
-camera = cameraPython() # 摄像头初始化
|
|
|
|
|
|
+Screen = Screen() # 畫布初始化
|
|
|
|
+camera = cameraPython() # 攝像頭初始化
|
|
|
|
|
|
-labels = ["loadModel", "unload", "left", "right", "forward", "stop"] # 标签
|
|
|
|
-path = "/root/preset/model/autologistics" # 模型路径
|
|
|
|
|
|
+labels = ["load", "unload", "left", "right", "forward", "stop"] # 標籤
|
|
|
|
+path = "/root/preset/model/autologistics" # 模型路徑
|
|
CustomModel = CustomModel(labels,path) # 初始化模型
|
|
CustomModel = CustomModel(labels,path) # 初始化模型
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- canvas = camera.capture() # 获取摄像头图像
|
|
|
|
- canvas = canvas.crop(48,8,224,224) # 裁剪图像为224*224
|
|
|
|
- data = CustomModel.loadModel(canvas) # 加载模型进行识别
|
|
|
|
|
|
+ canvas = camera.capture() # 獲取攝像頭圖像
|
|
|
|
+ canvas = canvas.crop(48,8,224,224) # 裁剪圖像為224*224
|
|
|
|
+ data = CustomModel.load(canvas) # 載入模型進行識別
|
|
for i in data:
|
|
for i in data:
|
|
- canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=(255,0,0),thickness=1) # 在屏幕绘制检测框
|
|
|
|
- canvas.draw_string(i["X"],i["Y"]-20,(str(i["name"])+":"+str(i["score"])),color=(255,0,0)) # 在屏幕上绘制名称与置信度
|
|
|
|
- Screen.show(canvas,48,8) # 显示画布
|
|
|
|
|
|
+ canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=(255,0,0),thickness=1) # 在螢幕繪製檢測框
|
|
|
|
+ canvas.draw_string(i["X"],i["Y"]-20,(str(i["name"])+":"+str(i["score"])),color=(255,0,0)) # 在螢幕上繪製名稱與置信度
|
|
|
|
+ Screen.show(canvas,48,8) # 顯示畫布
|
|
```
|
|
```
|
|
-其中i["X"]表示识别结果的检测框起点X轴坐标,i["Y"]表示识别结果的检测框起点Y轴坐标,i["W"]表示识别结果的检测框宽度,i["H"]表示识别结果的检测框高度,i["name"]表示识别结果的名称,i["score"]表示识别结果的置信度,i["middleX"]表示识别结果的检测框中心点的X轴坐标,i["middleY"]表示识别结果的检测框中心点的Y轴坐标。
|
|
|
|
|
|
+其中i["X"]表示識別結果的檢測框起點X軸坐標,i["Y"]表示識別結果的檢測框起點Y軸坐標,i["W"]表示識別結果的檢測框寬度,i["H"]表示識別結果的檢測框高度,i["name"]表示識別結果的名稱,i["score"]表示識別結果的置信度,i["middleX"]表示識別結果的檢測框中心點的X軸坐標,i["middleY"]表示識別結果的檢測框中心點的Y軸坐標。
|
|
|
|
|
|
-## 边缘检测
|
|
|
|
|
|
+## 邊緣檢測
|
|
|
|
|
|
```python
|
|
```python
|
|
from AI import EdgeDetection
|
|
from AI import EdgeDetection
|
|
@@ -61,33 +61,33 @@ from AI import EdgeDetection
|
|
EdgeDetection()
|
|
EdgeDetection()
|
|
```
|
|
```
|
|
|
|
|
|
-### 加载识别
|
|
|
|
|
|
+### 載入識別
|
|
```python
|
|
```python
|
|
loadModel(img)
|
|
loadModel(img)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| img | image.Image() | 要识别的Image对象,必填 |
|
|
|
|
|
|
+| img | 圖片 | 要識別的Image對象,必填 |
|
|
|
|
|
|
-### 样例
|
|
|
|
|
|
+### 樣例
|
|
```python
|
|
```python
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import EdgeDetection
|
|
from AI import EdgeDetection
|
|
|
|
|
|
-Screen = Screen() # 画布初始化
|
|
|
|
-camera = cameraPython() # 摄像头初始化
|
|
|
|
|
|
+Screen = Screen() # 畫布初始化
|
|
|
|
+camera = cameraPython() # 攝像頭初始化
|
|
EdgeDetection = EdgeDetection() # 初始化
|
|
EdgeDetection = EdgeDetection() # 初始化
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- img = camera.capture() # 获取摄像头数据
|
|
|
|
- img = img.crop(48,8,224,224) # 裁剪尺寸为224*224
|
|
|
|
- canvas = EdgeDetection.loadModel(img) # 加载模型
|
|
|
|
- Screen.show(canvas,48,8) # 显示画布
|
|
|
|
|
|
+ img = camera.capture() # 獲取攝像頭資料
|
|
|
|
+ img = img.crop(48,8,224,224) # 裁剪尺寸為224*224
|
|
|
|
+ canvas = EdgeDetection.load(img) # 載入模型
|
|
|
|
+ Screen.show(canvas,48,8) # 顯示畫布
|
|
```
|
|
```
|
|
|
|
|
|
-## 人脸检测
|
|
|
|
|
|
+## 人臉檢測
|
|
|
|
|
|
```python
|
|
```python
|
|
from AI import Facedetection
|
|
from AI import Facedetection
|
|
@@ -98,36 +98,36 @@ from AI import Facedetection
|
|
Facedetection()
|
|
Facedetection()
|
|
```
|
|
```
|
|
|
|
|
|
-### 加载识别
|
|
|
|
|
|
+### 載入識別
|
|
```python
|
|
```python
|
|
loadModel(img)
|
|
loadModel(img)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| img | image.Image() | 要识别的Image对象,必填 |
|
|
|
|
|
|
+| img | 圖片 | 要識別的Image對象,必填 |
|
|
|
|
|
|
-### 样例
|
|
|
|
|
|
+### 樣例
|
|
```python
|
|
```python
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import Facedetection
|
|
from AI import Facedetection
|
|
|
|
|
|
-Screen = Screen() # 画布初始化
|
|
|
|
-camera = cameraPython() # 摄像头初始化
|
|
|
|
-face = Facedetection() # 人脸检测初始化
|
|
|
|
|
|
+Screen = Screen() # 畫布初始化
|
|
|
|
+camera = cameraPython() # 攝像頭初始化
|
|
|
|
+face = Facedetection() # 人臉檢測初始化
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- canvas = camera.capture() # 获取摄像头图像
|
|
|
|
- canvas = canvas.crop(48,8,224,224) # 裁剪图像尺寸
|
|
|
|
- data = face.loadModel(canvas) # 加载人脸检测模型
|
|
|
|
|
|
+ canvas = camera.capture() # 獲取攝像頭圖像
|
|
|
|
+ canvas = canvas.crop(48,8,224,224) # 裁剪圖像尺寸
|
|
|
|
+ data = face.load(canvas) # 載入人臉檢測模型
|
|
for i in data:
|
|
for i in data:
|
|
- canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=(255,0,0), thickness=1) # 在屏幕上绘制人脸检测框
|
|
|
|
- canvas.draw_string(5,5,str(len(data)), scale = 1, color = (255,255,255) , thickness = 1) # 在屏幕上显示人脸数量
|
|
|
|
- Screen.show(canvas,48,8) # 显示画布
|
|
|
|
|
|
+ canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=(255,0,0), thickness=1) # 在螢幕上繪製人臉檢測框
|
|
|
|
+ canvas.draw_string(5,5,str(len(data)), scale = 1, color = (255,255,255) , thickness = 1) # 在螢幕上顯示人臉數量
|
|
|
|
+ Screen.show(canvas,48,8) # 顯示畫布
|
|
```
|
|
```
|
|
|
|
|
|
-## 人脸识别
|
|
|
|
|
|
+## 人臉識別
|
|
|
|
|
|
```python
|
|
```python
|
|
from AI import FaceRecognition
|
|
from AI import FaceRecognition
|
|
@@ -138,62 +138,63 @@ from AI import FaceRecognition
|
|
FaceRecognition()
|
|
FaceRecognition()
|
|
```
|
|
```
|
|
|
|
|
|
-### 加载模型
|
|
|
|
-加载人脸检测模型,获取人脸信息
|
|
|
|
|
|
+### 載入模型
|
|
|
|
+載入人臉檢測模型,獲取人臉資訊
|
|
```python
|
|
```python
|
|
loadmodel(img)
|
|
loadmodel(img)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| img | image.Image() | 要识别的Image对象,必填 |
|
|
|
|
|
|
+| img | 圖片 | 要識別的Image對象,必填 |
|
|
|
|
|
|
-### 添加人脸
|
|
|
|
-录入人脸信息保存到本地
|
|
|
|
|
|
+### 添加人臉
|
|
|
|
+錄入人臉資訊保存到本地
|
|
```python
|
|
```python
|
|
add(name,feature,dataPath)
|
|
add(name,feature,dataPath)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| name | str | 识别到的人脸名称,必填 |
|
|
|
|
-| feature | list | 人脸数据,必填 |
|
|
|
|
-| dataPath | str | 保存路径,选填,默认为"/root/user/model/recorded_face_features.py" |
|
|
|
|
|
|
+| name | 字串 | 識別到的人臉名稱,必填 |
|
|
|
|
+| feature | 列表 | 人臉資料,必填 |
|
|
|
|
+| dataPath | 字串 | 保存路徑,選填,預設為"/root/user/model/recorded_face_features.py" |
|
|
|
|
|
|
-### 删除人脸
|
|
|
|
-删除本地保存的最后一条人脸数据
|
|
|
|
|
|
+### 刪除人臉
|
|
|
|
+刪除本地指定人臉資料
|
|
```python
|
|
```python
|
|
remove(name,dataPath)
|
|
remove(name,dataPath)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| name | str | 要删除的人脸名称,必填 |
|
|
|
|
-| dataPath | str | 保存路径,选填,默认为"/root/user/model/recorded_face_features.py" |
|
|
|
|
|
|
+| name | 字串 | 要刪除的人臉名稱,必填 |
|
|
|
|
+| dataPath | 字串 | 保存路徑,選填,預設為"/root/user/model/recorded_face_features.py" |
|
|
|
|
|
|
-### 加载人脸信息
|
|
|
|
-加载人脸采集时保存到本地的人脸信息数据
|
|
|
|
|
|
+### 載入人臉信息
|
|
|
|
+載入人臉採集時保存到本地的人臉資訊資料
|
|
```python
|
|
```python
|
|
loadface(DataPath)
|
|
loadface(DataPath)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| dataPath | str | 保存路径,选填,默认为"/root/user/model/recorded_face_features.py" |
|
|
|
|
|
|
+| dataPath | 字串 | 保存路徑,選填,預設為""/root/user/model/recorded_face_features.py" |
|
|
|
|
|
|
-### 样例
|
|
|
|
-#### 人脸采集
|
|
|
|
|
|
+### 樣例
|
|
|
|
+
|
|
|
|
+#### 人臉採集
|
|
```python
|
|
```python
|
|
import time
|
|
import time
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import FaceRecognition
|
|
from AI import FaceRecognition
|
|
from CocoPi import BUTTON
|
|
from CocoPi import BUTTON
|
|
|
|
|
|
-# 按钮初始化
|
|
|
|
|
|
+# 按鈕初始化
|
|
key_C = BUTTON(13)
|
|
key_C = BUTTON(13)
|
|
key_D = BUTTON(7)
|
|
key_D = BUTTON(7)
|
|
|
|
|
|
@@ -201,40 +202,40 @@ Screen = Screen()
|
|
camera = cameraPython()
|
|
camera = cameraPython()
|
|
|
|
|
|
FaceRecognition = FaceRecognition()
|
|
FaceRecognition = FaceRecognition()
|
|
-People_list = ["小明","小红","小刚","小花"]
|
|
|
|
|
|
+People_list = ["小明","小紅","小剛","小花"]
|
|
|
|
|
|
FaceNum = 0
|
|
FaceNum = 0
|
|
faceScore = 0
|
|
faceScore = 0
|
|
color = (255,0,0)
|
|
color = (255,0,0)
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- canvas = camera.capture() # 获取摄像头数据
|
|
|
|
- canvas = canvas.crop(48,8,224,224) # 裁剪图片尺寸
|
|
|
|
- data = FaceRecognition.loadmodel(canvas) # 加载人脸检测模型
|
|
|
|
|
|
+ canvas = camera.capture() # 獲取攝像頭資料
|
|
|
|
+ canvas = canvas.crop(48,8,224,224) # 裁剪圖片尺寸
|
|
|
|
+ data = FaceRecognition.loadmodel(canvas) # 載入人臉檢測模型
|
|
for i in data:
|
|
for i in data:
|
|
- canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=color,thickness=1) # 检测框
|
|
|
|
|
|
+ canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=color,thickness=1) # 檢測框
|
|
if key_C.is_pressed() and FaceNum < len(People_list):
|
|
if key_C.is_pressed() and FaceNum < len(People_list):
|
|
while not key_C.is_pressed()== False:
|
|
while not key_C.is_pressed()== False:
|
|
time.sleep(0.01)
|
|
time.sleep(0.01)
|
|
- FaceRecognition.add(People_list[len(FaceRecognition)],i["feature"]) # 录入人脸保存
|
|
|
|
|
|
+ FaceRecognition.add(People_list[len(FaceRecognition)],i["feature"]) # 錄入人臉保存
|
|
canvas.draw_rectangle(0,0,320,20,color=(0,0,0),thickness=-1)
|
|
canvas.draw_rectangle(0,0,320,20,color=(0,0,0),thickness=-1)
|
|
- canvas.draw_string(0,0,"已采集"+str(People_list[FaceNum])+"人脸数据",scale=1,color=(255,255,255),thickness=1)
|
|
|
|
|
|
+ canvas.draw_string(0,0,"已採集"+str(People_list[FaceNum])+"人臉數據",scale=1,color=(255,255,255),thickness=1)
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
FaceNum = FaceNum + 1
|
|
FaceNum = FaceNum + 1
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
if key_D.is_pressed() and FaceNum > 0:
|
|
if key_D.is_pressed() and FaceNum > 0:
|
|
while not key_D.is_pressed()== False:
|
|
while not key_D.is_pressed()== False:
|
|
time.sleep(0.01)
|
|
time.sleep(0.01)
|
|
- FaceRecognition.remove(People_list[len(FaceRecognition)-1]) # 删除人脸
|
|
|
|
|
|
+ FaceRecognition.remove(People_list[len(FaceRecognition)-1]) # 刪除人臉
|
|
canvas.draw_rectangle(0,0,320,20,color=(0,0,0),thickness=-1)
|
|
canvas.draw_rectangle(0,0,320,20,color=(0,0,0),thickness=-1)
|
|
- canvas.draw_string(0,0,"已删除"+str(People_list[FaceNum-1])+"人脸数据",scale=1,color=(255,255,255),thickness=1)
|
|
|
|
|
|
+ canvas.draw_string(0,0,"已刪除"+str(People_list[FaceNum-1])+"人臉數據",scale=1,color=(255,255,255),thickness=1)
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
FaceNum = FaceNum - 1
|
|
FaceNum = FaceNum - 1
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
```
|
|
```
|
|
|
|
|
|
-#### 人脸识别
|
|
|
|
|
|
+#### 人臉識別
|
|
```python
|
|
```python
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import FaceRecognition
|
|
from AI import FaceRecognition
|
|
@@ -247,13 +248,13 @@ faceScore = 0
|
|
color = (255,0,0)
|
|
color = (255,0,0)
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- canvas = camera.capture() # 获取摄像头数据
|
|
|
|
- canvas = canvas.crop(48,8,224,224) # 裁剪图片尺寸
|
|
|
|
- data = FaceRecognition.loadmodel(canvas) # 加载人脸检测模型
|
|
|
|
|
|
+ canvas = camera.capture() # 獲取攝像頭資料
|
|
|
|
+ canvas = canvas.crop(48,8,224,224) # 裁剪圖片尺寸
|
|
|
|
+ data = FaceRecognition.loadmodel(canvas) # 載入人臉檢測模型
|
|
FaceRecognition.loadface()
|
|
FaceRecognition.loadface()
|
|
for i in data:
|
|
for i in data:
|
|
faceScore = round(i["recognizeScore"],2)
|
|
faceScore = round(i["recognizeScore"],2)
|
|
- canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=color,thickness=1) # 检测框
|
|
|
|
|
|
+ canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=color,thickness=1) # 檢測框
|
|
canvas.draw_string(i["X"],i["Y"],str(i["name"])+":"+str(faceScore),scale=1,color=color,thickness=1)
|
|
canvas.draw_string(i["X"],i["Y"],str(i["name"])+":"+str(faceScore),scale=1,color=color,thickness=1)
|
|
if faceScore > 80:
|
|
if faceScore > 80:
|
|
color = (0,255,0)
|
|
color = (0,255,0)
|
|
@@ -262,14 +263,14 @@ while True:
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
```
|
|
```
|
|
|
|
|
|
-#### 人脸识别+人脸采集
|
|
|
|
|
|
+#### 人臉採集並識別
|
|
```python
|
|
```python
|
|
import time
|
|
import time
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import FaceRecognition
|
|
from AI import FaceRecognition
|
|
from CocoPi import BUTTON
|
|
from CocoPi import BUTTON
|
|
|
|
|
|
-# 按钮初始化
|
|
|
|
|
|
+# 按鈕初始化
|
|
key_C = BUTTON(13)
|
|
key_C = BUTTON(13)
|
|
key_D = BUTTON(7)
|
|
key_D = BUTTON(7)
|
|
|
|
|
|
@@ -277,24 +278,24 @@ Screen = Screen()
|
|
camera = cameraPython()
|
|
camera = cameraPython()
|
|
|
|
|
|
FaceRecognition = FaceRecognition()
|
|
FaceRecognition = FaceRecognition()
|
|
-People_list = ["小明","小红","小刚","小花"]
|
|
|
|
|
|
+People_list = ["小明","小紅","小剛","小花"]
|
|
|
|
|
|
FaceNum = 0
|
|
FaceNum = 0
|
|
faceScore = 0
|
|
faceScore = 0
|
|
color = (255,0,0)
|
|
color = (255,0,0)
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- canvas = camera.capture() # 获取摄像头图像
|
|
|
|
- canvas = canvas.crop(48,8,224,224) # 裁剪图片尺寸
|
|
|
|
- data = FaceRecognition.loadmodel(canvas) # 加载人脸检测模型
|
|
|
|
|
|
+ canvas = camera.capture() # 獲取攝像頭圖像
|
|
|
|
+ canvas = canvas.crop(48,8,224,224) # 裁剪圖片尺寸
|
|
|
|
+ data = FaceRecognition.loadmodel(canvas) # 載入人臉檢測模型
|
|
for i in data:
|
|
for i in data:
|
|
- canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=color,thickness=1) # 检测框
|
|
|
|
|
|
+ canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=color,thickness=1) # 檢測框
|
|
if key_C.is_pressed() and FaceNum < len(People_list):
|
|
if key_C.is_pressed() and FaceNum < len(People_list):
|
|
while not key_C.is_pressed()== False:
|
|
while not key_C.is_pressed()== False:
|
|
time.sleep(0.01)
|
|
time.sleep(0.01)
|
|
- FaceRecognition.add(People_list[len(FaceRecognition)],i["feature"]) # 录入人脸保存
|
|
|
|
|
|
+ FaceRecognition.add(People_list[len(FaceRecognition)],i["feature"]) # 錄入人臉保存
|
|
canvas.draw_rectangle(0,0,320,20,color=(0,0,0),thickness=-1)
|
|
canvas.draw_rectangle(0,0,320,20,color=(0,0,0),thickness=-1)
|
|
- canvas.draw_string(0,0,"已采集"+str(People_list[FaceNum])+"人脸数据",scale=1,color=(255,255,255),thickness=1)
|
|
|
|
|
|
+ canvas.draw_string(0,0,"已採集"+str(People_list[FaceNum])+"人臉數據",scale=1,color=(255,255,255),thickness=1)
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
FaceNum = FaceNum + 1
|
|
FaceNum = FaceNum + 1
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
@@ -307,16 +308,16 @@ while True:
|
|
if key_D.is_pressed() and FaceNum > 0:
|
|
if key_D.is_pressed() and FaceNum > 0:
|
|
while not key_D.is_pressed()== False:
|
|
while not key_D.is_pressed()== False:
|
|
time.sleep(0.01)
|
|
time.sleep(0.01)
|
|
- FaceRecognition.remove(People_list[len(FaceRecognition)-1]) # 删除人脸
|
|
|
|
|
|
+ FaceRecognition.remove(People_list[len(FaceRecognition)-1]) # 刪除人臉
|
|
canvas.draw_rectangle(0,0,320,20,color=(0,0,0),thickness=-1)
|
|
canvas.draw_rectangle(0,0,320,20,color=(0,0,0),thickness=-1)
|
|
- canvas.draw_string(0,0,"已删除"+str(People_list[FaceNum-1])+"人脸数据",scale=1,color=(255,255,255),thickness=1)
|
|
|
|
|
|
+ canvas.draw_string(0,0,"已刪除"+str(People_list[FaceNum-1])+"人臉數據",scale=1,color=(255,255,255),thickness=1)
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
FaceNum = FaceNum - 1
|
|
FaceNum = FaceNum - 1
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
```
|
|
```
|
|
|
|
|
|
-## 数字识别
|
|
|
|
|
|
+## 數位識別
|
|
|
|
|
|
```python
|
|
```python
|
|
from AI import Digitalecognition
|
|
from AI import Digitalecognition
|
|
@@ -327,36 +328,36 @@ from AI import Digitalecognition
|
|
Digitalecognition()
|
|
Digitalecognition()
|
|
```
|
|
```
|
|
|
|
|
|
-### 加载识别
|
|
|
|
|
|
+### 載入識別
|
|
```python
|
|
```python
|
|
loadModel(img)
|
|
loadModel(img)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| img | image.Image() | 要识别的Image对象,必填 |
|
|
|
|
|
|
+| img | 圖片 | 要識別的Image對象,必填 |
|
|
|
|
|
|
-### 样例
|
|
|
|
|
|
+### 樣例
|
|
```python
|
|
```python
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import Digitalecognition
|
|
from AI import Digitalecognition
|
|
|
|
|
|
-Screen = Screen() # 画布初始化
|
|
|
|
-camera = cameraPython() # 摄像头初始化
|
|
|
|
-Digit = Digitalecognition() # 人脸检测初始化
|
|
|
|
|
|
+Screen = Screen() # 畫布初始化
|
|
|
|
+camera = cameraPython() # 攝像頭初始化
|
|
|
|
+Digit = Digitalecognition() # 人臉檢測初始化
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- canvas = camera.capture() # 获取摄像头图像
|
|
|
|
- canvas = canvas.crop(48,8,224,224) # 裁剪图像尺寸
|
|
|
|
- data = Digit.loadModel(canvas)
|
|
|
|
|
|
+ canvas = camera.capture() # 獲取攝像頭圖像
|
|
|
|
+ canvas = canvas.crop(48,8,224,224) # 裁剪圖像尺寸
|
|
|
|
+ data = Digit.load(canvas)
|
|
for i in data:
|
|
for i in data:
|
|
canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=(255,0,0),thickness=1)
|
|
canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=(255,0,0),thickness=1)
|
|
canvas.draw_string(i["X"],i["Y"]-20,(str(i["name"])+":"+str(i["score"])),color=(255,0,0))
|
|
canvas.draw_string(i["X"],i["Y"]-20,(str(i["name"])+":"+str(i["score"])),color=(255,0,0))
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
```
|
|
```
|
|
|
|
|
|
-## 物体检测
|
|
|
|
|
|
+## 物體檢測
|
|
|
|
|
|
```python
|
|
```python
|
|
from AI import ObjectDetection
|
|
from AI import ObjectDetection
|
|
@@ -367,36 +368,36 @@ from AI import ObjectDetection
|
|
ObjectDetection()
|
|
ObjectDetection()
|
|
```
|
|
```
|
|
|
|
|
|
-### 加载识别
|
|
|
|
|
|
+### 載入識別
|
|
```python
|
|
```python
|
|
loadModel(img)
|
|
loadModel(img)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| img | image.Image() | 要识别的Image对象,必填 |
|
|
|
|
|
|
+| img | 圖片 | 要識別的Image對象,必填 |
|
|
|
|
|
|
-### 样例
|
|
|
|
|
|
+### 樣例
|
|
```python
|
|
```python
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import ObjectDetection
|
|
from AI import ObjectDetection
|
|
|
|
|
|
-Screen = Screen() # 画布初始化
|
|
|
|
-camera = cameraPython() # 摄像头初始化
|
|
|
|
-object = ObjectDetection() # 物体检测初始化
|
|
|
|
|
|
+Screen = Screen() # 畫布初始化
|
|
|
|
+camera = cameraPython() # 攝像頭初始化
|
|
|
|
+object = ObjectDetection() # 物體檢測初始化
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- canvas = camera.capture() # 获取摄像头图像
|
|
|
|
- canvas = canvas.crop(48,8,224,224) # 裁剪图像尺寸
|
|
|
|
- data = object.loadModel(canvas)
|
|
|
|
|
|
+ canvas = camera.capture() # 獲取攝像頭圖像
|
|
|
|
+ canvas = canvas.crop(48,8,224,224) # 裁剪圖像尺寸
|
|
|
|
+ data = object.load(canvas)
|
|
for i in data:
|
|
for i in data:
|
|
canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=(255,0,0),thickness=1)
|
|
canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=(255,0,0),thickness=1)
|
|
canvas.draw_string(i["X"],i["Y"]-20,(str(i["name"])+":"+str(i["score"])),color=(255,0,0))
|
|
canvas.draw_string(i["X"],i["Y"]-20,(str(i["name"])+":"+str(i["score"])),color=(255,0,0))
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
```
|
|
```
|
|
|
|
|
|
-## 猜拳识别
|
|
|
|
|
|
+## 猜拳識別
|
|
|
|
|
|
```python
|
|
```python
|
|
from AI import RockPaperScissors
|
|
from AI import RockPaperScissors
|
|
@@ -407,17 +408,17 @@ from AI import RockPaperScissors
|
|
RockPaperScissors()
|
|
RockPaperScissors()
|
|
```
|
|
```
|
|
|
|
|
|
-### 加载识别
|
|
|
|
|
|
+### 載入識別
|
|
```python
|
|
```python
|
|
loadModel(img)
|
|
loadModel(img)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| img | image.Image() | 要识别的Image对象,必填 |
|
|
|
|
|
|
+| img | 圖片 | 要識別的Image對象,必填 |
|
|
|
|
|
|
-### 样例
|
|
|
|
|
|
+### 樣例
|
|
```python
|
|
```python
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import RockPaperScissors
|
|
from AI import RockPaperScissors
|
|
@@ -436,7 +437,7 @@ while True:
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
```
|
|
```
|
|
|
|
|
|
-## 自学习识别
|
|
|
|
|
|
+## 自學習識別
|
|
|
|
|
|
```python
|
|
```python
|
|
from AI import SelfLearning
|
|
from AI import SelfLearning
|
|
@@ -447,44 +448,45 @@ from AI import SelfLearning
|
|
SelfLearning(lables)
|
|
SelfLearning(lables)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| lables | 列表 | 要识别的物体名称列表,必填 |
|
|
|
|
|
|
+| lables | 清單 | 要識別的物體名稱清單,必填 |
|
|
|
|
|
|
### 添加类别
|
|
### 添加类别
|
|
```python
|
|
```python
|
|
addClass(img)
|
|
addClass(img)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| img | image.Image() | 要识别的Image对象,必填 |
|
|
|
|
|
|
+| img | 圖片 | 要識別的Image對象,必填 |
|
|
|
|
|
|
-### 训练
|
|
|
|
|
|
+### 訓練
|
|
```python
|
|
```python
|
|
trainSave(path)
|
|
trainSave(path)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| path | string | 保存路径,选填,默认为“/root/user/model/module.bin” |
|
|
|
|
|
|
+| path | 字串 | 保存路徑,選填,預設為“/root/user/model/module.bin” |
|
|
|
|
|
|
-### 加载识别
|
|
|
|
|
|
+### 載入識別
|
|
```python
|
|
```python
|
|
loadModel(img,path)
|
|
loadModel(img,path)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| img | image.Image() | 要识别的Image对象,必填 |
|
|
|
|
-| path | string | 保存路径,选填,默认为“/root/user/model/module.bin” |
|
|
|
|
|
|
+| img | 圖片| 要識別的Image對象,必填 |
|
|
|
|
+| path | 字串 | 保存路徑,選填,預設為“/root/user/model/module.bin” |
|
|
|
|
+
|
|
|
|
+### 樣例
|
|
|
|
|
|
-### 样例
|
|
|
|
-#### 采集
|
|
|
|
|
|
+#### 採集
|
|
```python
|
|
```python
|
|
import time
|
|
import time
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
@@ -496,22 +498,22 @@ key_D = BUTTON(7)
|
|
|
|
|
|
Screen = Screen()
|
|
Screen = Screen()
|
|
camera = cameraPython()
|
|
camera = cameraPython()
|
|
-lables=(['鼠标','键盘','水杯'])
|
|
|
|
|
|
+lables=(['滑鼠','鍵盤','水杯'])
|
|
SL = SelfLearning(lables)
|
|
SL = SelfLearning(lables)
|
|
|
|
|
|
is_train = 0
|
|
is_train = 0
|
|
count = 0
|
|
count = 0
|
|
-str_display = "按C键添加类别,按D键進行学习"
|
|
|
|
|
|
+str_display = "按C鍵添加類別,按D鍵進行學習"
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- # 获取摄像头数据
|
|
|
|
|
|
+ # 獲取攝像頭資料
|
|
canvas = camera.capture()
|
|
canvas = camera.capture()
|
|
canvas = canvas.crop(48,8,224,224)
|
|
canvas = canvas.crop(48,8,224,224)
|
|
if key_C.is_pressed():
|
|
if key_C.is_pressed():
|
|
while not key_C.is_pressed()== False:
|
|
while not key_C.is_pressed()== False:
|
|
time.sleep(0.01)
|
|
time.sleep(0.01)
|
|
if count < len(lables):
|
|
if count < len(lables):
|
|
- # 采集数据添加到列表中
|
|
|
|
|
|
+ # 採集資料添加到清單中
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
SL.addClass(canvas)
|
|
SL.addClass(canvas)
|
|
count += 1
|
|
count += 1
|
|
@@ -520,26 +522,26 @@ while True:
|
|
time.sleep(0.01)
|
|
time.sleep(0.01)
|
|
if count >= len(lables) and is_train == 0:
|
|
if count >= len(lables) and is_train == 0:
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
- # 训练并保存,参数:path 为保存路径默认/root/user/model/module.bin
|
|
|
|
|
|
+ # 訓練並保存,參數:path 為保存路徑預設/root/user/model/module.bin
|
|
SL.train()
|
|
SL.train()
|
|
is_train = 1
|
|
is_train = 1
|
|
- str_display = "学习已完成"
|
|
|
|
|
|
+ str_display = "學習已完成"
|
|
canvas.draw_string(0,0,str_display,scale=1,color=(255,0,0),thickness=1)
|
|
canvas.draw_string(0,0,str_display,scale=1,color=(255,0,0),thickness=1)
|
|
- canvas.draw_string(0,16,"采集次数:"+str(count),scale=1,color=(255,0,0),thickness=1)
|
|
|
|
|
|
+ canvas.draw_string(0,16,"採集次數:"+str(count),scale=1,color=(255,0,0),thickness=1)
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
```
|
|
```
|
|
-#### 识别
|
|
|
|
|
|
+#### 識別
|
|
```python
|
|
```python
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import SelfLearning
|
|
from AI import SelfLearning
|
|
|
|
|
|
Screen = Screen()
|
|
Screen = Screen()
|
|
camera = cameraPython()
|
|
camera = cameraPython()
|
|
-SL= SelfLearning(['鼠标','键盘','水杯'])
|
|
|
|
|
|
+SL= SelfLearning(['滑鼠','鍵盤','水杯'])
|
|
SL.load()
|
|
SL.load()
|
|
|
|
|
|
while True:
|
|
while True:
|
|
- # 获取摄像头数据
|
|
|
|
|
|
+ # 獲取攝像頭資料
|
|
img = camera.capture()
|
|
img = camera.capture()
|
|
canvas = img.crop(48,8,224,224)
|
|
canvas = img.crop(48,8,224,224)
|
|
data = SL.predict(canvas)
|
|
data = SL.predict(canvas)
|
|
@@ -547,7 +549,7 @@ while True:
|
|
Screen.show(canvas,48,8)
|
|
Screen.show(canvas,48,8)
|
|
```
|
|
```
|
|
|
|
|
|
-## 拼音识别
|
|
|
|
|
|
+## 拼音識別
|
|
|
|
|
|
```python
|
|
```python
|
|
from AI import PinyinRecognition
|
|
from AI import PinyinRecognition
|
|
@@ -558,17 +560,17 @@ from AI import PinyinRecognition
|
|
PinyinRecognition(keywords)
|
|
PinyinRecognition(keywords)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| keywords | 列表 | 拼音参数,文字的拼音与音调,必填 |
|
|
|
|
|
|
+| keywords | 清單 | 拼音參數,文字的拼音與音調,必填 |
|
|
|
|
|
|
-### 获取结果
|
|
|
|
|
|
+### 獲取結果
|
|
```python
|
|
```python
|
|
getresult()
|
|
getresult()
|
|
```
|
|
```
|
|
|
|
|
|
-### 样例
|
|
|
|
|
|
+### 樣例
|
|
```python
|
|
```python
|
|
from cocopiPython import Screen
|
|
from cocopiPython import Screen
|
|
from AI import PinyinRecognition
|
|
from AI import PinyinRecognition
|
|
@@ -576,22 +578,22 @@ from AI import PinyinRecognition
|
|
Screen = Screen()
|
|
Screen = Screen()
|
|
canvas = Screen.create()
|
|
canvas = Screen.create()
|
|
|
|
|
|
-keywords = [["ni3 hao3",0.1],["hao3 de1",0.1],["wan3 shang4 hao3",0.1]] # 设置拼音参数
|
|
|
|
|
|
+keywords = [["ni3 hao3",0.1],["hao3 de1",0.1],["wan3 shang4 hao3",0.1]] # 設置拼音參數
|
|
PinyinRecognition = PinyinRecognition(keywords)
|
|
PinyinRecognition = PinyinRecognition(keywords)
|
|
|
|
|
|
data =""
|
|
data =""
|
|
while True:
|
|
while True:
|
|
canvas.clear()
|
|
canvas.clear()
|
|
- data = str(PinyinRecognition.getResult()) # 获取拼音识别结果
|
|
|
|
|
|
+ data = str(PinyinRecognition.getResult()) # 獲取拼音識別結果
|
|
print("jieguo:"+str(data))
|
|
print("jieguo:"+str(data))
|
|
- canvas.draw_string(0,0, "请对准麦克风说出指令", scale = 2, color = (255,0,0) , thickness = 1)
|
|
|
|
|
|
+ canvas.draw_string(0,0, "請對準麥克風說出指令", scale = 2, color = (255,0,0) , thickness = 1)
|
|
if data != "None":
|
|
if data != "None":
|
|
- canvas.draw_string(0, 30, "拼音识别结果:", scale=2, color=(255,0,0), thickness = 1)
|
|
|
|
|
|
+ canvas.draw_string(0, 30, "拼音識別結果:", scale=2, color=(255,0,0), thickness = 1)
|
|
canvas.draw_string(30, 60, (data), scale=2, color=(255,255,255), thickness = 1)
|
|
canvas.draw_string(30, 60, (data), scale=2, color=(255,255,255), thickness = 1)
|
|
Screen.show(canvas)
|
|
Screen.show(canvas)
|
|
```
|
|
```
|
|
|
|
|
|
-## 车牌识别
|
|
|
|
|
|
+## 車牌識別
|
|
|
|
|
|
```python
|
|
```python
|
|
from AI import PlateRecognition
|
|
from AI import PlateRecognition
|
|
@@ -602,31 +604,31 @@ from AI import PlateRecognition
|
|
PlateRecognition()
|
|
PlateRecognition()
|
|
```
|
|
```
|
|
|
|
|
|
-### 加载识别
|
|
|
|
|
|
+### 載入識別
|
|
```python
|
|
```python
|
|
loadModel(img)
|
|
loadModel(img)
|
|
```
|
|
```
|
|
|
|
|
|
-### 参数说明
|
|
|
|
-| 参数 | 类型 | 说明 |
|
|
|
|
|
|
+### 參數說明
|
|
|
|
+| 參數 | 值 | 描述 |
|
|
| :--- | :--- | :--- |
|
|
| :--- | :--- | :--- |
|
|
-| img | image.Image() | 要识别的Image对象,必填 |
|
|
|
|
|
|
+| img | 圖片 | 要識別的Image對象,必填 |
|
|
|
|
|
|
-### 样例
|
|
|
|
|
|
+### 樣例
|
|
```python
|
|
```python
|
|
from cocopiPython import cameraPython,Screen
|
|
from cocopiPython import cameraPython,Screen
|
|
from AI import PlateRecognition
|
|
from AI import PlateRecognition
|
|
|
|
|
|
-Screen = Screen() # 画布初始化
|
|
|
|
-camera = cameraPython() # 摄像头初始化
|
|
|
|
-PlateRecognition = PlateRecognition() # 车牌识别初始化
|
|
|
|
|
|
+Screen = Screen() # 畫布初始化
|
|
|
|
+camera = cameraPython() # 攝像頭初始化
|
|
|
|
+PlateRecognition = PlateRecognition() # 車牌識別初始化
|
|
while True:
|
|
while True:
|
|
- canvas = camera.capture() # 获取摄像头图像
|
|
|
|
- canvas = canvas.crop(48,8,224,224) # 裁剪图像尺寸
|
|
|
|
- data = PlateRecognition.load(canvas) # 加载识别
|
|
|
|
|
|
+ canvas = camera.capture() # 獲取攝像頭圖像
|
|
|
|
+ canvas = canvas.crop(48,8,224,224) # 裁剪圖像尺寸
|
|
|
|
+ data = PlateRecognition.load(canvas) # 載入識別
|
|
for i in data:
|
|
for i in data:
|
|
- canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=(255,0,0),thickness=1) # 检测框
|
|
|
|
- canvas.draw_string(i["X"],i["Y"]-10,(str(i["name"])),color=(255,0,0)) # 名称
|
|
|
|
- Screen.show(canvas,48,8) # 显示
|
|
|
|
|
|
+ canvas.draw_rectangle(i["X"],i["Y"],i["X"]+i["W"],i["Y"]+i["H"],color=(255,0,0),thickness=1) # 檢測框
|
|
|
|
+ canvas.draw_string(i["X"],i["Y"]-10,(str(i["name"])),color=(255,0,0)) # 名稱
|
|
|
|
+ Screen.show(canvas,48,8) # 顯示
|
|
```
|
|
```
|
|
|
|
|