Ask Your Question
0

Issue with IP camera

asked 2013-03-05 03:30:26 -0600

T@nguy gravatar image

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

berak gravatar image

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()
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-03-05 03:48:14 -0600

berak gravatar image

updated 2013-03-05 03:54:08 -0600

opencv has (limited) ipcam support via ffmpeg. it probably won't work on windows with opencv < 2.4.3.

and you have to use the VideoCapture for this (even if it's just 1 file), imread won't do.

the "Unrecognized or unsupported array type" error only says, the img from imread was empty.

adding a check for that case, is always a good idea!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-05 03:30:26 -0600

Seen: 858 times

Last updated: Mar 05 '13