Guest User

Untitled

a guest
May 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import matplotlib.image as img
  3. import numpy as np
  4. import cv2
  5.  
  6. #IM=img.imread("img01.jpg")
  7. #nF,nC=IM.shape #Obtiene el tamaño de la imagen
  8.  
  9. camera = cv2.VideoCapture(1)
  10. fourcc = cv2.VideoWriter_fourcc(*'XVID')
  11. out = cv2.VideoWriter('output3.avi',fourcc, 20.0, (640,480))
  12. cv2.namedWindow('Ventana1')
  13.  
  14. while cv2.waitKey(1)==-1:
  15. retval, img = camera.read()
  16. gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  17. #Def. ROI
  18. nf,nc=gray.shape
  19. nf3=round(nf/3)
  20. gray = gray[nf3:2*nf3,:]
  21. CAP1 = gray.copy()
  22. #Ecualización
  23. clahe = cv2.createCLAHE(clipLimit=20.0, tileGridSize=(8,8))
  24. gray= clahe.apply(gray)
  25. CAP2 = gray.copy()
  26. #Filtro Mediana
  27. gray = cv2.medianBlur(gray,5)
  28. CAP3 = gray.copy()
  29. #Binarización
  30. ret,gray = cv2.threshold(CAP2,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
  31. CAP4 = 255-gray.copy()
  32. #Muestra por pantalla
  33. cv2.imshow('Ventana1',CAP3)
  34. out.write(np.concatenate((CAP1,CAP2,CAP3,CAP4),axis=0))
  35. cv2.imshow('Ventana2',np.concatenate((CAP1,CAP2,CAP3,CAP4),axis=0))
  36. #CIERRA
  37. cv2.destroyAllWindows()
  38. camera.release()
Add Comment
Please, Sign In to add comment