Ask Your Question

Revision history [back]

Issue with IP camera

Hi, i'm trying to detect faces with Haar algorithm from an ip camera but my camera isn't able to broadcast a great videofeed so i decided to just take a picture (.jpg) from the camera each time the code needs it. But the code is'nt working. And i can't find where is the error? The error is : "error: C:\slave\WinInstallerMegaPack\src\opencv\modules\core\src\array.cpp:2482: error: (-206) Unrecognized or unsupported array type" Thank's for your help

import numpy as np import cv2 from datetime import datetime import cv2.cv as cv import numpy as np import os import time

def detect(img, cascade): rects = cascade.detectMultiScale(img, scaleFactor=1.5, minNeighbors=4, minSize=(30, 30), flags = cv.CV_HAAR_SCALE_IMAGE) if len(rects) == 0: return [] rects[:,2:] += rects[:,:2] return rects

def draw_rects(img, rects, color): for x1, y1, x2, y2 in rects: print ("###########1##############")

if __name__ == '__main__': import sys, getopt try: video_src = video_src[2] except: video_src = 0 cascade_fn = 'C:\Opencv24\opencv\data\haarcascades\haarcascade_frontalface_default.xml' cascade = cv2.CascadeClassifier(cascade_fn)

while True:
    tps1= time.clock()
    img = cv2.imread("http://10.0.0.9:8080/shot.jpg",cv2.CV_LOAD_IMAGE_GRAYSCALE) 
    rects = detect(img, cascade)
    draw_rects(gray, rects, (0, 255, 0))
    tps2= time.clock()
    print (1/(tps2-tps1))
    cv2.imshow('Visage',img)
    if 0xFF & cv2.waitKey(5) == 27:
        break
cv2.destroyAllWindows()
click to hide/show revision 2
No.2 Revision

updated 2013-03-05 03:45:32 -0500

berak gravatar image

Issue with IP camera

Hi, i'm trying to detect faces with Haar algorithm from an ip camera but my camera isn't able to broadcast a great videofeed so i decided to just take a picture (.jpg) from the camera each time the code needs it. But the code is'nt working. And i can't find where is the error? The error is : :

"error: C:\slave\WinInstallerMegaPack\src\opencv\modules\core\src\array.cpp:2482: error: (-206) Unrecognized or unsupported array type" type"

Thank's for your help

import numpy as np
import cv2
from datetime import datetime
import cv2.cv as cv
import numpy as np
import os
import time

time def detect(img, cascade): rects = cascade.detectMultiScale(img, scaleFactor=1.5, minNeighbors=4, minSize=(30, 30), flags = cv.CV_HAAR_SCALE_IMAGE) if len(rects) == 0: return [] rects[:,2:] += rects[:,:2] return rects

rects def draw_rects(img, rects, color): for x1, y1, x2, y2 in rects: print ("###########1##############")

("###########1##############") if __name__ == '__main__': import sys, getopt try: video_src = video_src[2] except: video_src = 0 cascade_fn = 'C:\Opencv24\opencv\data\haarcascades\haarcascade_frontalface_default.xml' cascade = cv2.CascadeClassifier(cascade_fn)

cv2.CascadeClassifier(cascade_fn)

    while True:
     tps1= time.clock()
     img = cv2.imread("http://10.0.0.9:8080/shot.jpg",cv2.CV_LOAD_IMAGE_GRAYSCALE) 
     rects = detect(img, cascade)
     draw_rects(gray, rects, (0, 255, 0))
     tps2= time.clock()
     print (1/(tps2-tps1))
     cv2.imshow('Visage',img)
     if 0xFF & cv2.waitKey(5) == 27:
         break
 cv2.destroyAllWindows()