title: Real time face detection OpenCV, Python
body: <p>I am trying to make a basic program for a real time face detection. Here's my code (I am a newbie in OpenCV) :</p>
  
  <pre><code>import numpy as np
  import cv2
  cam = cv2.VideoCapture(0)
  name = 'detect'
  face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
  cv2.namedWindow(name, cv2.WINDOW_AUTOSIZE)
  while True:
      s, img = cam.read()
      gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
      faces = face_cascade.detectMultiScale(gray, 1.3, 5)
      #print s
      for (x,y,w,h) in faces:
          img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
      cv2.imshow(name, img)    
      k = cv2.waitKey(0)
      if k == 27:
          cv2.destroyWindow("Detect")
          break
  </code></pre>
  
  <p>But when I run this code I get this error :</p>
  
  <pre><code>OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /build/buildd/opencv-2.4.2+dfsg/modules/core/src/array.cpp, line   2482
  Traceback (most recent call last):
  File "mytry.py", line 27, in &lt;module&gt;
  cv2.imshow(name, img)    
  cv2.error: /build/buildd/opencv-2.4.2+dfsg/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat
  </code></pre>
  
  <p>I am a newbie in OpenCV ! Please tell me what is wrong with the code, why does this error arises what changes should I make ?</p>