REALIZA TU PROPIO WALLY CON ARDUINO. "PRIMERA PARTE"
miércoles, 10 de junio de 2020
miércoles, 3 de junio de 2020
INSTALANDO OPENCV Y NUMPY EN WINDOWS
INSTALANDO OPENCV Y NUMPY ACTUALIZADOS
Para seguir el tutorial por favor visitar YouTube, al siguiente link:
El documento descargable se encuentra en este enlace:
PASOS DE INSTALACIÓN
1: Debemos de instalar Python la versión que desee en mi caso Python 3.6.7.
Para instalar correctamente siga los siguientes instrucciones:
ver video en youtube...
2: Ejecutamos instalador pip dentro de Python: como en la imagen.
pip install opencv-contrib-python
3: Comprobamos en CMD nuestro OpenCV y Numpy.
C:\Users\esteb>python
Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 13:35:33) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.2.0'
>>> import numpy
>>> numpy.__version__
'1.18.4'
>>>
CÓDIGO FUENTE EJEMPLAR PARA PROBAR LA INSTALACIÓN EN WINDOWS
Para realizar si la instalación esta, todo bien probaremos nuestro ejemplo de detección de formas geométricas, de la siguiente imagen:
CÓDIGO
#ESTEBAN QUISPE CHURATA
#PROBANDO INSTALACION DE OPENCV Y NUMPY
import cv2
image = cv2.imread('imagen_con_formas.png')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
canny = cv2.Canny(gray, 10, 150)
canny = cv2.dilate(canny, None, iterations=1)
canny = cv2.erode(canny, None, iterations=1)
cnts,_ = cv2.findContours(canny, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)# OpenCV 4
for c in cnts:
epsilon = 0.01*cv2.arcLength(c,True)
approx = cv2.approxPolyDP(c,epsilon,True)
x,y,w,h = cv2.boundingRect(approx)
if len(approx)==3:
cv2.putText(image,'TRIANGULO', (x,y-5),1,1.5,(0,255,0),2)
if len(approx)==4:
aspect_ratio = float(w)/h
print('RELACION DE ASPECTO= ', aspect_ratio)
if aspect_ratio == 1:
cv2.putText(image,'CUADRADO', (x,y-5),1,1.5,(0,255,0),2)
else:
cv2.putText(image,'RECTANGULO', (x,y-5),1,1.5,(0,255,0),2)
if len(approx)==5:
cv2.putText(image,'PENTAGONO', (x,y-5),1,1.5,(0,255,0),2)
if len(approx)==6:
cv2.putText(image,'HEXAGONO', (x,y-5),1,1.5,(0,255,0),2)
if len(approx)>10:
cv2.putText(image,'CIRCULO', (x,y-5),1,1.5,(0,255,0),2)
cv2.drawContours(image, [approx], 0, (0,255,0),2)
cv2.imshow('image',image)
cv2.waitKey(0)
RESULTADOS
martes, 2 de junio de 2020
RECONOCIMIENTO FACIAL EN WINDOWS_MATERIAL COMPLEMENTARIO
RECONOCIMIENTO FACIAL EN WINDOWS
![]() |
ESTEBAN QUISPE CHURATA |
Aprovechando el momento, les envió saludos cordiales a sus familias.
En este documento adjunto material complementario, que se utiliza en el videotutorial didáctica, donde podrás realizar tu propio reconocimiento facial con mi ayuda.
Adjunto link de descarga para el archivo ZIP.
PRIMER PASO: CAPTURAR ROSTROS CON NUESTRA CAMARA
CODIGO
#ESTEBAN QUISPE CHURATA
#importamos estas librerias necesarias para el codigo
import cv2
import os
import imutils
personName = 'ESTEBAN' #cambiar por el nombre que tengan almacenado en data
dataPath = 'C:/Users/esteb/Documents/reconocimiento facial/Data' #Cambia a la ruta donde hayas almacenado Data
personPath = dataPath + '/' + personName
if not os.path.exists(personPath):
print('Carpeta creada: ',personPath)
os.makedirs(personPath)
cap = cv2.VideoCapture(0,cv2.CAP_DSHOW) #para probar con webcam
faceClassif = cv2.CascadeClassifier(cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
count = 1200
while True:
ret, frame = cap.read()
if ret == False: break
frame = imutils.resize(frame, width=640)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
auxFrame = frame.copy()
faces = faceClassif.detectMultiScale(gray,1.3,5)
for (x,y,w,h) in faces:
cv2.rectangle(frame, (x,y),(x+w,y+h),(0,255,0),2)
rostro = auxFrame[y:y+h,x:x+w]
rostro = cv2.resize(rostro,(150,150),interpolation=cv2.INTER_CUBIC)
cv2.imwrite(personPath + '/rotro_{}.jpg'.format(count),rostro)
count = count + 1
cv2.imshow('frame',frame)
k = cv2.waitKey(1)
if k == 27 or count >= 1300:
break
cap.release()
cv2.destroyAllWindows()
SEGUNDO PASO: ENTRENANDO NUESTRO PROPIO RECONOCIMIENTO DE ROSTROS
CODIGO
#ESTEBAN QUISPE CHURATA
#importamos estas librerias necesarias para el codigo
import cv2
import os
import numpy as np
dataPath = 'C:/Users/esteb/Documents/reconocimiento facial/Data' #Cambia a la ruta donde hayas almacenado Data
peopleList = os.listdir(dataPath)
print('Lista de personas: ', peopleList)
labels = []
facesData = []
label = 0
for nameDir in peopleList:
personPath = dataPath + '/' + nameDir
print('Leyendo las imágenes')
for fileName in os.listdir(personPath):
print('Rostros: ', nameDir + '/' + fileName)
labels.append(label)
facesData.append(cv2.imread(personPath+'/'+fileName,0))
image = cv2.imread(personPath+'/'+fileName,0)
cv2.imshow('image',image)
cv2.waitKey(10)
label = label + 1
#metodo de entrenamiento utilizado
face_recognizer = cv2.face.LBPHFaceRecognizer_create()
# Entrenando el reconocedor de rostros
print("Entrenando...")
face_recognizer.train(facesData, np.array(labels))
# Almacenando el modelo obtenido
face_recognizer.write('modeloLBPHFace.xml')
print("Modelo almacenado...")
TERCER PASO: PROBANDO NUESTRO RECONOCIMIENTO DE ROSTROS
CODIGO
#ESTEBAN QUISPE CHURATA
#importamos estas librerias necesarias para el codigo
import cv2
import os
dataPath = 'C:/Users/esteb/Documents/reconocimiento facial/Data' #Cambia a la ruta donde hayas almacenado Data
imagePaths = os.listdir(dataPath)
print('imagePaths=',imagePaths)
face_recognizer = cv2.face.LBPHFaceRecognizer_create()
# Leyendo el modelo
face_recognizer.read('modeloLBPHFace.xml')
cap = cv2.VideoCapture(0,cv2.CAP_DSHOW) #encendemos nuestra camara
faceClassif = cv2.CascadeClassifier(cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
while True:
ret,frame = cap.read()
if ret == False: break
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
auxFrame = gray.copy()
faces = faceClassif.detectMultiScale(gray,1.3,5)
for (x,y,w,h) in faces:
rostro = auxFrame[y:y+h,x:x+w]
rostro = cv2.resize(rostro,(150,150),interpolation= cv2.INTER_CUBIC)
result = face_recognizer.predict(rostro)
cv2.putText(frame,'{}'.format(result),(x,y-5),1,1.3,(255,255,0),1,cv2.LINE_AA)
# LBPHFace
if result[1] < 70:
cv2.putText(frame,'{}'.format(imagePaths[result[0]]),(x,y-25),2,1.1,(0,255,0),1,cv2.LINE_AA)
cv2.rectangle(frame, (x,y),(x+w,y+h),(0,255,0),2)
else:
cv2.putText(frame,'Desconocido',(x,y-20),2,0.8,(0,0,255),1,cv2.LINE_AA)
cv2.rectangle(frame, (x,y),(x+w,y+h),(0,0,255),2)
cv2.imshow('frame',frame)
k = cv2.waitKey(1)
if k == 27:
break
cap.release()
LINK DE DESCARGA PARA EL ARCHIVO ZIP:
Suscribirse a:
Entradas
(
Atom
)
Popular Posts
-
________________________________________ ESTEBAN QUISPE CHURATA (ultima actualizacion 2020) ...
-
RECONOCIMIENTO FACIAL EN WINDOWS ESTEBAN QUISPE CHURATA Aprovechando el momento, les envió saludos cordiales a sus familias. En ...
-
VISITE AL NUEVO ENLACE VISITE AL NUEVO ENLACE VISITE AL NUEVO ENLACE VISITE AL NUEVO ENLACE VISITE ...
-
REALIZA TU PROPIO WALLY CON ARDUINO. "PRIMERA PARTE"
-
INSTALANDO OPENCV Y NUMPY ACTUALIZADOS Para seguir el tutorial por favor visitar YouTube, al siguiente link: El documento descarg...
-
Esteban Quispe Churata, nacio el 16 de agosto de 1998, en Totora_Luribay, Provincia LOAYZA. Sus padres son: Martin Quispe Mamani,...
-
ROBOT ESQUICHU SISTEMA CENTRAL DEL ROBOT DISEÑO INICIAL DISEÑO PRIMARIO (PRINCIPIOS FISICOS, CALCULO)
Blog Archive
Con la tecnología de Blogger.