├── Codigo ├── Anexo Python │ ├── HolaMundo.py │ ├── clases.py │ ├── diccionarios.py │ ├── ejemploDepuracion.py │ ├── entrada_usuario.py │ ├── funciones.py │ ├── listas.py │ ├── miModulo.py │ ├── modulos.py │ ├── sentenciasControl.py │ └── variables.py └── OpenCV │ ├── Busqueda de imagenes │ └── Comparacion patrones.py │ ├── Color tracking │ ├── captura_fotogramas_webcam.py │ ├── color_tracking.py │ ├── color_tracking_dibuja_trayectoria.py │ ├── color_tracking_emoticono.py │ └── color_tracking_fotogramas_webcam.py │ ├── Contornos │ ├── bounding_box_hoja.py │ ├── bounding_box_hoja_circulo.py │ ├── bounding_box_hoja_elipse.py │ ├── bounding_box_hoja_erosionado.py │ ├── contador_monedas.py │ ├── contador_monedas_suavizado.py │ ├── contorno_figuras_geometricas.py │ ├── contorno_hoja.py │ ├── contornos_monedas_areas.py │ ├── identificacion_figuras_geometricas.py │ ├── ocr.py │ ├── ocr_calculo_similitud.py │ └── siete_diferencias.py │ ├── Filtro Canny │ ├── filtro_canny.py │ └── filtro_canny_binario.py │ ├── Filtros lineales │ ├── filtro_paso_alto.py │ └── filtro_paso_bajo.py │ ├── Filtros morfologicos │ ├── filtro_dilatacion.py │ └── filtro_erosion.py │ ├── Filtros umbral │ ├── umbral_adaptativo.py │ ├── umbral_outsu.py │ └── umbral_simple.py │ ├── Funciones de interfaz grafica de usuario │ ├── barra_desplazamiento.py │ ├── circulos.py │ ├── cuadrado.py │ ├── cuadrados.py │ ├── flecha.py │ ├── lineas.py │ ├── texto.py │ └── texto_centrado.py │ ├── Histogramas │ └── histograma.py │ ├── Meanshift │ └── meanshift.py │ ├── Operacione basicas de manejo de imagenes │ ├── adicion_imagenes.py │ ├── and_imagenes.py │ ├── escalado.py │ ├── hsv_brillo.py │ ├── hsv_filtro_color.py │ ├── obtener_color_pixel.py │ ├── regiones.py │ ├── sustraccion_imagenes.py │ └── ventanas.py │ ├── Operaciones basicas de manejo de video │ ├── almacenamiento_video.py │ ├── captura_fotograma.py │ ├── captura_video.py │ └── reproduccion_video.py │ ├── Primeros pasos │ ├── guardar_imagen_rejilla.py │ ├── imagen_blanca.py │ ├── imagen_color.py │ ├── imagen_negra.py │ ├── imagen_rejilla_byn.py │ ├── imagen_rejilla_color.py │ ├── mostrar_componentes_color.py │ └── mostrar_imagen_archivo.py │ ├── Procesamiento de video │ ├── contador_monedas_poca_luz.py │ ├── contador_monedas_suavizado.py │ ├── contador_tacos_poca_luz.py │ ├── identificacion_figuras_geometricas.py │ ├── identificacion_figuras_geometricas_poca_luz.py │ ├── reconocimiento_facial.py │ └── reconocimiento_facial_poca_luz.py │ ├── Realidad aumentada │ ├── monoculo_imagen_estatica.py │ ├── monoculo_webcam.py │ ├── sombrero_imagen_estatica.py │ └── sombrero_webcam.py │ ├── Reconocimiento de objetos │ ├── __pycache__ │ │ └── face_recognition.cpython-37.pyc │ ├── almacenamiento_facial.py │ ├── identificacion_personas.py │ ├── reconocimiento_facial.py │ └── reconocimiento_facial_ojos.py │ ├── Sustracciвn de fondo │ ├── alarma_movimiento.py │ └── sustraccion_fondo.py │ ├── eventos de raton y teclado │ ├── captura_teclas.py │ ├── eventos_raton.py │ ├── pizarra.py │ └── pizarra_teclas.py │ ├── haarcascades │ ├── haarcascade_eye.xml │ ├── haarcascade_frontalface_alt.xml │ └── haarcascade_frontalface_default.xml │ └── imagenes │ ├── Einstein.jpg │ ├── Humphrey.jpg │ ├── Humphrey_Ingrid.jpg │ ├── Invalidos.jpg │ ├── Invalidos_ruido.jpg │ ├── Moises.jpg │ ├── Notre_Dame.jpg │ ├── Tesla.jpg │ ├── agujeros.jpg │ ├── alarma │ └── fotograma.jpg │ ├── caras │ ├── Humphrey.jpg │ └── Ingrid.jpg │ ├── coliseo.jpg │ ├── coliseo_recorte.jpg │ ├── cuadricula.jpg │ ├── cuadricula_ruido.jpg │ ├── cuadro.jpg │ ├── degradado.jpg │ ├── dos.jpg │ ├── espacio.jpg │ ├── figuras_geometricas.png │ ├── figuras_geometricas2.jpg │ ├── figuras_geometricas3.jpg │ ├── figuras_geometricas4.jpg │ ├── figuras_geometricas5.jpg │ ├── hoja.jpg │ ├── ingrid.jpg │ ├── lgtb.jpg │ ├── logo.jpg │ ├── mercado1.jpg │ ├── mercado2.jpg │ ├── monedas1.jpg │ ├── monedas2.jpg │ ├── monedas3.jpg │ ├── monoculo.jpg │ ├── numeros.jpg │ ├── numeros_girados.jpg │ ├── panteon.jpg │ ├── rejilla.jpg │ ├── secuencia_emoticono │ ├── Imagen1.jpg │ ├── Imagen2.jpg │ ├── Imagen3.jpg │ ├── Imagen4.jpg │ ├── Imagen5.jpg │ ├── Imagen6.jpg │ └── emoticono0.jpg │ ├── secuencia_webcam │ ├── fotograma0.jpg │ ├── fotograma1.jpg │ ├── fotograma2.jpg │ ├── fotograma3.jpg │ ├── fotograma4.jpg │ ├── fotograma5.jpg │ ├── fotograma6.jpg │ ├── fotograma7.jpg │ ├── fotograma8.jpg │ └── fotograma9.jpg │ ├── sombrero.jpg │ ├── tabla_numeros.jpg │ ├── tabla_numeros_sombra.jpg │ ├── tabla_numeros_webcam.jpg │ ├── tierra.jpg │ ├── tres.jpg │ ├── uno.jpg │ ├── uno_girado.jpg │ ├── wikipedia0.jpg │ └── wikipedia3.jpg └── README.md /Codigo/Anexo Python/HolaMundo.py: -------------------------------------------------------------------------------- 1 | print("Hola Mundo") 2 | -------------------------------------------------------------------------------- /Codigo/Anexo Python/clases.py: -------------------------------------------------------------------------------- 1 | class Perro: 2 | def __init__(self, nombre, raza): 3 | self.nombre = nombre 4 | self.raza = raza 5 | 6 | def ladrar(self): 7 | print("¡Guau!") 8 | 9 | class Persona: 10 | def __init__(self, nombre, dni): 11 | self.nombre = nombre 12 | self.dni = dni 13 | 14 | def mostrarAtributos(self): 15 | print("Nombre de la persona: " + self.nombre) 16 | print("DNI: " + str(self.dni)) 17 | 18 | class Cliente(Persona): 19 | def __init__(self, nombre, dni, perro): 20 | Persona.__init__(self, nombre, dni) 21 | self.perro = perro 22 | def mostrarAtributos(self): 23 | super().mostrarAtributos() 24 | print("Nombre del perro: " + self.perro.nombre) 25 | print("Raza: " + self.perro.raza) 26 | 27 | mi_perro = Perro("Snoopy", "Beagle") 28 | yo = Cliente("Tomás", 1234, mi_perro) 29 | yo.mostrarAtributos() 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Codigo/Anexo Python/diccionarios.py: -------------------------------------------------------------------------------- 1 | yo = { 2 | "nombre" : "Tomás", 3 | "NIF" : 1234567, 4 | "dirección" : "Madrid" 5 | } 6 | 7 | mi_perro = { 8 | "nombre": "Snoppy", 9 | "raza": "Beagle", 10 | "sexo": "macho", 11 | "edad": 10, 12 | "dueño": yo 13 | } 14 | 15 | print("---DATOS DEL PERRO---") 16 | for clave_perro, valor_perro in mi_perro.items(): 17 | if clave_perro == "dueño" : 18 | print("---DATOS DEL DUEÑO---") 19 | for clave_dueño, valor_dueño in valor_perro.items(): 20 | print(clave_dueño + ":" + str(valor_dueño)) 21 | else : print(clave_perro + ":" + str(valor_perro)) 22 | -------------------------------------------------------------------------------- /Codigo/Anexo Python/ejemploDepuracion.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | 3 | numero1 = randint(1, 10) 4 | numero2 = randint(1, 10) 5 | numero = numero1 + numero2 6 | 7 | respuesta = int(input("Cuánto es " + str(numero1) + " + " + str(numero2) + "? ")) 8 | 9 | if respuesta == numero: 10 | print("¡Correcto!") 11 | else: 12 | print("No es correcto, la respuesta es " + str(numero)) 13 | -------------------------------------------------------------------------------- /Codigo/Anexo Python/entrada_usuario.py: -------------------------------------------------------------------------------- 1 | nombre = input("¿Cómo te llamas? ") 2 | print("Encantado de conocerte, " + nombre) 3 | 4 | 5 | -------------------------------------------------------------------------------- /Codigo/Anexo Python/funciones.py: -------------------------------------------------------------------------------- 1 | def hola(nombre = "anónimo"): 2 | if nombre == "anónimo" : print("Hola") 3 | else : print("Hola " + nombre) 4 | 5 | hola() 6 | nombre = input("¿Cómo te llamas? ") 7 | hola(nombre) 8 | -------------------------------------------------------------------------------- /Codigo/Anexo Python/listas.py: -------------------------------------------------------------------------------- 1 | lista1 = [1, 2] 2 | lista2 = [] 3 | 4 | lista2 = lista1.copy() 5 | 6 | lista2.append(3) 7 | 8 | print("elementos de lista1: " + str(lista1)) 9 | print("elementos de lista2: " + str(lista2)) 10 | -------------------------------------------------------------------------------- /Codigo/Anexo Python/miModulo.py: -------------------------------------------------------------------------------- 1 | variable = "Soy la variable de miModulo.py" 2 | 3 | def funcion(): 4 | print("Soy la función de miModulo.py") 5 | 6 | -------------------------------------------------------------------------------- /Codigo/Anexo Python/modulos.py: -------------------------------------------------------------------------------- 1 | from tabulate import tabulate 2 | 3 | cabecera = ["NOMBRE", "DIRECCIÓN", "TELÉFONO"] 4 | datos_persona1 = ["Tomás", "Gran Vía, 10, 1ºA", "9112345"] 5 | datos_persona2 = ["Juan", "Alcalá, 11, 2ºB", "9167890"] 6 | 7 | tabla =[datos_persona1, datos_persona2] 8 | tabla_con_formato = tabulate(tabla, cabecera) 9 | print(tabla_con_formato) 10 | -------------------------------------------------------------------------------- /Codigo/Anexo Python/sentenciasControl.py: -------------------------------------------------------------------------------- 1 | edad = 9 2 | marca = "Mercedes" 3 | 4 | if (edad < 10) and (marca == "BMW" or marca == "Mercedes"): 5 | print("Te compro el " + marca + " de " + str(edad) + " años") 6 | else: 7 | print("No compro ese tipo de coches") 8 | 9 | -------------------------------------------------------------------------------- /Codigo/Anexo Python/variables.py: -------------------------------------------------------------------------------- 1 | nombre = "Tomás" 2 | hora = 12 3 | 4 | print("¿{} tiene cita a las {}?".format(nombre, hora)) 5 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Busqueda de imagenes/Comparacion patrones.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | color = (0, 155, 255) 4 | grosor = 2 5 | 6 | img = cv2.imread('../imagenes/coliseo.jpg') 7 | patron = cv2.imread('../imagenes/coliseo_recorte.jpg') 8 | 9 | res = cv2.matchTemplate(img, patron, cv2.TM_SQDIFF_NORMED) 10 | 11 | min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) 12 | esq_sup_izq = min_loc 13 | alto, ancho, _ = patron.shape 14 | esq_inf_der = (esq_sup_izq[0] + ancho, esq_sup_izq[1] + alto) 15 | 16 | cv2.rectangle(img, esq_sup_izq, esq_inf_der, color, grosor) 17 | 18 | cv2.imshow('Imagen original', img) 19 | cv2.imshow('Patron', patron) 20 | 21 | 22 | cv2.waitKey(0) 23 | cv2.destroyAllWindows() 24 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Color tracking/captura_fotogramas_webcam.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | carpeta_fotogramas = '../imagenes/secuencia_webcam' 4 | numero_fotograma = 0 5 | numero_fotogramas = 10 6 | grabando = False 7 | 8 | camara = cv2.VideoCapture(0) 9 | 10 | if not camara.isOpened(): 11 | print("No es posible abrir la cámara") 12 | exit() 13 | while numero_fotograma < numero_fotogramas: 14 | ret, frame = camara.read() 15 | if not ret: 16 | print("No es posible obtener la imagen") 17 | break 18 | 19 | cv2.imshow('webcam', frame) 20 | 21 | if cv2.waitKey(100) == ord(' '): 22 | grabando = True 23 | print("Inicio grabacion") 24 | if grabando: 25 | print('Grabando '+'/fotograma'+str(numero_fotograma)+'.jpg') 26 | cv2.imwrite(carpeta_fotogramas+'/fotograma'+str(numero_fotograma)+'.jpg', frame) 27 | numero_fotograma +=1 28 | 29 | print("Fin grabacion") 30 | camara.release() 31 | cv2.destroyAllWindows() 32 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Color tracking/color_tracking.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | matiz_objetivo = 0 5 | rango = 5 6 | max_rango = 30 7 | 8 | color = (0, 255, 255) 9 | grosor = 2 10 | 11 | def selecciona_color(evento, x, y, flags, frame): 12 | global matiz_objetivo 13 | 14 | if evento == cv2.EVENT_LBUTTONDOWN: 15 | hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 16 | h, s, v = cv2.split(hsv) 17 | matiz_objetivo = h[y, x] 18 | 19 | def selecciona_rango(valor): 20 | global rango 21 | rango = valor 22 | 23 | def filtra_matiz(frame): 24 | frame_suavizado = cv2.blur(frame, (10, 10)) 25 | hsv = cv2.cvtColor(frame_suavizado, cv2.COLOR_BGR2HSV) 26 | color_inferior = np.array([matiz_objetivo - rango,150,0]) 27 | color_superior = np.array([matiz_objetivo + rango,255,255]) 28 | mascara = cv2.inRange(hsv, color_inferior, color_superior) 29 | 30 | #mascara = cv2.dilate(mascara, None, iterations=4) 31 | #mascara = cv2.erode(mascara, None, iterations=2) 32 | 33 | contornos, _ = cv2.findContours(mascara, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 34 | 35 | cv2.imshow('Mascara',mascara) 36 | res = cv2.bitwise_and(frame,frame, mask=mascara) 37 | cv2.imshow('Imagen filtrada',res) 38 | 39 | return contornos 40 | 41 | cv2.namedWindow('webcam') 42 | cv2.createTrackbar('Rango', 'webcam', rango, max_rango, selecciona_rango) 43 | 44 | camara = cv2.VideoCapture(0) 45 | if not camara.isOpened(): 46 | print("No es posible abrir la cámara") 47 | exit() 48 | while True: 49 | ret, frame = camara.read() 50 | if not ret: 51 | print("No es posible obtener la imagen") 52 | break 53 | 54 | contornos = filtra_matiz(frame) 55 | if len(contornos): 56 | contorno_max = max(contornos, key = cv2.contourArea) 57 | 58 | (x, y), radio = cv2.minEnclosingCircle(contorno_max) 59 | centro = (int (x), int (y)) 60 | radio = int (radio) 61 | cv2.circle (frame, centro, radio, color, grosor) 62 | 63 | cv2.imshow('webcam', frame) 64 | cv2.setMouseCallback('webcam', selecciona_color, frame) 65 | 66 | if cv2.waitKey(1) == ord('q'): 67 | break 68 | 69 | camara.release() 70 | cv2.destroyAllWindows() 71 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Color tracking/color_tracking_dibuja_trayectoria.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | matiz_objetivo = 0 5 | rango = 5 6 | 7 | color = (0, 255, 255) 8 | grosor = 4 9 | 10 | lista_puntos = [] 11 | tamanio_lista = 50 12 | dibujar = False 13 | 14 | def selecciona_color(evento, x, y, flags, frame): 15 | global matiz_objetivo, lista_puntos, dibujar 16 | 17 | if evento == cv2.EVENT_LBUTTONDOWN: 18 | hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 19 | h, s, v = cv2.split(hsv) 20 | matiz_objetivo = h[y, x] 21 | 22 | dibujar = True 23 | lista_puntos = [] 24 | 25 | def selecciona_rango(valor): 26 | global rango 27 | rango = valor 28 | 29 | def filtra_matiz(frame): 30 | frame_suavizado = cv2.blur(frame, (10, 10)) 31 | hsv = cv2.cvtColor(frame_suavizado, cv2.COLOR_BGR2HSV) 32 | color_inferior = np.array([matiz_objetivo - rango,150,0]) 33 | color_superior = np.array([matiz_objetivo + rango,255,255]) 34 | mascara = cv2.inRange(hsv, color_inferior, color_superior) 35 | 36 | #mascara = cv2.dilate(mascara, None, iterations=4) 37 | #mascara = cv2.erode(mascara, None, iterations=2) 38 | 39 | res = cv2.bitwise_and(frame,frame, mask=mascara) 40 | 41 | contornos, _ = cv2.findContours(mascara, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 42 | 43 | #cv2.imshow('Mascara',mascara) 44 | #cv2.imshow('Imagen filtrada',res) 45 | 46 | return contornos 47 | 48 | cv2.namedWindow('webcam') 49 | cv2.createTrackbar('Rango', 'webcam', 5, 30, selecciona_rango) 50 | 51 | camara = cv2.VideoCapture(0) 52 | if not camara.isOpened(): 53 | print("No es posible abrir la cámara") 54 | exit() 55 | 56 | while True: 57 | ret, frame = camara.read() 58 | if not ret: 59 | print("No es posible obtener la imagen") 60 | break 61 | 62 | contornos = filtra_matiz(frame) 63 | if len(contornos) > 0 and dibujar: 64 | contorno_max = max(contornos, key = cv2.contourArea) 65 | (x, y), radio = cv2.minEnclosingCircle(contorno_max) 66 | x = int(x) 67 | y = int(y) 68 | if len(lista_puntos) >= tamanio_lista : lista_puntos. pop(0) 69 | lista_puntos.append((x, y)) 70 | if len(lista_puntos) >= 2: 71 | punto_prev = lista_puntos[0] 72 | for punto in lista_puntos: 73 | cv2.line(frame, punto, punto_prev, color, grosor) 74 | punto_prev = punto 75 | 76 | frame = cv2.flip(frame, 1) 77 | cv2.imshow('webcam', frame) 78 | cv2.setMouseCallback('webcam', selecciona_color, frame) 79 | 80 | if cv2.waitKey(10) == ord('q'): break 81 | 82 | camara.release() 83 | cv2.destroyAllWindows() 84 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Color tracking/color_tracking_emoticono.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | from os import listdir 4 | from math import ceil 5 | 6 | matiz_objetivo = 0 7 | rango = 5 8 | 9 | color = (0, 255, 255) 10 | grosor = 2 11 | 12 | carpeta_emoticono = '../imagenes/secuencia_emoticono/' 13 | lista_emoticonos = [] 14 | 15 | for archivo in listdir(carpeta_emoticono): 16 | lista_emoticonos.append(cv2.imread(carpeta_emoticono+archivo)) 17 | 18 | numero_imagenes = len(lista_emoticonos) 19 | indice_emoticono = ceil(numero_imagenes/2) 20 | 21 | def selecciona_color(evento, x, y, flags, frame): 22 | global matiz_objetivo 23 | 24 | if evento == cv2.EVENT_LBUTTONDOWN: 25 | hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 26 | h, s, v = cv2.split(hsv) 27 | matiz_objetivo = h[y, x] 28 | 29 | def selecciona_rango(valor): 30 | global rango 31 | rango = valor 32 | 33 | def filtra_matiz(frame): 34 | frame_suavizado = cv2.blur(frame, (10, 10)) 35 | hsv = cv2.cvtColor(frame_suavizado, cv2.COLOR_BGR2HSV) 36 | color_inferior = np.array([matiz_objetivo - rango,150,0]) 37 | color_superior = np.array([matiz_objetivo + rango,255,255]) 38 | mascara = cv2.inRange(hsv, color_inferior, color_superior) 39 | 40 | #mascara = cv2.dilate(mascara, None, iterations=4) 41 | #mascara = cv2.erode(mascara, None, iterations=2) 42 | 43 | contornos, _ = cv2.findContours(mascara, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 44 | return contornos 45 | 46 | cv2.namedWindow('webcam') 47 | cv2.createTrackbar('Rango', 'webcam', 5, 30, selecciona_rango) 48 | 49 | camara = cv2.VideoCapture(0) 50 | if not camara.isOpened(): 51 | print("No es posible abrir la cámara") 52 | exit() 53 | 54 | ancho_frame = camara.get(cv2.CAP_PROP_FRAME_WIDTH) 55 | ancho_zona = ancho_frame/numero_imagenes 56 | 57 | while True: 58 | ret, frame = camara.read() 59 | if not ret: 60 | print("No es posible obtener la imagen") 61 | break 62 | 63 | contornos = filtra_matiz(frame) 64 | if len(contornos) > 0: 65 | contorno_max = max(contornos, key = cv2.contourArea) 66 | 67 | (x, y), radio = cv2.minEnclosingCircle(contorno_max) 68 | centro = (int (x), int (y)) 69 | radio = int (radio) 70 | cv2.circle (frame, centro, radio, color, grosor) 71 | 72 | indice_emoticono = numero_imagenes - ceil(x/ancho_zona) 73 | 74 | cv2.imshow('webcam', frame) 75 | cv2.imshow('Emoticono', lista_emoticonos[indice_emoticono]) 76 | cv2.setMouseCallback('webcam', selecciona_color, frame) 77 | 78 | if cv2.waitKey(1) == ord('q'): 79 | break 80 | 81 | camara.release() 82 | cv2.destroyAllWindows() 83 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Color tracking/color_tracking_fotogramas_webcam.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | from os import listdir 4 | from math import ceil 5 | 6 | matiz_objetivo = 0 7 | rango = 5 8 | 9 | color = (0, 255, 255) 10 | grosor = 2 11 | 12 | carpeta_emoticono = '../imagenes/secuencia_webcam/' 13 | lista_emoticonos = [] 14 | 15 | for archivo in listdir(carpeta_emoticono): 16 | lista_emoticonos.append(cv2.imread(carpeta_emoticono+archivo)) 17 | 18 | numero_imagenes = len(lista_emoticonos) 19 | indice_emoticono = ceil(numero_imagenes/2) 20 | 21 | def selecciona_color(evento, x, y, flags, frame): 22 | global matiz_objetivo 23 | 24 | if evento == cv2.EVENT_LBUTTONDOWN: 25 | hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 26 | h, s, v = cv2.split(hsv) 27 | matiz_objetivo = h[y, x] 28 | 29 | def selecciona_rango(valor): 30 | global rango 31 | rango = valor 32 | 33 | def filtra_matiz(frame): 34 | frame_suavizado = cv2.blur(frame, (10, 10)) 35 | hsv = cv2.cvtColor(frame_suavizado, cv2.COLOR_BGR2HSV) 36 | color_inferior = np.array([matiz_objetivo - rango,150,0]) 37 | color_superior = np.array([matiz_objetivo + rango,255,255]) 38 | mascara = cv2.inRange(hsv, color_inferior, color_superior) 39 | 40 | contornos, _ = cv2.findContours(mascara, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 41 | return contornos 42 | 43 | cv2.namedWindow('webcam') 44 | cv2.createTrackbar('Rango', 'webcam', 5, 30, selecciona_rango) 45 | 46 | camara = cv2.VideoCapture(0) 47 | if not camara.isOpened(): 48 | print("No es posible abrir la cámara") 49 | exit() 50 | 51 | ancho_frame = camara.get(cv2.CAP_PROP_FRAME_WIDTH) 52 | ancho_zona = ancho_frame/numero_imagenes 53 | 54 | while True: 55 | ret, frame = camara.read() 56 | if not ret: 57 | print("No es posible obtener la imagen") 58 | break 59 | 60 | contornos = filtra_matiz(frame) 61 | if len(contornos) > 0: 62 | contorno_max = max(contornos, key = cv2.contourArea) 63 | 64 | (x, y), radio = cv2.minEnclosingCircle(contorno_max) 65 | centro = (int (x), int (y)) 66 | radio = int (radio) 67 | cv2.circle (frame, centro, radio, color, grosor) 68 | 69 | indice_emoticono = numero_imagenes - ceil(x/ancho_zona) 70 | 71 | cv2.imshow('webcam', frame) 72 | cv2.imshow('Mascota', lista_emoticonos[indice_emoticono]) 73 | cv2.setMouseCallback('webcam', selecciona_color, frame) 74 | 75 | if cv2.waitKey(1) == ord('q'): 76 | break 77 | 78 | camara.release() 79 | cv2.destroyAllWindows() 80 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/bounding_box_hoja.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | umbral = 175 4 | color = (0,0,255) 5 | grosor = 3 6 | 7 | img = cv2.imread('../imagenes/hoja.jpg') 8 | 9 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 10 | _, img_umbral = cv2.threshold(img_byn, umbral, 255, cv2.THRESH_BINARY_INV) 11 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 12 | 13 | for contorno in contornos: 14 | x,y,ancho,alto = cv2.boundingRect(contorno) 15 | cv2.rectangle(img,(x,y),(x+ancho,y+alto), color, grosor) 16 | 17 | #cv2.drawContours(img, contornos, -1, color, grosor) 18 | cv2.imshow('Bounding box', img) 19 | 20 | cv2.waitKey(0) 21 | cv2.destroyAllWindows() 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/bounding_box_hoja_circulo.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | kernel = np.ones((10,10),np.uint8) 5 | 6 | umbral = 175 7 | color = (0,0,255) 8 | grosor = 3 9 | 10 | img = cv2.imread('../imagenes/hoja.jpg') 11 | 12 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 13 | img_erosionada = cv2.erode(img_byn,kernel) 14 | _, img_umbral = cv2.threshold(img_erosionada, umbral, 255, cv2.THRESH_BINARY_INV) 15 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 16 | 17 | for contorno in contornos: 18 | (x, y), radio = cv2.minEnclosingCircle(contorno) 19 | centro = (int (x), int (y)) 20 | radio = int (radio) 21 | cv2.circle (img, centro, radio, color, grosor) 22 | 23 | cv2.imshow('Bounding box', img) 24 | 25 | cv2.waitKey(0) 26 | cv2.destroyAllWindows() 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/bounding_box_hoja_elipse.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | kernel = np.ones((10,10),np.uint8) 5 | 6 | umbral = 175 7 | color = (0,0,255) 8 | grosor = 3 9 | 10 | img = cv2.imread('../imagenes/hoja.jpg') 11 | 12 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 13 | img_erosionada = cv2.erode(img_byn,kernel) 14 | _, img_umbral = cv2.threshold(img_erosionada, umbral, 255, cv2.THRESH_BINARY_INV) 15 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 16 | 17 | for contorno in contornos: 18 | elipse = cv2.fitEllipse (contorno) 19 | cv2.ellipse (img, elipse, color, grosor) 20 | 21 | cv2.imshow('Bounding box', img) 22 | 23 | cv2.waitKey(0) 24 | cv2.destroyAllWindows() 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/bounding_box_hoja_erosionado.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | kernel = np.ones((10,10),np.uint8) 5 | 6 | umbral = 175 7 | color = (0,0,255) 8 | grosor = 3 9 | 10 | img = cv2.imread('../imagenes/hoja.jpg') 11 | 12 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 13 | img_erosionada = cv2.erode(img_byn,kernel) 14 | _, img_umbral = cv2.threshold(img_erosionada, umbral, 255, cv2.THRESH_BINARY_INV) 15 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 16 | 17 | for contorno in contornos: 18 | x,y,ancho,alto = cv2.boundingRect(contorno) 19 | cv2.rectangle(img,(x,y),(x+ancho,y+alto), color, grosor) 20 | 21 | cv2.imshow('Bounding box', img) 22 | 23 | cv2.waitKey(0) 24 | cv2.destroyAllWindows() 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/contador_monedas.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | fuente = cv2.FONT_HERSHEY_COMPLEX 4 | color = (0,255,255) 5 | grosor = 2 6 | escala = 1 7 | posicion_texto_1 = (20, 30) 8 | posicion_texto_2 = (20, 60) 9 | posicion_texto_5 = (20, 90) 10 | 11 | umbral = 120 12 | 13 | area_min_1 = 4000 14 | area_min_2 = 6000 15 | area_min_5 = 8000 16 | 17 | num_monedas_1 = num_monedas_2 = num_monedas_5 = 0 18 | 19 | img = cv2.imread('../imagenes/monedas2.jpg') 20 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 21 | _, img_umbral = cv2.threshold(img_byn, umbral, 255, cv2.THRESH_BINARY_INV) 22 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 23 | #cv2.drawContours(img, contornos, -1, color, grosor) 24 | 25 | for contorno in contornos: 26 | area = abs(cv2.contourArea(contorno, True)) 27 | if area >= area_min_5: num_monedas_5 += 1 28 | elif area >= area_min_2: num_monedas_2 += 1 29 | elif area >= area_min_1: num_monedas_1 += 1 30 | 31 | cv2.putText(img, "Monedas de 1 centimo: " + str(num_monedas_1), posicion_texto_1, fuente, escala, color, grosor) 32 | cv2.putText(img, "Monedas de 2 centimos: " + str(num_monedas_2), posicion_texto_2, fuente, escala, color, grosor) 33 | cv2.putText(img, "Monedas de 5 centimos: " + str(num_monedas_5), posicion_texto_5, fuente, escala, color, grosor) 34 | cv2.imshow('Contornos', img) 35 | 36 | cv2.waitKey(0) 37 | cv2.destroyAllWindows() 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/contador_monedas_suavizado.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | fuente = cv2.FONT_HERSHEY_COMPLEX 4 | color = (0,255,255) 5 | grosor = 2 6 | escala = 1 7 | posicion_texto_1 = (20, 30) 8 | posicion_texto_2 = (20, 60) 9 | posicion_texto_5 = (20, 90) 10 | 11 | umbral = 120 12 | 13 | area_min_1 = 4000 14 | area_min_2 = 6000 15 | area_min_5 = 8000 16 | 17 | num_monedas_1 = num_monedas_2 = num_monedas_5 = 0 18 | 19 | img = cv2.imread('../imagenes/monedas3.jpg') 20 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 21 | img_suavizada = cv2.blur(img_byn, (10, 10)) 22 | _, img_umbral = cv2.threshold(img_suavizada, umbral, 255, cv2.THRESH_BINARY_INV) 23 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 24 | 25 | for contorno in contornos: 26 | area = abs(cv2.contourArea(contorno, True)) 27 | if area >= area_min_5: num_monedas_5 += 1 28 | elif area >= area_min_2: num_monedas_2 += 1 29 | elif area >= area_min_1: num_monedas_1 += 1 30 | 31 | cv2.drawContours(img, contornos, -1, color, grosor) 32 | cv2.putText(img, "Monedas de 1 centimo: " + str(num_monedas_1), posicion_texto_1, fuente, escala, color, grosor) 33 | cv2.putText(img, "Monedas de 2 centimos: " + str(num_monedas_2), posicion_texto_2, fuente, escala, color, grosor) 34 | cv2.putText(img, "Monedas de 5 centimos: " + str(num_monedas_5), posicion_texto_5, fuente, escala, color, grosor) 35 | cv2.imshow('Contornos', img) 36 | 37 | cv2.waitKey(0) 38 | cv2.destroyAllWindows() 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/contorno_figuras_geometricas.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | umbral = 200 4 | color = (0,255,255) 5 | grosor = 3 6 | 7 | img = cv2.imread('../imagenes/figuras_geometricas3.jpg') 8 | 9 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 10 | _, img_umbral = cv2.threshold(img_byn, umbral, 255, cv2.THRESH_BINARY_INV) 11 | cv2.imshow('Imagen binarizada', img_umbral) 12 | 13 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 14 | 15 | cv2.drawContours(img, contornos, -1, color, grosor) 16 | cv2.imshow('Contorno', img) 17 | 18 | cv2.waitKey(0) 19 | cv2.destroyAllWindows() 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/contorno_hoja.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | color = (0,255,255) 4 | grosor = 3 5 | 6 | img = cv2.imread('../imagenes/hoja.jpg') 7 | img_original = img.copy() 8 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 9 | 10 | def mostrar_imagen_binarizada(umbral): 11 | global img_umbral 12 | _, img_umbral = cv2.threshold(img_byn, umbral, 255, cv2.THRESH_BINARY_INV) 13 | cv2.imshow('Imagen binarizada', img_umbral) 14 | 15 | def mostrar_contornos(): 16 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 17 | img = img_original.copy() 18 | cv2.drawContours(img, contornos, -1, color, grosor) 19 | cv2.imshow('Contornos', img) 20 | 21 | def actualizar_imagenes(umbral): 22 | mostrar_imagen_binarizada(umbral) 23 | mostrar_contornos() 24 | 25 | actualizar_imagenes(0) 26 | 27 | cv2.createTrackbar('Umbral', 'Contornos', 0, 255, actualizar_imagenes) 28 | 29 | cv2.waitKey(0) 30 | cv2.destroyAllWindows() 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/contornos_monedas_areas.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | color = (0,255,255) 4 | grosor = 3 5 | 6 | img = cv2.imread('../imagenes/monedas2.jpg') 7 | img_original = img.copy() 8 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 9 | 10 | def mostrar_imagen_binarizada(umbral): 11 | global img_umbral 12 | _, img_umbral = cv2.threshold(img_byn, umbral, 255, cv2.THRESH_BINARY_INV) 13 | cv2.imshow('Imagen binarizada', img_umbral) 14 | 15 | def mostrar_contornos(): 16 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 17 | 18 | for contorno in contornos: 19 | print(cv2.contourArea(contorno, True)) 20 | print("------------") 21 | 22 | img = img_original.copy() 23 | cv2.drawContours(img, contornos, -1, color, grosor) 24 | cv2.imshow('Contornos', img) 25 | 26 | def actualizar_imagenes(umbral): 27 | mostrar_imagen_binarizada(umbral) 28 | mostrar_contornos() 29 | 30 | mostrar_imagen_binarizada(0) 31 | mostrar_contornos() 32 | 33 | cv2.createTrackbar('Umbral', 'Contornos', 0, 255, actualizar_imagenes) 34 | 35 | cv2.waitKey(0) 36 | cv2.destroyAllWindows() 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/identificacion_figuras_geometricas.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | umbral = 200 4 | 5 | porcentaje_error = 0.01 6 | 7 | fuente = cv2.FONT_HERSHEY_SIMPLEX 8 | color = (0,0,0) 9 | grosor = 2 10 | escala = 1 11 | texto = "" 12 | 13 | img = cv2.imread('../imagenes/figuras_geometricas4.jpg') 14 | 15 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 16 | _, img_umbral = cv2.threshold(img_byn, umbral, 255, cv2.THRESH_BINARY_INV) 17 | 18 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) 19 | 20 | for contorno in contornos: 21 | x,y,ancho,alto = cv2.boundingRect(contorno) 22 | 23 | margen_error = porcentaje_error*cv2.arcLength(contorno, True ) 24 | contorno_aprox = cv2.approxPolyDP(contorno, margen_error, True ) 25 | #cv2.drawContours(img, [contorno_aprox], 0, color, grosor) 26 | 27 | if len(contorno_aprox) == 3: texto = "TRIANGULO" 28 | elif len(contorno_aprox) == 4:texto = "CUADRADO" 29 | elif len(contorno_aprox) == 5: texto = "PENTAGONO" 30 | 31 | (ancho_texto, alto_texto), _ = cv2.getTextSize(texto, fuente, escala, grosor) 32 | posicion_x = int(x + (ancho - ancho_texto) / 2) 33 | posicion_y = int(y + (alto / 2 + alto_texto / 2)) 34 | 35 | cv2.putText(img, texto, (posicion_x, posicion_y), fuente, escala, color, grosor) 36 | 37 | cv2.imshow('Figuras geometricas', img) 38 | 39 | cv2.waitKey(0) 40 | cv2.destroyAllWindows() 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/ocr.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | 4 | umbral = 150 5 | 6 | similitud = 0.1 7 | 8 | fuente = cv2.FONT_HERSHEY_SIMPLEX 9 | color = 0 10 | grosor = 2 11 | escala = 1 12 | posicion = (20, 30) 13 | numeros = "Numeros: " 14 | 15 | img = cv2.imread('../imagenes/numeros.jpg', 0) 16 | 17 | img1 = cv2.imread('../imagenes/uno.jpg',0) 18 | img2 = cv2.imread('../imagenes/dos.jpg',0) 19 | img3 = cv2.imread('../imagenes/tres.jpg',0) 20 | 21 | _, img1_umbral = cv2.threshold(img1, umbral, 255, cv2.THRESH_BINARY_INV) 22 | _, img2_umbral = cv2.threshold(img2, umbral, 255, cv2.THRESH_BINARY_INV) 23 | _, img3_umbral = cv2.threshold(img3, umbral, 255, cv2.THRESH_BINARY_INV) 24 | contornos1, _ = cv2.findContours(img1_umbral, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 25 | contornos2, _ = cv2.findContours(img2_umbral, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 26 | contornos3, _ = cv2.findContours(img3_umbral, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 27 | contorno1 = contornos1[0] 28 | contorno2 = contornos2[0] 29 | contorno3 = contornos3[0] 30 | 31 | _, img_umbral = cv2.threshold(img, umbral, 255, cv2.THRESH_BINARY_INV) 32 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 33 | for contorno in contornos: 34 | if cv2.matchShapes(contorno,contorno1,cv2.CONTOURS_MATCH_I1,0.0) <= similitud: 35 | numeros = numeros + "1" 36 | elif cv2.matchShapes(contorno,contorno2,cv2.CONTOURS_MATCH_I1,0.0) <= similitud: 37 | numeros = numeros + "2" 38 | elif cv2.matchShapes(contorno,contorno3,cv2.CONTOURS_MATCH_I1,0.0) <= similitud: 39 | numeros = numeros + "3" 40 | 41 | cv2.putText(img, numeros, posicion, fuente, escala, color, grosor) 42 | cv2.imshow('Numeros', img) 43 | 44 | cv2.waitKey(0) 45 | cv2.destroyAllWindows() 46 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/ocr_calculo_similitud.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | 4 | umbral = 150 5 | 6 | img1 = cv2.imread('../imagenes/uno.jpg',0) 7 | img2 = cv2.imread('../imagenes/dos.jpg',0) 8 | img3 = cv2.imread('../imagenes/tres.jpg',0) 9 | 10 | _, img1_umbral = cv2.threshold(img1, umbral, 255, cv2.THRESH_BINARY_INV) 11 | _, img2_umbral = cv2.threshold(img2, umbral, 255, cv2.THRESH_BINARY_INV) 12 | _, img3_umbral = cv2.threshold(img3, umbral, 255, cv2.THRESH_BINARY_INV) 13 | contornos1, _ = cv2.findContours(img1_umbral, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 14 | contornos2, _ = cv2.findContours(img2_umbral, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 15 | contornos3, _ = cv2.findContours(img3_umbral, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) 16 | contorno1 = contornos1[0] 17 | contorno2 = contornos2[0] 18 | contorno3 = contornos3[0] 19 | 20 | similitud12 = cv2.matchShapes(contorno1, contorno2, cv2.CONTOURS_MATCH_I1, 0.0) 21 | similitud13 = cv2.matchShapes(contorno1, contorno3, cv2.CONTOURS_MATCH_I1, 0.0) 22 | similitud23 = cv2.matchShapes(contorno2, contorno3, cv2.CONTOURS_MATCH_I1, 0.0) 23 | 24 | print("similitud entre el 1 y el 2: ", similitud12) 25 | print("similitud entre el 1 y el 3: ", similitud13) 26 | print("similitud entre el 2 y el 3: ", similitud23) 27 | 28 | 29 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Contornos/siete_diferencias.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | umbral = 25 4 | 5 | color = (0,255,255) 6 | grosor = 3 7 | tamanio_flecha = 50 8 | 9 | 10 | img1 = cv2.imread('../imagenes/mercado1.jpg') 11 | img2 = cv2.imread('../imagenes/mercado2.jpg') 12 | 13 | img = cv2.subtract(img1, img2) 14 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 15 | img_suavizada = cv2.blur(img_byn, (10, 10)) 16 | _, img_umbral = cv2.threshold(img_suavizada, umbral, 255, cv2.THRESH_BINARY) 17 | contornos, _ = cv2.findContours(img_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 18 | 19 | for contorno in contornos: 20 | x,y,ancho,alto = cv2.boundingRect(contorno) 21 | x_extremo1 = x + ancho + tamanio_flecha 22 | y_extremo1 = y + int(alto/2) - tamanio_flecha 23 | x_extremo2 = x + ancho 24 | y_extremo2 = y + int(alto/2) 25 | cv2.arrowedLine(img1, (x_extremo1, y_extremo1), (x_extremo2, y_extremo2), color, grosor) 26 | 27 | #cv2.drawContours(img1, contornos, -1, color, grosor) 28 | #cv2.imshow('Imagen binarizada', img_umbral) 29 | cv2.imshow('Imagen 1', img1) 30 | cv2.imshow('Imagen 2', img2) 31 | 32 | 33 | cv2.waitKey(0) 34 | cv2.destroyAllWindows() 35 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Filtro Canny/filtro_canny.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/figuras_geometricas2.jpg', 0) 4 | 5 | img_canny = cv2.Canny(img, 100, 200) 6 | cv2.imshow('Imagen filtrada', img_canny) 7 | 8 | cv2.imshow('Imagen original', img) 9 | 10 | cv2.waitKey(0) 11 | cv2.destroyAllWindows() 12 | 13 | 14 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Filtro Canny/filtro_canny_binario.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 0) 4 | 5 | img_canny = cv2.Canny(img, 100, 200) 6 | _, img_inversa = cv2.threshold(img_canny, 0, 255, cv2.THRESH_BINARY_INV) 7 | cv2.imshow('Imagen filtrada', img_inversa) 8 | 9 | cv2.waitKey(0) 10 | cv2.destroyAllWindows() 11 | 12 | 13 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Filtros lineales/filtro_paso_alto.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/Invalidos.jpg', 0) 4 | 5 | img_paso_bajo = cv2.blur(img, (10, 10)) 6 | img_paso_alto = cv2.subtract(img, img_paso_bajo) 7 | cv2.imshow('Imagen filtrada', img_paso_alto) 8 | 9 | cv2.imshow('Imagen original', img) 10 | 11 | cv2.waitKey(0) 12 | cv2.destroyAllWindows() 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Filtros lineales/filtro_paso_bajo.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/Invalidos.jpg', 0) 4 | 5 | img_suavizada = cv2.blur(img, (10, 10)) 6 | cv2.imshow('Imagen filtrada', img_suavizada) 7 | 8 | cv2.imshow('Imagen original', img) 9 | 10 | cv2.waitKey(0) 11 | cv2.destroyAllWindows() 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Filtros morfologicos/filtro_dilatacion.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | kernel = np.ones((2,2),np.uint8) 5 | 6 | img = cv2.imread('../imagenes/Invalidos_ruido.jpg', 0) 7 | 8 | img_dilatada = cv2.dilate(img,kernel) 9 | 10 | cv2.imshow('Imagen filtrada', img_dilatada) 11 | 12 | cv2.imshow('Imagen original', img) 13 | 14 | cv2.waitKey(0) 15 | cv2.destroyAllWindows() 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Filtros morfologicos/filtro_erosion.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | kernel = np.ones((5,5),np.uint8) 5 | 6 | img = cv2.imread('../imagenes/agujeros.jpg', 0) 7 | img_erosionada = cv2.erode(img,kernel) 8 | 9 | cv2.imshow('Imagen filtrada', img_erosionada) 10 | 11 | cv2.imshow('Imagen original', img) 12 | 13 | cv2.waitKey(0) 14 | cv2.destroyAllWindows() 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Filtros umbral/umbral_adaptativo.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | bloque = 3 4 | constante = 0 5 | 6 | def actualizar_bloque(blq): 7 | global bloque 8 | bloque = blq 9 | if bloque < 3 : bloque = 3 10 | elif bloque%2 == 0 : bloque += 1 11 | img_umbral = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,bloque,constante) 12 | cv2.imshow('Imagen filtrada', img_umbral) 13 | 14 | def actualizar_constante (cte): 15 | global constante 16 | constante = cte 17 | img_umbral = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,bloque,constante) 18 | cv2.imshow('Imagen filtrada', img_umbral) 19 | 20 | img = cv2.imread('../imagenes/tabla_numeros.jpg', 0) 21 | 22 | img_umbral = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,bloque,constante) 23 | cv2.imshow('Imagen filtrada', img_umbral) 24 | 25 | cv2.imshow('Imagen original', img) 26 | cv2.createTrackbar('Bloque', 'Imagen original', bloque, 500, actualizar_bloque) 27 | cv2.createTrackbar('Constante', 'Imagen original', constante, 255, actualizar_constante) 28 | 29 | cv2.waitKey(0) 30 | cv2.destroyAllWindows() 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Filtros umbral/umbral_outsu.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/degradado.jpg', 0) 4 | 5 | _, img_umbral = cv2.threshold(img, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU) 6 | cv2.imshow('Imagen filtrada', img_umbral) 7 | 8 | cv2.imshow('Imagen original', img) 9 | 10 | cv2.waitKey(0) 11 | cv2.destroyAllWindows() 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Filtros umbral/umbral_simple.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | def actualizar_imagen(umbral): 4 | _, img_umbral = cv2.threshold(img, umbral, 255, cv2.THRESH_BINARY) 5 | cv2.imshow('Imagen filtrada', img_umbral) 6 | 7 | img = cv2.imread('../imagenes/degradado.jpg', 0) 8 | cv2.imshow('Imagen original', img) 9 | 10 | cv2.createTrackbar('Umbral', 'Imagen original', 0, 255, actualizar_imagen) 11 | 12 | actualizar_imagen(0) 13 | 14 | cv2.waitKey(0) 15 | cv2.destroyAllWindows() 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Funciones de interfaz grafica de usuario/barra_desplazamiento.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | img_original = img.copy() 5 | 6 | color = (0, 0, 255) 7 | grosor = 4 8 | fuente = cv2.FONT_HERSHEY_SCRIPT_SIMPLEX 9 | escala = 2 10 | alto_imagen, ancho_imagen, canales = img.shape 11 | 12 | def actualizar_imagen(escala): 13 | img = img_original.copy() 14 | posicion_x, posicion_y = centrarImagen(escala) 15 | cv2.putText(img, "Isabel", (posicion_x, posicion_y), fuente, escala, color, grosor) 16 | cv2.imshow('Cuadro', img) 17 | 18 | def centrarImagen(escala): 19 | (ancho_texto, alto_texto), _ = cv2.getTextSize("Isabel", fuente, escala, grosor) 20 | posicion_x = int((ancho_imagen - ancho_texto) / 2) 21 | posicion_y = int((alto_imagen + alto_texto) / 2) 22 | return posicion_x, posicion_y 23 | 24 | posicion_x, posicion_y = centrarImagen(escala) 25 | cv2.putText(img, "Isabel", (posicion_x, posicion_y), fuente, escala, color, grosor) 26 | cv2.imshow('Cuadro', img) 27 | cv2.createTrackbar('Escala texto', 'Cuadro', 2, 5, actualizar_imagen) 28 | 29 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Funciones de interfaz grafica de usuario/circulos.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | 5 | alto, ancho, canales = img.shape 6 | color = (0, 0, 255) 7 | incremento_radio = 80 8 | grosor = 40 9 | 10 | centro_x = int(ancho/2) 11 | centro_y = int(alto/2) 12 | 13 | for radio in range(0, int(alto/2)+1, incremento_radio): 14 | cv2.circle(img, (centro_x, centro_y), radio,color, grosor) 15 | 16 | cv2.imshow('cuadro', img) 17 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Funciones de interfaz grafica de usuario/cuadrado.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | 5 | color = (0, 0, 255) 6 | grosor = 2 7 | cara_x1, cara_x2 = 300, 550 8 | cara_y1, cara_y2 = 20, 220 9 | 10 | cv2.rectangle(img, (cara_x1, cara_y1), (cara_x2, cara_y2),color, grosor) 11 | 12 | cv2.imshow('cuadro', img) 13 | 14 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Funciones de interfaz grafica de usuario/cuadrados.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | 5 | alto, ancho, canales = img.shape 6 | color = (0, 0, 255) 7 | grosor = 2 8 | separación = 10 9 | numero_cuadrados = 10 10 | 11 | centro_x = int(ancho/2) 12 | centro_y = int(alto/2) 13 | 14 | for lado in range(0, 100, separación): 15 | x1 = centro_x - int(lado*ancho/200) 16 | x2 = centro_x + int(lado*ancho/200) 17 | y1 = centro_y - int(lado*alto/200) 18 | y2 = centro_y + int(lado*alto/200) 19 | cv2.rectangle(img, (x1, y1), (x2, y2),color, grosor) 20 | 21 | cv2.imshow('cuadro', img) 22 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Funciones de interfaz grafica de usuario/flecha.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | 5 | cv2.arrowedLine(img, (200, 100), (300, 150),(0, 0, 255), 5) 6 | 7 | cv2.imshow('cuadro', img) 8 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Funciones de interfaz grafica de usuario/lineas.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | 5 | alto, ancho, _ = img.shape 6 | color = (0, 0, 255) 7 | grosor = 2 8 | cuadricula = 80 9 | 10 | for x in range(0, ancho+1, cuadricula): 11 | img = cv2.line(img, (x, 0), (x, alto), color, grosor) 12 | for y in range(0, alto+1, cuadricula): 13 | img = cv2.line(img, (0, y), (ancho, y), color, grosor) 14 | 15 | cv2.imshow('cuadro', img) 16 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Funciones de interfaz grafica de usuario/texto.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | 5 | color = (0, 0, 255) 6 | grosor = 4 7 | fuente = cv2.FONT_HERSHEY_SCRIPT_SIMPLEX 8 | escala = 2 9 | 10 | cv2.arrowedLine(img, (200, 100), (300, 150), color, grosor) 11 | cv2.putText(img, "Isabel", (100, 75), fuente, escala, color, grosor) 12 | 13 | cv2.imshow('cuadro', img) 14 | 15 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Funciones de interfaz grafica de usuario/texto_centrado.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | 5 | color = (0, 0, 255) 6 | grosor = 4 7 | fuente = cv2.FONT_HERSHEY_SCRIPT_SIMPLEX 8 | escala = 2 9 | 10 | (ancho_texto, alto_texto), _ = cv2.getTextSize("Isabel", fuente, escala, grosor) 11 | alto_imagen, ancho_imagen, canales = img.shape 12 | 13 | posicion_x = int((ancho_imagen - ancho_texto) / 2) 14 | posicion_y = int(alto_imagen / 2 + alto_texto / 2) 15 | 16 | cv2.putText(img, "Isabel", (posicion_x, posicion_y), fuente, escala, color, grosor) 17 | 18 | cv2.imshow('cuadro', img) 19 | 20 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Histogramas/histograma.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | from matplotlib import pyplot as plt 3 | 4 | img = cv2.imread('../imagenes/Moises.jpg', 0) 5 | 6 | hist = cv2.calcHist([img],[0],None,[256],[0,256]) 7 | 8 | print(hist) 9 | cv2.imshow('Imagen', img) 10 | 11 | plt.xlabel('Nivel de luz') 12 | plt.ylabel('Nº de pixeles') 13 | plt.title('Histograma') 14 | plt.plot(hist) 15 | plt.show() 16 | 17 | cv2.waitKey(0) 18 | cv2.destroyAllWindows() 19 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Meanshift/meanshift.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | 4 | objeto_seleccionado = False 5 | 6 | ancho = 100 7 | alto = 100 8 | color = (0, 255, 255) 9 | grosor = 2 10 | 11 | criterios_parada = (cv2.TERM_CRITERIA_COUNT | cv2.TERM_CRITERIA_EPS, 15, 2) 12 | 13 | def eventos_raton(evento, x, y, flags, parametros): 14 | global roi_hist, ventana_seguimiento, objeto_seleccionado 15 | 16 | if evento == cv2.EVENT_LBUTTONDOWN: 17 | objeto_seleccionado = True 18 | x = int(x-ancho/2) 19 | y = int(y-alto/2) 20 | ventana_seguimiento = (x, y, ancho, alto) 21 | roi = frame[y:y+alto, x:x+ancho] 22 | hsv_roi = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV) 23 | mascara = cv2.inRange(hsv_roi, np.array((0,60,32)), np.array((180,255,255))) 24 | roi_hist = cv2.calcHist([hsv_roi],[0],mascara,[180],[0,180]) 25 | cv2.normalize(roi_hist,roi_hist,0,255,cv2.NORM_MINMAX) 26 | 27 | 28 | camara = cv2.VideoCapture(0) 29 | if not camara.isOpened(): 30 | print("No es posible abrir la cámara") 31 | exit() 32 | 33 | cv2.namedWindow('webcam') 34 | cv2.setMouseCallback('webcam', eventos_raton) 35 | 36 | while(True): 37 | ret, frame = camara.read() 38 | if not ret: 39 | print("No es posible obtener la imagen") 40 | break 41 | if objeto_seleccionado: 42 | hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 43 | dst = cv2.calcBackProject([hsv],[0],roi_hist,[0,180],1) 44 | cv2.imshow('retroproyeccion',dst) 45 | _, ventana_seguimiento = cv2.meanShift(dst, ventana_seguimiento, criterios_parada) 46 | x,y,ancho,alto = ventana_seguimiento 47 | frame = cv2.rectangle(frame, (x,y), (x+ancho,y+alto), color, grosor) 48 | 49 | cv2.imshow('webcam',frame) 50 | 51 | if cv2.waitKey(1) == ord('q'): break 52 | 53 | camara.release() 54 | cv2.destroyAllWindows() 55 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operacione basicas de manejo de imagenes/adicion_imagenes.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img1 = cv2.imread('../imagenes/espacio.jpg', 1) 4 | img2 = cv2.imread('../imagenes/tierra.jpg', 1) 5 | 6 | img = cv2.addWeighted(img1, 0.4, img2, 0.8, 0) 7 | 8 | cv2.imshow('Composicion imagenes', img) 9 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operacione basicas de manejo de imagenes/and_imagenes.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img1 = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | img2 = cv2.imread('../imagenes/logo.jpg', 1) 5 | 6 | alto, ancho, _ = img2.shape 7 | roi = img1[0:alto, 0:ancho] 8 | 9 | roi = cv2.bitwise_and(img2, roi) 10 | img1[0:alto, 0:ancho ] = roi 11 | 12 | cv2.imshow('Composicion imagenes', img1) 13 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operacione basicas de manejo de imagenes/escalado.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/Notre_Dame.jpg', 1) 4 | 5 | alto, ancho, _ = img.shape 6 | escala = 0.5 7 | ancho_escalado, alto_escalado = int(ancho*escala), int(alto*escala) 8 | 9 | imagen_escalada = cv2.resize(img, (ancho_escalado, alto_escalado)) 10 | 11 | 12 | cv2.imshow('Imagen original', img) 13 | cv2.imshow('Imagen escalada', imagen_escalada) 14 | 15 | cv2.waitKey(0) 16 | cv2.destroyAllWindows() 17 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operacione basicas de manejo de imagenes/hsv_brillo.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg') 4 | img_original = img.copy() 5 | cv2.imshow('Imagen', img) 6 | 7 | def incrementa_brillo(brillo): 8 | img = img_original.copy() 9 | 10 | hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) 11 | h, s, v = cv2.split(hsv) 12 | 13 | limite = 255 - brillo 14 | v[v > limite] = 255 15 | v[v <= limite] += brillo 16 | 17 | hsv = cv2.merge((h, s, v)) 18 | img = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR) 19 | cv2.imshow('Imagen', img) 20 | 21 | cv2.createTrackbar('Incremento', 'Imagen', 0, 255, incrementa_brillo) 22 | 23 | cv2.waitKey(0) 24 | cv2.destroyAllWindows() 25 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operacione basicas de manejo de imagenes/hsv_filtro_color.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | intervalo = 5 5 | 6 | img = cv2.imread('../imagenes/lgtb.jpg') 7 | hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) 8 | 9 | def filtra_matiz(matiz): 10 | matiz_inferior = np.array([matiz- intervalo,0,0]) 11 | matiz_superior = np.array([matiz + intervalo,255,255]) 12 | mascara = cv2.inRange(hsv, matiz_inferior, matiz_superior) 13 | 14 | res = cv2.bitwise_and(img,img, mask=mascara) 15 | 16 | cv2.imshow('Mascara',mascara) 17 | cv2.imshow('Imagen filtrada',res) 18 | cv2.imshow('Imagen original',img) 19 | 20 | filtra_matiz(0) 21 | 22 | cv2.createTrackbar('Matiz', 'Imagen original', 0, 179, filtra_matiz) 23 | 24 | cv2.waitKey(0) 25 | cv2.destroyAllWindows() 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operacione basicas de manejo de imagenes/obtener_color_pixel.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | img_original = img.copy() 5 | 6 | cv2.imshow('Cuadro', img) 7 | 8 | def color(event,x,y,flags,param): 9 | global img 10 | if event == cv2.EVENT_LBUTTONDOWN: 11 | color = img[y, x].tolist() 12 | cv2.circle(img, (x, y), 40,color, -1) 13 | elif event == cv2.EVENT_LBUTTONUP: 14 | img = img_original.copy() 15 | cv2.imshow('Cuadro',img) 16 | 17 | cv2.setMouseCallback('Cuadro',color) 18 | 19 | key = cv2.waitKey(0) 20 | cv2.destroyAllWindows() 21 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operacione basicas de manejo de imagenes/regiones.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | color = (0, 0, 255) 4 | grosor = 2 5 | ancho_min = 125 6 | 7 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 8 | img_original = img.copy() 9 | 10 | cv2.imshow('Cuadro', img) 11 | 12 | def region(event,x,y,flags,param): 13 | global x1, y1, img 14 | 15 | if event == cv2.EVENT_LBUTTONDOWN: 16 | x1, y1 = x, y 17 | elif event == cv2.EVENT_MOUSEMOVE and flags == cv2.EVENT_FLAG_LBUTTON : 18 | img = img_original.copy() 19 | cv2.rectangle(img, (x1, y1), (x, y), color, grosor) 20 | elif event == cv2.EVENT_LBUTTONUP : 21 | if x > x1 and y > y1 and x - x1 > ancho_min: 22 | img_recortada = img_original[y1:y, x1:x] 23 | cv2.imshow('Recorte',img_recortada) 24 | 25 | cv2.imshow('Cuadro',img) 26 | 27 | cv2.setMouseCallback('Cuadro',region) 28 | 29 | key = cv2.waitKey(0) 30 | cv2.destroyAllWindows() 31 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operacione basicas de manejo de imagenes/sustraccion_imagenes.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img1 = cv2.imread('../imagenes/wikipedia0.jpg', 0) 4 | img2 = cv2.imread('../imagenes/wikipedia3.jpg', 0) 5 | 6 | img = cv2.subtract(img1, img2) 7 | 8 | cv2.imshow('Sustraccion imagenes', img) 9 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operacione basicas de manejo de imagenes/ventanas.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | 5 | cv2.namedWindow('Cuadro', cv2.WINDOW_NORMAL) 6 | cv2.moveWindow('Cuadro', 0, 0) 7 | cv2.imshow('Cuadro', img) 8 | 9 | 10 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operaciones basicas de manejo de video/almacenamiento_video.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | archivo_video = '../videos/video.avi' 4 | 5 | #Se crea el objeto que representa la fuente de video 6 | camara = cv2.VideoCapture(0) 7 | # Se obtiene el código FourCC del codec DIVX 8 | fourcc = cv2.VideoWriter_fourcc(*'DIVX') 9 | #Se crea el objeto VideoWriter 10 | video = cv2.VideoWriter(archivo_video, fourcc, 20, (640, 480)) 11 | #Si no se ha podido acceer a la fuente de video se sale del programa 12 | if not camara.isOpened(): 13 | print("No es posible abrir la cámara") 14 | exit() 15 | while True: 16 | # Se captura la imagen frame a frame 17 | ret, frame = camara.read() 18 | # Si la captura no se ha tomado correctamente se sale del bucle 19 | if not ret: 20 | print("No es posible obtener la imagen") 21 | break 22 | #El frame se guarda en el archivo 23 | video.write(frame) 24 | # El frame se muestra en pantalla 25 | cv2.imshow('webcam', frame) 26 | if cv2.waitKey(1) == ord('q'): 27 | break 28 | # Se liberan los recursos utilizados y se cierra la ventana 29 | camara.release() 30 | video.release() 31 | cv2.destroyAllWindows() 32 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operaciones basicas de manejo de video/captura_fotograma.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | #Se crea el objeto que representa la fuente de video 4 | camara = cv2.VideoCapture(0) 5 | # Se obtiene el código FourCC del codec DIVX 6 | fourcc = cv2.VideoWriter_fourcc(*'DIVX') 7 | #Se crea el objeto VideoWriter 8 | video = cv2.VideoWriter('../videos/video.avi', fourcc, 20, (640, 480)) 9 | #Si no se ha podido acceer a la fuente de video se sale del programa 10 | if not camara.isOpened(): 11 | print("No es posible abrir la cámara") 12 | exit() 13 | while True: 14 | # Se captura la imagen frame a frame 15 | ret, frame = camara.read() 16 | # Si la captura no se ha tomado correctamente se sale del bucle 17 | if not ret: 18 | print("No es posible obtener la imagen") 19 | break 20 | # El frame se muestra en pantalla 21 | cv2.imshow('webcam', frame) 22 | if cv2.waitKey(1) == ord('q'): 23 | break 24 | elif cv2.waitKey(1) == ord('s'): 25 | print('Fotogtama guardado') 26 | cv2.imwrite('../imagenes/fotograma.jpg', frame) 27 | # Se liberan los recursos utilizados y se cierra la ventana 28 | camara.release() 29 | video.release() 30 | cv2.destroyAllWindows() 31 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operaciones basicas de manejo de video/captura_video.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | #Se crea el objeto que representa la fuente de video 4 | camara = cv2.VideoCapture(0) 5 | #Si no se ha podido acceer a la fuente de video se sale del programa 6 | if not camara.isOpened(): 7 | print("No es posible abrir la cámara") 8 | exit() 9 | while True: 10 | # Se captura la imagen frame a frame 11 | ret, frame = camara.read() 12 | # Si la captura no se ha tomado correctamente se sale del bucle 13 | if not ret: 14 | print("No es posible obtener la imagen") 15 | break 16 | # El frame se muestra en pantalla 17 | cv2.imshow('webcam', frame) 18 | if cv2.waitKey(1) == ord('q'): 19 | break 20 | # Se libera la cámara y se cierra la ventana 21 | camara.release() 22 | cv2.destroyAllWindows() 23 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Operaciones basicas de manejo de video/reproduccion_video.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | fps = 30 4 | velocidad_reproduccion = int(1000/fps) #milisegundos 5 | 6 | #Se crea el objeto que representa la fuente de video 7 | video = cv2.VideoCapture('../videos/video.avi') 8 | #Si no se ha podido acceer a la fuente de video se sale del programa 9 | if not video.isOpened(): 10 | print("No es posible abrir el archivo") 11 | exit() 12 | while True: 13 | # Se captura la imagen frame a frame 14 | ret, frame = video.read() 15 | # Cuando el video termina, se sale del bucle 16 | if not ret: 17 | print("Reproducción finalizada") 18 | break 19 | # El frame se muestra en pantalla 20 | cv2.imshow('video', frame) 21 | if cv2.waitKey(velocidad_reproduccion) == ord('q'): 22 | break 23 | # Se libera la cámara y se cierra la ventana 24 | video.release() 25 | cv2.destroyAllWindows() 26 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Primeros pasos/guardar_imagen_rejilla.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy 3 | 4 | ancho = alto = 300 5 | 6 | img = numpy.ones((alto,ancho),numpy.uint8)*255 7 | 8 | for x in range(ancho): 9 | for y in range(alto): 10 | if x%50 == 0 or y%50 == 0: 11 | img[y, x] = 0 12 | 13 | cv2.imwrite('../imagenes/rejilla.jpg', img) 14 | print("Imagen almacenada") 15 | 16 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Primeros pasos/imagen_blanca.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy 3 | 4 | ancho = alto = 300 5 | 6 | img = numpy.ones((alto,ancho),numpy.uint8)*255 7 | 8 | cv2.imshow('Imagen blanca', img) 9 | 10 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Primeros pasos/imagen_color.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy 3 | 4 | ancho = alto = 300 5 | 6 | img = numpy.ones((alto,ancho, 3),numpy.uint8)*255 7 | img[:] = (255, 0, 0) 8 | 9 | cv2.imshow('Imagen color', img) 10 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Primeros pasos/imagen_negra.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy 3 | 4 | ancho = alto = 300 5 | 6 | img = numpy.zeros((alto,ancho),numpy.uint8) 7 | 8 | cv2.imshow('Imagen negra', img) 9 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Primeros pasos/imagen_rejilla_byn.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy 3 | 4 | ancho = alto = 300 5 | 6 | img = numpy.ones((alto,ancho),numpy.uint8)*255 7 | 8 | for x in range(ancho): 9 | for y in range(alto): 10 | if x%50 == 0 or y%50 == 0: 11 | img[y, x] = 0 12 | 13 | cv2.imshow('Rejilla ', img) 14 | 15 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Primeros pasos/imagen_rejilla_color.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy 3 | 4 | ancho = alto = 300 5 | 6 | img = numpy.ones((alto,ancho, 3),numpy.uint8)*255 7 | img[:] = (255, 255, 255) 8 | 9 | for x in range(ancho): 10 | for y in range(alto): 11 | if x%50 == 0 or y%50 == 0: 12 | img[y, x] = (0, 0, 255) 13 | 14 | cv2.imshow('Rejilla ', img) 15 | 16 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Primeros pasos/mostrar_componentes_color.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/figuras_geometricas.png', 1) 4 | 5 | img_azul,img_verde, img_roja = cv2.split(img) 6 | 7 | cv2.imshow('Azul', img_azul) 8 | cv2.imshow('Verde', img_verde) 9 | cv2.imshow('Roja', img_roja) 10 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Primeros pasos/mostrar_imagen_archivo.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | img = cv2.imread('../imagenes/cuadro.jpg', 1) 4 | cv2.imshow('Cuadro', img) 5 | 6 | tamanio = img.size 7 | alto, ancho, canales = img.shape 8 | tipo = img.dtype 9 | print("Tamaño: " + str(tamanio) + " bytes") 10 | print("Ancho: " + str(ancho) + " píxeles") 11 | print("Alto: " + str(alto) + " píxeles") 12 | print("Nº canales: " + str(canales)) 13 | print("Tipo: " + str(tipo)) 14 | 15 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Procesamiento de video/contador_monedas_poca_luz.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | fuente = cv2.FONT_HERSHEY_COMPLEX 4 | color = (0,255,255) 5 | grosor = 2 6 | escala = 1 7 | posicion_texto_1 = (20, 30) 8 | posicion_texto_2 = (20, 60) 9 | posicion_texto_5 = (20, 90) 10 | (ancho_texto, alto_texto), _ = cv2.getTextSize(" ", fuente, escala, grosor) 11 | 12 | umbral = 120 13 | 14 | area_min_1 = 4000 15 | area_min_2 = 6000 16 | area_min_5 = 8000 17 | 18 | area_max = 10000 19 | 20 | num_monedas_1 = num_monedas_2 = num_monedas_5 = 0 21 | 22 | incremento_brillo = 0 23 | 24 | def modifica_brillo(img): 25 | hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) 26 | h, s, v = cv2.split(hsv) 27 | 28 | limite = 255 - incremento_brillo 29 | v[v > limite] = 255 30 | v[v <= limite] += incremento_brillo 31 | 32 | hsv = cv2.merge((h, s, v)) 33 | img = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR) 34 | return img 35 | 36 | def incrementa_brillo(valor): 37 | global incremento_brillo 38 | incremento_brillo = valor 39 | 40 | cv2.namedWindow('webcam') 41 | cv2.createTrackbar('Brillo', 'webcam', 0, 255, incrementa_brillo) 42 | 43 | camara = cv2.VideoCapture(0) 44 | if not camara.isOpened(): 45 | print("No es posible abrir la cámara") 46 | exit() 47 | 48 | while True: 49 | ret, frame = camara.read() 50 | if not ret: 51 | print("No es posible obtener la imagen") 52 | break 53 | 54 | frame = modifica_brillo(frame) 55 | 56 | frame_byn = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 57 | 58 | frame_suavizado = cv2.blur(frame_byn, (10, 10)) 59 | _, frame_umbral = cv2.threshold(frame_suavizado, umbral, 255, cv2.THRESH_BINARY_INV) 60 | contornos, _ = cv2.findContours(frame_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 61 | #cv2.drawContours(frame, contornos, -1, color, grosor) 62 | 63 | num_monedas_1 = num_monedas_2 = num_monedas_5 = 0 64 | for contorno in contornos: 65 | area = abs(cv2.contourArea(contorno, True)) 66 | #print(area) 67 | (x, y), _ = cv2.minEnclosingCircle(contorno) 68 | centro_objeto = (int(x-ancho_texto/2), int(y+alto_texto/2)) 69 | if area <= area_max: 70 | if area >= area_min_5: 71 | num_monedas_5 += 1 72 | cv2.putText(frame, "5", centro_objeto, fuente, escala, color, grosor) 73 | elif area >= area_min_2: 74 | num_monedas_2 += 1 75 | cv2.putText(frame, "2", centro_objeto, fuente, escala, color, grosor) 76 | elif area >= area_min_1: 77 | num_monedas_1 += 1 78 | cv2.putText(frame, "1", centro_objeto, fuente, escala, color, grosor) 79 | 80 | cv2.putText(frame, "Monedas de 1 centimo: " + str(num_monedas_1), posicion_texto_1, fuente, escala, color, grosor) 81 | cv2.putText(frame, "Monedas de 2 centimos: " + str(num_monedas_2), posicion_texto_2, fuente, escala, color, grosor) 82 | cv2.putText(frame, "Monedas de 5 centimos: " + str(num_monedas_5), posicion_texto_5, fuente, escala, color, grosor) 83 | 84 | cv2.imshow('webcam', frame) 85 | 86 | if cv2.waitKey(1) == ord('q'): break 87 | 88 | camara.release() 89 | cv2.destroyAllWindows() 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Procesamiento de video/contador_monedas_suavizado.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | fuente = cv2.FONT_HERSHEY_COMPLEX 4 | color = (0,255,255) 5 | grosor = 2 6 | escala = 1 7 | posicion_texto_1 = (20, 30) 8 | posicion_texto_2 = (20, 60) 9 | posicion_texto_5 = (20, 90) 10 | (ancho_texto, alto_texto), _ = cv2.getTextSize(" ", fuente, escala, grosor) 11 | 12 | umbral = 120 13 | 14 | area_min_1 = 4000 15 | area_min_2 = 6000 16 | area_min_5 = 8000 17 | 18 | area_max = 10000 19 | 20 | num_monedas_1 = num_monedas_2 = num_monedas_5 = 0 21 | 22 | camara = cv2.VideoCapture(0) 23 | if not camara.isOpened(): 24 | print("No es posible abrir la cámara") 25 | exit() 26 | 27 | while True: 28 | ret, frame = camara.read() 29 | if not ret: 30 | print("No es posible obtener la imagen") 31 | break 32 | frame_byn = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 33 | 34 | frame_suavizado = cv2.blur(frame_byn, (10, 10)) 35 | _, frame_umbral = cv2.threshold(frame_suavizado, umbral, 255, cv2.THRESH_BINARY_INV) 36 | contornos, _ = cv2.findContours(frame_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 37 | #cv2.drawContours(frame, contornos, -1, color, grosor) 38 | 39 | num_monedas_1 = num_monedas_2 = num_monedas_5 = 0 40 | for contorno in contornos: 41 | area = abs(cv2.contourArea(contorno, True)) 42 | #print(area) 43 | (x, y), _ = cv2.minEnclosingCircle(contorno) 44 | centro_objeto = (int(x-ancho_texto/2), int(y+alto_texto/2)) 45 | if area <= area_max: 46 | if area >= area_min_5: 47 | num_monedas_5 += 1 48 | cv2.putText(frame, "5", centro_objeto, fuente, escala, color, grosor) 49 | elif area >= area_min_2: 50 | num_monedas_2 += 1 51 | cv2.putText(frame, "2", centro_objeto, fuente, escala, color, grosor) 52 | elif area >= area_min_1: 53 | num_monedas_1 += 1 54 | cv2.putText(frame, "1", centro_objeto, fuente, escala, color, grosor) 55 | 56 | cv2.putText(frame, "Monedas de 1 centimo: " + str(num_monedas_1), posicion_texto_1, fuente, escala, color, grosor) 57 | cv2.putText(frame, "Monedas de 2 centimos: " + str(num_monedas_2), posicion_texto_2, fuente, escala, color, grosor) 58 | cv2.putText(frame, "Monedas de 5 centimos: " + str(num_monedas_5), posicion_texto_5, fuente, escala, color, grosor) 59 | 60 | cv2.imshow('webcam', frame) 61 | 62 | if cv2.waitKey(1) == ord('q'): break 63 | 64 | camara.release() 65 | cv2.destroyAllWindows() 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Procesamiento de video/contador_tacos_poca_luz.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | fuente = cv2.FONT_HERSHEY_COMPLEX 4 | color = (0,0,255) 5 | grosor = 2 6 | escala = 1 7 | posicion_texto_6 = (20, 30) 8 | posicion_texto_8 = (20, 60) 9 | posicion_texto_10 = (20, 90) 10 | (ancho_texto, alto_texto), _ = cv2.getTextSize(" ", fuente, escala, grosor) 11 | 12 | umbral = 120 13 | 14 | area_min_6 = 3000 15 | area_min_8 = 4000 16 | area_min_10 = 9500 17 | 18 | area_max = 20000 19 | 20 | num_tacos_6 = num_tacos_8 = num_tacos_10 = 0 21 | 22 | incremento_brillo = 0 23 | 24 | def modifica_brillo(img): 25 | hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) 26 | h, s, v = cv2.split(hsv) 27 | 28 | limite = 255 - incremento_brillo 29 | v[v > limite] = 255 30 | v[v <= limite] += incremento_brillo 31 | 32 | hsv = cv2.merge((h, s, v)) 33 | img = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR) 34 | return img 35 | 36 | def incrementa_brillo(valor): 37 | global incremento_brillo 38 | incremento_brillo = valor 39 | 40 | cv2.namedWindow('webcam') 41 | cv2.createTrackbar('Brillo', 'webcam', 0, 255, incrementa_brillo) 42 | 43 | camara = cv2.VideoCapture(0) 44 | if not camara.isOpened(): 45 | print("No es posible abrir la cámara") 46 | exit() 47 | 48 | while True: 49 | ret, frame = camara.read() 50 | if not ret: 51 | print("No es posible obtener la imagen") 52 | break 53 | 54 | frame = modifica_brillo(frame) 55 | 56 | frame_byn = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 57 | 58 | frame_suavizado = cv2.blur(frame_byn, (10, 10)) 59 | _, frame_umbral = cv2.threshold(frame_suavizado, umbral, 255, cv2.THRESH_BINARY_INV) 60 | contornos, _ = cv2.findContours(frame_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 61 | cv2.drawContours(frame, contornos, -1, color, grosor) 62 | 63 | num_tacos_6 = num_tacos_8 = num_tacos_10 = 0 64 | for contorno in contornos: 65 | area = abs(cv2.contourArea(contorno, True)) 66 | #print(area) 67 | (x, y), _ = cv2.minEnclosingCircle(contorno) 68 | centro_objeto = (int(x-ancho_texto/2), int(y+alto_texto/2)) 69 | if area <= area_max: 70 | if area >= area_min_10: 71 | num_tacos_10 += 1 72 | cv2.putText(frame, "10", centro_objeto, fuente, escala, color, grosor) 73 | elif area >= area_min_8: 74 | num_tacos_8 += 1 75 | cv2.putText(frame, "8", centro_objeto, fuente, escala, color, grosor) 76 | elif area >= area_min_6: 77 | num_tacos_6 += 1 78 | cv2.putText(frame, "6", centro_objeto, fuente, escala, color, grosor) 79 | 80 | #print("---") 81 | cv2.putText(frame, "Tacos del numero 6: " + str(num_tacos_6), posicion_texto_6, fuente, escala, color, grosor) 82 | cv2.putText(frame, "Tacos del numero 8: " + str(num_tacos_8), posicion_texto_8, fuente, escala, color, grosor) 83 | cv2.putText(frame, "Tacos del numero 10: " + str(num_tacos_10), posicion_texto_10, fuente, escala, color, grosor) 84 | 85 | cv2.imshow('webcam', frame) 86 | 87 | if cv2.waitKey(1) == ord('q'): break 88 | 89 | camara.release() 90 | cv2.destroyAllWindows() 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Procesamiento de video/identificacion_figuras_geometricas.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | umbral = 200 4 | 5 | fuente = cv2.FONT_HERSHEY_SIMPLEX 6 | color = (0,0,0) 7 | grosor = 2 8 | escala = 1 9 | texto = "" 10 | 11 | area_min = 5000 12 | 13 | area_max = 50000 14 | 15 | camara = cv2.VideoCapture(0) 16 | if not camara.isOpened(): 17 | print("No es posible abrir la cámara") 18 | exit() 19 | 20 | while True: 21 | ret, frame = camara.read() 22 | if not ret: 23 | print("No es posible obtener la imagen") 24 | break 25 | 26 | frame_byn = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 27 | _, frame_umbral = cv2.threshold(frame_byn, umbral, 255, cv2.THRESH_BINARY_INV) 28 | 29 | contornos, _ = cv2.findContours(frame_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) 30 | 31 | for contorno in contornos: 32 | x,y,ancho,alto = cv2.boundingRect(contorno) 33 | 34 | margen_error = 0.05*cv2.arcLength(contorno, True ) 35 | contorno_aprox = cv2.approxPolyDP(contorno, margen_error, True ) 36 | area = abs(cv2.contourArea(contorno_aprox, True)) 37 | if area >= area_min and area < area_max: 38 | cv2.drawContours(frame, [contorno_aprox], 0, color, grosor) 39 | 40 | if len(contorno_aprox) == 3: texto = "TRIANGULO" 41 | elif len(contorno_aprox) == 4:texto = "CUADRADO" 42 | elif len(contorno_aprox) == 5: texto = "PENTAGONO" 43 | 44 | (ancho_texto, alto_texto), _ = cv2.getTextSize(texto, fuente, escala, grosor) 45 | posicion_x = int(x + (ancho - ancho_texto) / 2) 46 | posicion_y = int(y + (alto / 2 + alto_texto / 2)) 47 | 48 | cv2.putText(frame, texto, (posicion_x, posicion_y), fuente, escala, color, grosor) 49 | 50 | cv2.imshow('webcam', frame) 51 | 52 | if cv2.waitKey(1) == ord('q'): break 53 | 54 | camara.release() 55 | cv2.destroyAllWindows() 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Procesamiento de video/identificacion_figuras_geometricas_poca_luz.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | umbral = 200 4 | 5 | fuente = cv2.FONT_HERSHEY_SIMPLEX 6 | color = (0,0,0) 7 | grosor = 2 8 | escala = 1 9 | texto = "" 10 | 11 | area_min = 10000 12 | 13 | area_max = 50000 14 | 15 | incremento_brillo = 0 16 | 17 | def modifica_brillo(img): 18 | hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) 19 | h, s, v = cv2.split(hsv) 20 | 21 | limite = 255 - incremento_brillo 22 | v[v > limite] = 255 23 | v[v <= limite] += incremento_brillo 24 | 25 | hsv = cv2.merge((h, s, v)) 26 | img = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR) 27 | return img 28 | 29 | def incrementa_brillo(valor): 30 | global incremento_brillo 31 | incremento_brillo = valor 32 | 33 | cv2.namedWindow('webcam') 34 | cv2.createTrackbar('Brillo', 'webcam', 0, 255, incrementa_brillo) 35 | 36 | camara = cv2.VideoCapture(0) 37 | if not camara.isOpened(): 38 | print("No es posible abrir la cámara") 39 | exit() 40 | 41 | while True: 42 | global frame 43 | ret, frame = camara.read() 44 | if not ret: 45 | print("No es posible obtener la imagen") 46 | break 47 | 48 | frame = modifica_brillo(frame) 49 | 50 | frame_byn = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 51 | frame_suavizado = cv2.blur(frame_byn, (10, 10)) 52 | _, frame_umbral = cv2.threshold(frame_suavizado, umbral, 255, cv2.THRESH_BINARY_INV) 53 | 54 | contornos, _ = cv2.findContours(frame_umbral, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) 55 | 56 | for contorno in contornos: 57 | x,y,ancho,alto = cv2.boundingRect(contorno) 58 | 59 | margen_error = 0.05*cv2.arcLength(contorno, True ) 60 | contorno_aprox = cv2.approxPolyDP(contorno, margen_error, True ) 61 | area = abs(cv2.contourArea(contorno_aprox, True)) 62 | if area >= area_min and area < area_max: 63 | cv2.drawContours(frame, [contorno_aprox], 0, color, grosor) 64 | 65 | if len(contorno_aprox) == 3: texto = "TRIANGULO" 66 | elif len(contorno_aprox) == 4:texto = "CUADRADO" 67 | elif len(contorno_aprox) == 5: texto = "PENTAGONO" 68 | 69 | (ancho_texto, alto_texto), _ = cv2.getTextSize(texto, fuente, escala, grosor) 70 | posicion_x = int(x + (ancho - ancho_texto) / 2) 71 | posicion_y = int(y + (alto / 2 + alto_texto / 2)) 72 | 73 | cv2.putText(frame, texto, (posicion_x, posicion_y), fuente, escala, color, grosor) 74 | 75 | cv2.imshow('webcam', frame) 76 | 77 | if cv2.waitKey(1) == ord('q'): break 78 | 79 | camara.release() 80 | cv2.destroyAllWindows() 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Procesamiento de video/reconocimiento_facial.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | color = (0, 255, 255) 4 | grosor = 2 5 | 6 | clasificador = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml') 7 | 8 | camara = cv2.VideoCapture(0) 9 | if not camara.isOpened(): 10 | print("No es posible abrir la cámara") 11 | exit() 12 | 13 | while True: 14 | ret, frame = camara.read() 15 | if not ret: 16 | print("No es posible obtener la imagen") 17 | break 18 | frame_byn = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 19 | 20 | caras = clasificador.detectMultiScale(frame_byn) 21 | for (x, y, ancho, alto) in caras: 22 | cv2.rectangle(frame,(x, y),(x + ancho, y + alto),color, grosor) 23 | 24 | cv2.imshow('webcam', frame) 25 | 26 | if cv2.waitKey(1) == ord('q'): break 27 | 28 | camara.release() 29 | cv2.destroyAllWindows() 30 | 31 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Procesamiento de video/reconocimiento_facial_poca_luz.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | color = (0, 255, 255) 4 | grosor = 2 5 | 6 | clasificador = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml') 7 | 8 | incremento_brillo = 0 9 | 10 | def modifica_brillo(img): 11 | hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) 12 | h, s, v = cv2.split(hsv) 13 | 14 | limite = 255 - incremento_brillo 15 | v[v > limite] = 255 16 | v[v <= limite] += incremento_brillo 17 | 18 | hsv = cv2.merge((h, s, v)) 19 | img = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR) 20 | return img 21 | 22 | def incrementa_brillo(valor): 23 | global incremento_brillo 24 | incremento_brillo = valor 25 | 26 | cv2.namedWindow('webcam') 27 | cv2.createTrackbar('Brillo', 'webcam', 0, 255, incrementa_brillo) 28 | 29 | camara = cv2.VideoCapture(0) 30 | if not camara.isOpened(): 31 | print("No es posible abrir la cámara") 32 | exit() 33 | 34 | while True: 35 | ret, frame = camara.read() 36 | if not ret: 37 | print("No es posible obtener la imagen") 38 | break 39 | 40 | frame = modifica_brillo(frame) 41 | 42 | frame_byn = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 43 | 44 | caras = clasificador.detectMultiScale(frame_byn) 45 | for (x, y, ancho, alto) in caras: 46 | cv2.rectangle(frame,(x, y),(x + ancho, y + alto),color, grosor) 47 | 48 | cv2.imshow('webcam', frame) 49 | 50 | if cv2.waitKey(1) == ord('q'): break 51 | 52 | camara.release() 53 | cv2.destroyAllWindows() 54 | 55 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Realidad aumentada/monoculo_imagen_estatica.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | monoculo = cv2.imread('../imagenes/monoculo.jpg') 4 | alto_monoculo, ancho_monoculo, _ = monoculo.shape 5 | talla_monoculo = 1.3 6 | offset_monoculo = 5 7 | 8 | proporciones_monoculo = ancho_monoculo/alto_monoculo 9 | 10 | clasificador = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml') 11 | clasificador_ojos = cv2.CascadeClassifier('../haarcascades/haarcascade_eye.xml') 12 | 13 | img = cv2.imread('../imagenes/Einstein.jpg') 14 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 15 | 16 | alto_imagen, ancho_imagen, _ = img.shape 17 | 18 | caras = clasificador.detectMultiScale(img_byn) 19 | for (x_cara, y_cara, ancho_cara, alto_cara) in caras: 20 | cara = img_byn[y_cara:y_cara+alto_cara, x_cara:x_cara+ancho_cara] 21 | ojos = clasificador_ojos.detectMultiScale(cara) 22 | if len(ojos) != 2 : continue 23 | (x_ojo0, y_ojo0, ancho_ojo0, _) = ojos[0] 24 | (x_ojo1, y_ojo1, ancho_ojo1, _) = ojos[1] 25 | if x_ojo0 > x_ojo1 : 26 | x_ojo = x_ojo0 + int(ancho_ojo0/offset_monoculo) 27 | y_ojo = y_ojo0 28 | ancho_ojo = ancho_ojo0 29 | else: 30 | x_ojo = x_ojo1 + int(ancho_ojo1/offset_monoculo) 31 | y_ojo = y_ojo1 32 | ancho_ojo = ancho_ojo1 33 | 34 | ancho_monoculo = int(ancho_ojo*talla_monoculo) 35 | alto_monoculo = int(ancho_monoculo/proporciones_monoculo) 36 | monoculo = cv2.resize(monoculo, (ancho_monoculo, alto_monoculo)) 37 | y_monoculo = y_ojo + y_cara 38 | x_monoculo = x_ojo + y_cara 39 | 40 | if x_monoculo >= 0 and y_monoculo >= 0 and x_monoculo+ancho_monoculo <= ancho_imagen and y_monoculo+alto_monoculo <= alto_imagen : 41 | roi = img[y_monoculo:y_monoculo+alto_monoculo, x_monoculo:x_monoculo+ancho_monoculo] 42 | roi = cv2.bitwise_and(monoculo, roi) 43 | img[y_monoculo:y_monoculo+alto_monoculo, x_monoculo:x_monoculo+ancho_monoculo] = roi 44 | 45 | cv2.imshow('Einstein',img) 46 | 47 | cv2.waitKey(0) 48 | cv2.destroyAllWindows() 49 | 50 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Realidad aumentada/monoculo_webcam.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | monoculo = cv2.imread('../imagenes/monoculo.jpg') 4 | alto_monoculo, ancho_monoculo, _ = monoculo.shape 5 | talla_monoculo = 1.3 6 | proporciones_monoculo = ancho_monoculo/alto_monoculo 7 | offset_monoculo = 5 8 | 9 | area_min = 10000 10 | 11 | clasificador = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml') 12 | clasificador_ojos = cv2.CascadeClassifier('../haarcascades/haarcascade_eye.xml') 13 | 14 | camara = cv2.VideoCapture(0) 15 | if not camara.isOpened(): 16 | print("No es posible abrir la cámara") 17 | exit() 18 | 19 | ancho_ventana = int(camara.get(cv2.CAP_PROP_FRAME_WIDTH)) 20 | alto_ventana = int(camara.get(cv2.CAP_PROP_FRAME_HEIGHT)) 21 | 22 | while True: 23 | ret, frame = camara.read() 24 | if not ret: 25 | print("No es posible obtener la imagen") 26 | break 27 | 28 | frame_byn = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 29 | 30 | caras = clasificador.detectMultiScale(frame_byn) 31 | for (x_cara, y_cara, ancho_cara, alto_cara) in caras: 32 | if ancho_cara*alto_cara > area_min: 33 | cara = frame_byn[y_cara:y_cara+alto_cara, x_cara:x_cara+ancho_cara] 34 | ojos = clasificador_ojos.detectMultiScale(cara) 35 | if len(ojos) != 2 : continue 36 | (x_ojo0, y_ojo0, ancho_ojo0, _) = ojos[0] 37 | (x_ojo1, y_ojo1, ancho_ojo1, _) = ojos[1] 38 | if x_ojo0 > x_ojo1 : 39 | x_ojo = x_ojo0 + int(ancho_ojo0/offset_monoculo) 40 | y_ojo = y_ojo0 41 | ancho_ojo = ancho_ojo0 42 | else: 43 | x_ojo = x_ojo1 + int(ancho_ojo1/offset_monoculo) 44 | y_ojo = y_ojo1 45 | ancho_ojo = ancho_ojo1 46 | 47 | ancho_monoculo = int(ancho_ojo*talla_monoculo) 48 | alto_monoculo = int(ancho_monoculo/proporciones_monoculo) 49 | monoculo = cv2.resize(monoculo, (ancho_monoculo, alto_monoculo)) 50 | x_monoculo = x_ojo + x_cara 51 | y_monoculo = y_ojo + y_cara 52 | if x_monoculo >= 0 and y_monoculo>= 0 and x_monoculo+ancho_monoculo <= ancho_ventana and y_monoculo+alto_monoculo <= alto_ventana : 53 | roi = frame[y_monoculo:y_monoculo+alto_monoculo, x_monoculo:x_monoculo+ancho_monoculo] 54 | roi = cv2.bitwise_and(monoculo, roi) 55 | frame[y_monoculo:y_monoculo+alto_monoculo, x_monoculo:x_monoculo+ancho_monoculo] = roi 56 | 57 | cv2.imshow('webcam',frame) 58 | 59 | if cv2.waitKey(1) == ord('q'): break 60 | 61 | camara.release() 62 | cv2.destroyAllWindows() 63 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Realidad aumentada/sombrero_imagen_estatica.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | sombrero = cv2.imread('../imagenes/sombrero.jpg') 4 | alto_sombrero, ancho_sombrero, _ = sombrero.shape 5 | talla_sombrero = 1.4 6 | proporciones_sombrero = ancho_sombrero/alto_sombrero 7 | 8 | 9 | clasificador = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml') 10 | 11 | img = cv2.imread('../imagenes/Einstein.jpg') 12 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 13 | 14 | alto_imagen, ancho_imagen, _ = img.shape 15 | 16 | caras = clasificador.detectMultiScale(img_byn) 17 | for (x_cara, y_cara, ancho_cara, alto_cara) in caras: 18 | ancho_sombrero = int(ancho_cara*talla_sombrero) 19 | alto_sombrero = int(ancho_sombrero/proporciones_sombrero) 20 | sombrero = cv2.resize(sombrero, (ancho_sombrero, alto_sombrero)) 21 | y_sombrero = y_cara-alto_sombrero 22 | x_sombrero = int(x_cara+ancho_cara/2-ancho_sombrero/2) 23 | 24 | if x_sombrero >= 0 and y_sombrero>= 0 and x_sombrero+ancho_sombrero <= ancho_imagen and y_sombrero+alto_sombrero <= alto_imagen : 25 | roi = img[y_sombrero:y_sombrero+alto_sombrero, x_sombrero:x_sombrero+ancho_sombrero] 26 | roi = cv2.bitwise_and(sombrero, roi) 27 | img[y_sombrero:y_sombrero+alto_sombrero, x_sombrero:x_sombrero+ancho_sombrero] = roi 28 | 29 | cv2.imshow('Einstein',img) 30 | 31 | cv2.waitKey(0) 32 | cv2.destroyAllWindows() 33 | 34 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Realidad aumentada/sombrero_webcam.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | sombrero = cv2.imread('../imagenes/sombrero.jpg') 4 | alto_sombrero, ancho_sombrero, _ = sombrero.shape 5 | talla_sombrero = 1.4 6 | proporciones_sombrero = ancho_sombrero/alto_sombrero 7 | 8 | area_min = 10000 9 | 10 | clasificador = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml') 11 | 12 | camara = cv2.VideoCapture(0) 13 | if not camara.isOpened(): 14 | print("No es posible abrir la cámara") 15 | exit() 16 | 17 | ancho_ventana = int(camara.get(cv2.CAP_PROP_FRAME_WIDTH)) 18 | alto_ventana = int(camara.get(cv2.CAP_PROP_FRAME_HEIGHT)) 19 | 20 | while True: 21 | ret, frame = camara.read() 22 | if not ret: 23 | print("No es posible obtener la imagen") 24 | break 25 | 26 | frame_byn = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 27 | 28 | caras = clasificador.detectMultiScale(frame_byn) 29 | for (x_cara, y_cara, ancho_cara, alto_cara) in caras: 30 | if ancho_cara*alto_cara > area_min: 31 | ancho_sombrero = int(ancho_cara*talla_sombrero) 32 | alto_sombrero = int(ancho_sombrero/proporciones_sombrero) 33 | sombrero = cv2.resize(sombrero, (ancho_sombrero, alto_sombrero)) 34 | y_sombrero = y_cara-alto_sombrero 35 | x_sombrero = int(x_cara+ancho_cara/2-ancho_sombrero/2) 36 | if x_sombrero >= 0 and y_sombrero>= 0 and x_sombrero+ancho_sombrero <= ancho_ventana and y_sombrero+alto_sombrero <= alto_ventana : 37 | roi = frame[y_sombrero:y_sombrero+alto_sombrero, x_sombrero:x_sombrero+ancho_sombrero] 38 | roi = cv2.bitwise_and(sombrero, roi) 39 | frame[y_sombrero:y_sombrero+alto_sombrero, x_sombrero:x_sombrero+ancho_sombrero] = roi 40 | 41 | cv2.imshow('webcam',frame) 42 | 43 | if cv2.waitKey(10) == ord('q'): break 44 | 45 | camara.release() 46 | cv2.destroyAllWindows() 47 | 48 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Reconocimiento de objetos/__pycache__/face_recognition.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/Reconocimiento de objetos/__pycache__/face_recognition.cpython-37.pyc -------------------------------------------------------------------------------- /Codigo/OpenCV/Reconocimiento de objetos/almacenamiento_facial.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | archivo_persona = '../imagenes/Humphrey.jpg' 4 | archivo_cara = '../imagenes/caras/Humphrey.jpg' 5 | 6 | clasificador = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml') 7 | 8 | img = cv2.imread(archivo_persona) 9 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 10 | 11 | caras = clasificador.detectMultiScale(img_byn) 12 | x, y, ancho, alto = caras[0] 13 | img_cara = img[y:y+alto, x:x+ancho] 14 | cv2.imwrite(archivo_cara, img_cara) 15 | 16 | print("Cara almacenada") 17 | 18 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Reconocimiento de objetos/identificacion_personas.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | from os import listdir 3 | 4 | color = (0, 255, 255) 5 | grosor = 2 6 | fuente = cv2.FONT_HERSHEY_COMPLEX 7 | escala = 1 8 | 9 | carpeta_caras = '../imagenes/caras/' 10 | lista_nombres = [] 11 | lista_caras = [] 12 | 13 | error = 10 14 | 15 | for archivo in listdir(carpeta_caras): 16 | lista_nombres.append(archivo.replace(".jpg","")) 17 | lista_caras.append(cv2.imread(carpeta_caras+archivo, 0)) 18 | 19 | clasificador = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml') 20 | 21 | img = cv2.imread('../imagenes/Humphrey_Ingrid.jpg') 22 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 23 | 24 | caras = clasificador.detectMultiScale(img_byn) 25 | for (x, y, ancho, alto) in caras: 26 | #cv2.rectangle(img,(x, y),(x + ancho, y + alto),color, grosor) 27 | for indice in range(len(lista_caras)): 28 | patron = cv2.resize(lista_caras[indice], (ancho, alto)) 29 | res = cv2.matchTemplate(img_byn, patron, cv2.TM_SQDIFF_NORMED) 30 | min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) 31 | esq_sup_izq = min_loc 32 | 33 | (x1, y1) = esq_sup_izq 34 | if abs(x-x1) < error and abs(y-y1) < error : 35 | #esq_inf_der_ingrid = (esq_sup_izq_ingrid[0] + ancho, esq_sup_izq_ingrid[1] + alto) 36 | #cv2.rectangle(img, esq_sup_izq_ingrid, esq_inf_der_ingrid, (0, 0, 255), grosor) 37 | cv2.putText(img, lista_nombres[indice], (x, y), fuente, escala, color, grosor) 38 | break 39 | 40 | cv2.imshow('Identificacion personas',img) 41 | 42 | cv2.waitKey(0) 43 | cv2.destroyAllWindows() 44 | 45 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Reconocimiento de objetos/reconocimiento_facial.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | color = (0, 255, 255) 4 | grosor = 2 5 | 6 | clasificador = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml') 7 | 8 | img = cv2.imread('../imagenes/Tesla.jpg') 9 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 10 | 11 | caras = clasificador.detectMultiScale(img_byn) 12 | for (x, y, ancho, alto) in caras: 13 | cv2.rectangle(img,(x, y),(x + ancho, y + alto),color, grosor) 14 | 15 | cv2.imshow('Tesla',img) 16 | 17 | cv2.waitKey(0) 18 | cv2.destroyAllWindows() 19 | 20 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Reconocimiento de objetos/reconocimiento_facial_ojos.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | color = (0, 255, 255) 4 | grosor = 2 5 | 6 | clasificador_caras = cv2.CascadeClassifier('../haarcascades/haarcascade_frontalface_default.xml') 7 | clasificador_ojos = cv2.CascadeClassifier('../haarcascades/haarcascade_eye.xml') 8 | 9 | 10 | img = cv2.imread('../imagenes/Einstein.jpg') 11 | img_byn = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 12 | 13 | caras = clasificador_caras.detectMultiScale(img_byn) 14 | for (x, y, ancho, alto) in caras: 15 | cv2.rectangle(img,(x, y),(x + ancho, y + alto),color, grosor) 16 | cara = img_byn[y:y+alto, x:x+ancho] 17 | ojos = clasificador_ojos.detectMultiScale(cara) 18 | for (x1, y1, ancho1, alto1) in ojos: 19 | radio = int((ancho1 + alto1)/4) 20 | cv2.circle(img, (x1 + x + radio, y1 + y + radio), radio, color, grosor) 21 | 22 | cv2.imshow('Einstein',img) 23 | 24 | cv2.waitKey(0) 25 | cv2.destroyAllWindows() 26 | 27 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Sustracciвn de fondo/alarma_movimiento.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | color = (0, 255, 255) 4 | grosor = 2 5 | area_min = 50000 6 | 7 | carpeta_fotogramas = '../imagenes/alarma' 8 | 9 | backSub = cv2.createBackgroundSubtractorKNN() 10 | 11 | camara = cv2.VideoCapture(0) 12 | if not camara.isOpened(): 13 | print("No es posible abrir la cámara") 14 | exit() 15 | 16 | while(True): 17 | ret, frame = camara.read() 18 | if not ret: 19 | print("No es posible obtener la imagen") 20 | break 21 | mascara_1er_plano = backSub.apply(frame) 22 | contornos, _ = cv2.findContours(mascara_1er_plano, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE) 23 | if len(contornos): 24 | contorno_max = max(contornos, key = cv2.contourArea) 25 | area = abs(cv2.contourArea(contorno_max, True)) 26 | #print(area) 27 | if area > area_min: 28 | cv2.imwrite(carpeta_fotogramas+'/fotograma.jpg', frame) 29 | 30 | cv2.drawContours(frame, [contorno_max], 0, color, grosor) 31 | cv2.imshow('webcam',frame) 32 | cv2.imshow('mascara 1er plano',mascara_1er_plano) 33 | 34 | if cv2.waitKey(1) == ord('q'): break 35 | 36 | camara.release() 37 | cv2.destroyAllWindows() 38 | -------------------------------------------------------------------------------- /Codigo/OpenCV/Sustracciвn de fondo/sustraccion_fondo.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | backSub = cv2.createBackgroundSubtractorKNN() 4 | 5 | camara = cv2.VideoCapture(0) 6 | if not camara.isOpened(): 7 | print("No es posible abrir la cámara") 8 | exit() 9 | 10 | while(True): 11 | ret, frame = camara.read() 12 | if not ret: 13 | print("No es posible obtener la imagen") 14 | break 15 | mascara_1er_plano = backSub.apply(frame) 16 | 17 | cv2.imshow('webcam',frame) 18 | cv2.imshow('mascara 1er plano',mascara_1er_plano) 19 | 20 | if cv2.waitKey(1) == ord('q'): break 21 | 22 | camara.release() 23 | cv2.destroyAllWindows() 24 | -------------------------------------------------------------------------------- /Codigo/OpenCV/eventos de raton y teclado/captura_teclas.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy 3 | 4 | img = numpy.ones((300,300),numpy.uint8)*255 5 | cv2.imshow('Captura teclas', img) 6 | 7 | while True: 8 | key = cv2.waitKey(100) 9 | if key != -1: 10 | print(key) 11 | -------------------------------------------------------------------------------- /Codigo/OpenCV/eventos de raton y teclado/eventos_raton.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy 3 | 4 | img = numpy.ones((600, 600, 3), numpy.uint8) 5 | img[:] = (255, 255, 255) 6 | 7 | color = (0, 0, 255) 8 | grosor = 4 9 | fuente = cv2.FONT_HERSHEY_SIMPLEX 10 | escala = 1 11 | 12 | cv2.imshow('Eventos raton', img) 13 | 14 | def eventos_raton(evento, x, y, flags, parametros): 15 | if evento == cv2.EVENT_LBUTTONDOWN: 16 | cv2.putText(img, "Clic izquierdo", (x, y), fuente, escala, color, grosor) 17 | elif evento == cv2.EVENT_RBUTTONDOWN: 18 | cv2.putText(img, "Clic derecho", (x, y), fuente, escala, color, grosor) 19 | 20 | cv2.imshow('Eventos raton', img) 21 | 22 | 23 | cv2.setMouseCallback('Eventos raton', eventos_raton) 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Codigo/OpenCV/eventos de raton y teclado/pizarra.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | import cv2 3 | 4 | color = (0, 0, 255) 5 | grosor = 2 6 | 7 | img = numpy.zeros((600, 600, 3), numpy.uint8) 8 | img[:] = (255, 255, 255) 9 | cv2.imshow('Pizarra',img) 10 | 11 | def pinta(event,x,y,flags,param): 12 | global x_prev,y_prev 13 | if event == cv2.EVENT_LBUTTONDOWN: 14 | x_prev,y_prev = x,y 15 | elif event == cv2.EVENT_MOUSEMOVE and flags == cv2.EVENT_FLAG_LBUTTON: 16 | cv2.line(img,(x_prev,y_prev),(x,y),color, grosor) 17 | x_prev,y_prev = x,y 18 | 19 | cv2.imshow('Pizarra',img) 20 | 21 | cv2.setMouseCallback('Pizarra',pinta) 22 | 23 | 24 | -------------------------------------------------------------------------------- /Codigo/OpenCV/eventos de raton y teclado/pizarra_teclas.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | import cv2 3 | 4 | color = (0, 0, 255) 5 | grosor = 2 6 | borrado = False 7 | 8 | img = numpy.zeros((600, 600, 3), numpy.uint8) 9 | img[:] = (255, 255, 255) 10 | cv2.imshow('Pizarra',img) 11 | 12 | def pinta(event,x,y,flags,param): 13 | global x_prev,y_prev, color, grosor 14 | 15 | if event == cv2.EVENT_LBUTTONDOWN: 16 | x_prev,y_prev = x,y 17 | elif event == cv2.EVENT_MOUSEMOVE and flags == cv2.EVENT_FLAG_LBUTTON: 18 | cv2.line(img,(x_prev,y_prev),(x,y),color, grosor) 19 | x_prev,y_prev = x,y 20 | 21 | cv2.imshow('Pizarra',img) 22 | 23 | cv2.setMouseCallback('Pizarra',pinta) 24 | 25 | while True: 26 | key = cv2.waitKey(100) 27 | if key == 13: 28 | borrado = not(borrado) 29 | if borrado : 30 | color = (255, 255, 255) 31 | grosor = 8 32 | else : 33 | color = (0, 0, 255) 34 | grosor = 2 35 | elif key == 27 or key == ord('q'): break 36 | 37 | cv2.destroyAllWindows() 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/Einstein.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/Einstein.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/Humphrey.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/Humphrey.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/Humphrey_Ingrid.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/Humphrey_Ingrid.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/Invalidos.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/Invalidos.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/Invalidos_ruido.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/Invalidos_ruido.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/Moises.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/Moises.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/Notre_Dame.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/Notre_Dame.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/Tesla.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/Tesla.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/agujeros.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/agujeros.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/alarma/fotograma.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/alarma/fotograma.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/caras/Humphrey.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/caras/Humphrey.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/caras/Ingrid.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/caras/Ingrid.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/coliseo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/coliseo.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/coliseo_recorte.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/coliseo_recorte.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/cuadricula.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/cuadricula.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/cuadricula_ruido.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/cuadricula_ruido.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/cuadro.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/cuadro.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/degradado.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/degradado.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/dos.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/dos.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/espacio.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/espacio.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/figuras_geometricas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/figuras_geometricas.png -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/figuras_geometricas2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/figuras_geometricas2.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/figuras_geometricas3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/figuras_geometricas3.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/figuras_geometricas4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/figuras_geometricas4.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/figuras_geometricas5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/figuras_geometricas5.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/hoja.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/hoja.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/ingrid.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/ingrid.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/lgtb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/lgtb.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/logo.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/mercado1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/mercado1.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/mercado2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/mercado2.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/monedas1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/monedas1.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/monedas2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/monedas2.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/monedas3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/monedas3.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/monoculo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/monoculo.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/numeros.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/numeros.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/numeros_girados.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/numeros_girados.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/panteon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/panteon.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/rejilla.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/rejilla.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen1.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen2.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen3.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen4.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen5.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_emoticono/Imagen6.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_emoticono/emoticono0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_emoticono/emoticono0.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_webcam/fotograma0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_webcam/fotograma0.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_webcam/fotograma1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_webcam/fotograma1.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_webcam/fotograma2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_webcam/fotograma2.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_webcam/fotograma3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_webcam/fotograma3.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_webcam/fotograma4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_webcam/fotograma4.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_webcam/fotograma5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_webcam/fotograma5.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_webcam/fotograma6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_webcam/fotograma6.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_webcam/fotograma7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_webcam/fotograma7.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_webcam/fotograma8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_webcam/fotograma8.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/secuencia_webcam/fotograma9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/secuencia_webcam/fotograma9.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/sombrero.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/sombrero.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/tabla_numeros.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/tabla_numeros.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/tabla_numeros_sombra.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/tabla_numeros_sombra.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/tabla_numeros_webcam.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/tabla_numeros_webcam.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/tierra.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/tierra.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/tres.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/tres.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/uno.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/uno.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/uno_girado.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/uno_girado.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/wikipedia0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/wikipedia0.jpg -------------------------------------------------------------------------------- /Codigo/OpenCV/imagenes/wikipedia3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marcombo/vision-artificial-opencv-python/800eb251ab82caf5ea32a5a01970fd4349d2380c/Codigo/OpenCV/imagenes/wikipedia3.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vision-artificial-opencv-python --------------------------------------------------------------------------------