Esempio n. 1
0
    interval = float(sys.argv[2])
except:
    print 'usage', sys.argv[0], ' <url> <interval>'
    sys.exit()


print 'url', url
print 'interval', interval

stamp_begin = -1.0

cf = Classifier('../models/deploy.prototxt',
    '../models/pretrained.caffemodel',
    '../models/mean.binaryproto',
    '../models/labels.txt')
vc = VideoCap(url, (256, 256), "1/3")


curr_encoding = locale.getdefaultlocale()[1]

def cb_image(image):
    global cf, quit, stamp_begin

    if image is None:
        quit = True
        return
   
    if stamp_begin < 0.0:
        stamp_begin = time.time()

    pred = cf.predicate(image)
Esempio n. 2
0
if __name__ == '__main__':
    url = sys.argv[1]

    cf = Classifier('../models/deploy.prototxt',
                    '../models/pretrained.caffemodel',
                    '../models/mean.binaryproto', '../models/labels.txt')

    quit = False

    def cb_image(img):
        global quit, cf

        if img is None:
            print 'end'
            quit = True
        else:
            pred = cf.predicate(img)
            f = cv2.resize(img, (480, 270))
            cv2.imshow('show', f)
            key = cv2.waitKey(1)
            print pred[0][1].decode('utf-8').encode(
                'gbk') + ' score:', pred[0][2]

    vc = VideoCap(url, (256, 256), "1/3")
    vc.start(cb_image)

    while not quit:
        time.sleep(1.0)

# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
Esempio n. 3
0
    cf = Classifier('../models/deploy.prototxt',
            '../models/pretrained.caffemodel',
            '../models/mean.binaryproto',
            '../models/labels.txt')

    quit = False

    def cb_image(img):
        global quit, cf

        if img is None:
            print 'end'
            quit = True
        else:
            pred = cf.predicate(img)
            f = cv2.resize(img, (480, 270))
            cv2.imshow('show', f)
            key = cv2.waitKey(1)
            print pred[0][1].decode('utf-8').encode('gbk') + ' score:', pred[0][2]


    vc = VideoCap(url, (256, 256), "1/3")
    vc.start(cb_image)

    while not quit:
        time.sleep(1.0)


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4