zoukankan      html  css  js  c++  java
  • 【人脸识别】OpenCV获取自己的图像

    思路:先获取10000张自己的图像,然后通过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
    

    图像效果:

  • 相关阅读:
    [POI2010]Divine Divisor
    JOISC2014B たのしい家庭菜園
    Problem. C
    AGC004F Namori
    AGC007F Shik and Copying String
    AGC027C ABland Yard
    AGC028E High Elements
    JOI2017FinalE 縄
    CF797F Mice and Holes
    Problem. B
  • 原文地址:https://www.cnblogs.com/zhangshengdong/p/12682160.html
Copyright © 2011-2022 走看看