[顔認識] OpenCVは独自のイメージを取得します

アイデア:最初に10,000個の画像を取得し、次にCNNニューラルネットワークを介して学習します。
最初のステップ:まず、顔のデータを取得します。方法は?
コードは次のとおりです。

import cv2
import os
import sys
import random

output_dir = 'E:/myface'

# 上述目录不存在,创建一个temp目录
if not os.path.exists(output_dir):
    os.makedirs(output_dir)


# 打开摄像头 参数为输入流,可以为摄像头或视频文件
camera = cv2.VideoCapture(0)

index = 1
while True:
	if (index <= 10000):
		print('Being processed picture %s' % index)
## 获取我的脸部图片
		success, img = camera.read()
		cv2.imshow('image', img)
		cv2.imwrite(output_dir+'/'+str(index)+'.jpg', img)
		index += 1
	else:
		print('Finished!')
		break

画像効果:

おすすめ

転載: www.cnblogs.com/zhangshengdong/p/12682160.html