def runFullSequential(src, cleanUp=False):
    if cleanUp:
        if os.path.exists('./videos_full'):
            shutil.rmtree('./videos_full')

    manager = FullStorageManager(None, CropSplitter(), 'videos_full')
    now = timer()
    manager.put(src,
                os.path.basename(src),
                parallel=False,
                args={
                    'encoding': XVID,
                    'size': -1,
                    'sample': 1.0,
                    'offset': 0,
                    'limit': -1,
                    'batch_size': 50,
                    'num_processes': os.cpu_count()
                })
    put_time = timer() - now
    logrecord('full', ({'file': src}), 'put', str({'elapsed': put_time}), 's')

    clips = manager.get(os.path.basename(src), Condition())
    pipelines = []
    for c in clips:
        pipelines.append(c[KeyPoints()])
    result = counts(pipelines, ['one'], stats=True)
    logrecord('full', ({'file': src}), 'get', str(result), 's')
def runSimple(src, cleanUp=False):
    if cleanUp:
        if os.path.exists('./videos_simple'):
            shutil.rmtree('./videos_simple')

    manager = SimpleStorageManager('videos_simple')
    now = timer()
    manager.put(src,
                os.path.basename(src),
                args={
                    'encoding': XVID,
                    'size': -1,
                    'sample': 1.0,
                    'offset': 0,
                    'limit': -1,
                    'batch_size': 50
                })
    put_time = timer() - now
    logrecord('simple', ({
        'file': src
    }), 'put', str({'elapsed': put_time}), 's')

    clips = manager.get(os.path.basename(src), lambda f: True)
    pipelines = []
    for c in clips:
        pipelines.append(c[KeyPoints()])
    result = counts(pipelines, ['one'], stats=True)
    logrecord('simple', ({'file': src}), 'get', str(result), 's')
def runFullPutMany(src_list, batch_size=30, cleanUp=False):
    if cleanUp:
        if os.path.exists('./videos_full'):
            shutil.rmtree('./videos_full')

    manager = FullStorageManager(None, CropSplitter(), 'videos_full')
    now = timer()
    targets = [os.path.basename(src) for src in src_list]
    logs = manager.put_many(src_list,
                            targets,
                            log=True,
                            args={
                                'encoding': XVID,
                                'size': -1,
                                'sample': 1.0,
                                'offset': 0,
                                'limit': -1,
                                'batch_size': batch_size,
                                'num_processes': os.cpu_count()
                            })
    put_time = timer() - now
    logrecord('full', ({
        'file': src_list
    }), 'put', str({'elapsed': put_time}), 's')
    for i, log in enumerate(logs):
        logrecord('fullMany', i, 'put', str({'elapsed': log}), 's')

    # Don't call get() for now
    for src in src_list:
        clips = manager.get(os.path.basename(src), Condition())
        pipelines = []
        for c in clips:
            pipelines.append(c[KeyPoints()])
        result = counts(pipelines, ['one'], stats=True)
        logrecord('full', ({'file': src}), 'get', str(result), 's')
示例#4
0
def runNaive(src, cleanUp = False):
    if cleanUp:
        if os.path.exists('./videos_naive'):
            shutil.rmtree('./videos_naive')

    c = VideoStream(src)
    pipelines = c[KeyPoints()]
    result = count(pipelines, ['one'], stats=True)

    logrecord('naive',({'file': src}), 'get', str(result), 's')
示例#5
0
def test_put(src, cleanUp = False):
    if cleanUp:
        if os.path.exists('./videos'):
            shutil.rmtree('./videos')
    manager = FullStorageManager(None, CropSplitter(), 'videos')
    start = time.time()
    manager.put(src, os.path.basename(src), parallel = True, args={'encoding': XVID, 'size': -1, 'sample': 1.0, 'offset': 0, 'limit': -1, 'batch_size': 50, 'num_processes': 6})
    print("Put time:", time.time() - start)
    clips = manager.get(os.path.basename(src), Condition(label='person'))
    pipelines = []
    for c in clips:
        pipelines.append(c[KeyPoints()])
    result = counts(pipelines, ['one'], stats=True)
    logrecord('full', ({'file': src}), 'get', str(result), 's')
示例#6
0
def runFull(src, cleanUp=True, limit=-1, background_scale=1, optimizer=False):
    if cleanUp:
        if os.path.exists('/tmp/videos'):
            shutil.rmtree('/tmp/videos')

    manager = FullStorageManager(
        CustomTagger(FixedCameraBGFGSegmenter().segment, batch_size=30),
        CropSplitter(), '/tmp/videos')
    start = time.time()
    output = manager.put(src,
                         'test',
                         parallel=False,
                         args={
                             'encoding': XVID,
                             'size': -1,
                             'sample': 1.0,
                             'offset': 0,
                             'limit': limit,
                             'batch_size': 30,
                             'background_scale': background_scale
                         })
    end = time.time()

    clips = manager.get('test', Condition(label='foreground'))

    region = Box(200, 550, 350, 750)

    pipelines = []
    d = SplitterOptimizer()
    for c in clips:
        pipeline = c[KeyPoints()][ActivityMetric('one', region)][Filter(
            'one', [-0.25, -0.25, 1, -0.25, -0.25], 1.5, delay=10)]
        if optimizer:
            pipeline = d.optimize(pipeline)
        pipelines.append(pipeline)

    result = counts(pipelines, ['one'], stats=True)
    logrecord('full', ({
        'size': limit,
        'optimizer': optimizer,
        'file': src,
        'background_scale': background_scale,
        'folder_size': get_size('/tmp/videos')
    }), 'get', str(result), 's', 'put', str(end - start), 's')
示例#7
0
from splitter.optimizer.splitter import SplitterOptimizer
from splitter.struct import CustomTagger, VideoStream, Box
from splitter.tracking.contour import KeyPoints
from splitter.tracking.event import Filter, ActivityMetric

if len(sys.argv) < 2:
    print("Enter filename as argv[1]")
    exit(1)
filename = sys.argv[1]

vs = VideoStream(filename, hwang=True, rows=range(0, 8000, 400))

region = Box(200, 550, 350, 750)

d = SplitterOptimizer()
pipeline = vs[KeyPoints()][ActivityMetric('one', region)][Filter(
    'one', [-0.25, -0.25, 1, -0.25, -0.25], 1.5, delay=10)]
# pipeline = d.optimize(pipeline)

result = count(pipeline, ['one'], stats=True)
print("Hwang:", result)

vs = VideoStream(filename, hwang=False, limit=500)

region = Box(200, 550, 350, 750)

d = SplitterOptimizer()
pipeline = vs[KeyPoints()][ActivityMetric('one', region)][Filter(
    'one', [-0.25, -0.25, 1, -0.25, -0.25], 1.5, delay=10)]
# pipeline = d.optimize(pipeline)