Ver Mensaje Individual
  #4 (permalink)  
Antiguo 09/04/2013, 18:13
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: Script que graba unos segundos de webcam

Código Python:
Ver original
  1. import cv
  2.  
  3. cv.NamedWindow("camera", 1)
  4. capture = cv.CreateCameraCapture(0)
  5.  
  6. width = int(cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_WIDTH))
  7. height = int(cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_HEIGHT))
  8. writer = cv.CreateVideoWriter(
  9.     filename='video.avi',
  10.     fourcc=cv.CV_FOURCC('F', 'M', 'P', '4'),
  11.     fps=25.0,
  12.     frame_size=(width,height),
  13.     is_color=1)
  14. while True:
  15.     frame = cv.QueryFrame(capture)
  16.     cv.ShowImage("camera", frame)
  17.     cv.WriteFrame(writer, frame)
  18.     k = cv.WaitKey(10);
  19.     if k == 1048678: #Close with 'f'
  20.         break

Cierras el programa con la tecla f.