Ask Your Question

Revision history [back]

I have an error in #import numpy as np, why is that?

The code I am trying to run is this one: ( Microsoft Visual Studio Coomunity 2015, Open cv 3.1.0. and numpy is downloaded in directory C:)

PS: how can I copy-paste the code here so you can read it properly?

import numpy as np

import cv2

//cargamos la plantilla e inicializamos la webcam : face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml') cap = cv2.VideoCapture(0)

while (True) : //leemos un frame y lo guardamos ret, img = cap.read()

//convertimos la imagen a blanco y negro
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

//buscamos las coordenadas de los rostros(si los hay) y
//guardamos su posicion
faces = face_cascade.detectMultiScale(gray, 1.3, 5)

//Dibujamos un rectangulo en las coordenadas de cada rostro
for (x, y, w, h) in faces :

cv2.rectangle(img, (x, y), (x + w, y + h), (125, 255, 0), 2)

//Mostramos la imagen cv2.imshow('img', img)

//con la tecla 'q' salimos del programa if cv2.waitKey(1) & 0xFF == ord('q') : break cap.release() cv2 - destroyAllWindows()

click to hide/show revision 2
No.2 Revision

updated 2016-11-16 01:00:02 -0600

berak gravatar image

I have an error in #import numpy as np, why is that?

The code I am trying to run is this one: ( Microsoft Visual Studio Coomunity 2015, Open cv 3.1.0. and numpy is downloaded in directory C:)

PS: how can I copy-paste the code here so you can read it properly?

import
#import numpy as np

import cv2

np #import cv2 //cargamos la plantilla e inicializamos la webcam : face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml') cap = cv2.VideoCapture(0)

cv2.VideoCapture(0) while (True) : //leemos un frame y lo guardamos ret, img = cap.read()

cap.read()
//convertimos la imagen a blanco y negro
 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
 //buscamos las coordenadas de los rostros(si los hay) y
 //guardamos su posicion
 faces = face_cascade.detectMultiScale(gray, 1.3, 5)
 //Dibujamos un rectangulo en las coordenadas de cada rostro
 for (x, y, w, h) in faces :

cv2.rectangle(img, (x, y), (x + w, y + h), (125, 255, 0), 2)

2) //Mostramos la imagen cv2.imshow('img', img)

img) //con la tecla 'q' salimos del programa if cv2.waitKey(1) & 0xFF == ord('q') : break cap.release() cv2 - destroyAllWindows()

destroyAllWindows()
click to hide/show revision 3
retagged

updated 2016-11-16 01:54:00 -0600

berak gravatar image

I have an error in #import numpy as np, why is that?

The code I am trying to run is this one: ( Microsoft Visual Studio Coomunity 2015, Open cv 3.1.0. and numpy is downloaded in directory C:)

PS: how can I copy-paste the code here so you can read it properly?

#import numpy as np
#import cv2

//cargamos la plantilla e inicializamos la webcam :
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')
cap = cv2.VideoCapture(0)

while (True) :
    //leemos un frame y lo guardamos
    ret, img = cap.read()

    //convertimos la imagen a blanco y negro
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    //buscamos las coordenadas de los rostros(si los hay) y
    //guardamos su posicion
    faces = face_cascade.detectMultiScale(gray, 1.3, 5)

    //Dibujamos un rectangulo en las coordenadas de cada rostro
    for (x, y, w, h) in faces :
cv2.rectangle(img, (x, y), (x + w, y + h), (125, 255, 0), 2)

//Mostramos la imagen
cv2.imshow('img', img)

//con la tecla 'q' salimos del programa
if cv2.waitKey(1) & 0xFF == ord('q') :
    break
    cap.release()
    cv2 - destroyAllWindows()