Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import matplotlib.image as img
- import numpy as np
- import cv2
- #IM=img.imread("img01.jpg")
- #nF,nC=IM.shape #Obtiene el tamaño de la imagen
- camera = cv2.VideoCapture(1)
- fourcc = cv2.VideoWriter_fourcc(*'XVID')
- out = cv2.VideoWriter('output3.avi',fourcc, 20.0, (640,480))
- cv2.namedWindow('Ventana1')
- while cv2.waitKey(1)==-1:
- retval, img = camera.read()
- gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
- #Def. ROI
- nf,nc=gray.shape
- nf3=round(nf/3)
- gray = gray[nf3:2*nf3,:]
- CAP1 = gray.copy()
- #Ecualización
- clahe = cv2.createCLAHE(clipLimit=20.0, tileGridSize=(8,8))
- gray= clahe.apply(gray)
- CAP2 = gray.copy()
- #Filtro Mediana
- gray = cv2.medianBlur(gray,5)
- CAP3 = gray.copy()
- #Binarización
- ret,gray = cv2.threshold(CAP2,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
- CAP4 = 255-gray.copy()
- #Muestra por pantalla
- cv2.imshow('Ventana1',CAP3)
- out.write(np.concatenate((CAP1,CAP2,CAP3,CAP4),axis=0))
- cv2.imshow('Ventana2',np.concatenate((CAP1,CAP2,CAP3,CAP4),axis=0))
- #CIERRA
- cv2.destroyAllWindows()
- camera.release()
Add Comment
Please, Sign In to add comment