示例#1
0
    def __call__(self, video, gtruths, cpfs, pool = None):
        result = {}
        pathdict = {}
        for id, gtruth in gtruths.items():
            gtruth.sort(key = lambda x: x.frame)
            pathdict[id] = dict((x.frame, x) for x in gtruth)

        requests = {}
        for id, gtruth in gtruths.items():
            frame, score, predicted, _ = marginals.pick([gtruth[0]], video, 
                                         last = gtruth[-1].frame,
                                         pool = pool,
                                         pairwisecost = self.pairwisecost,
                                         upperthreshold = self.upperthreshold,
                                         sigma = self.sigma,
                                         erroroverlap = self.erroroverlap,
                                         skip = self.skip,
                                         rgbbin = self.rgbbin,
                                         hogbin = self.hogbin)
                                                     
            requests[id] = (score, frame, predicted, [gtruth[0]])
            result[id] = {}
        usedclicks = len(gtruths)

        logger.info("Used {0} clicks!".format(usedclicks))

        numframes = sum(x[-1].frame - x[0].frame for x in gtruths.values())
        reqclicks = [(int(numframes * x), x) for x in cpfs]
        reqclicks.sort()

        for clicks, cpf in reqclicks:
            for _ in range(clicks - usedclicks):
                id = max((y[0], x) for x, y in requests.items())[1]

                givens = list(requests[id][3])
                givens.append(pathdict[id][requests[id][1]])
                givens.sort(key = lambda x: x.frame)

                frame, score, predicted, _ = marginals.pick(givens, video,
                                        last = max(pathdict[id]),
                                        pool = pool,
                                        pairwisecost = self.pairwisecost,
                                        upperthreshold = self.upperthreshold,
                                        sigma = self.sigma,
                                        erroroverlap = self.erroroverlap,
                                        skip = self.skip,
                                        rgbbin = self.rgbbin,
                                        hogbin = self.hogbin)

                requests[id] = (score, frame, predicted, givens)
                usedclicks += 1

                logger.info("Used {0} clicks with {1} total in this cpf!"
                            .format(usedclicks, clicks))

            for id, (_, _, path, _) in requests.iteritems():
                result[id][cpf] = path
        return result
示例#2
0
logging.basicConfig(level = logging.INFO)

g = frameiterator("/scratch/vatic/syn-occlusion2")
b = [Box(592, 48, 592 + 103, 48 + 326, 20)]
stop = 22

g = frameiterator("/scratch/virat/frames/VIRAT_S_000302_04_000453_000484")
b = [Box(156, 96, 156 + 50, 96 + 24, 270),
     Box(391, 83, 391 + 48, 83 + 22, 459)]
stop = 500

pool = multiprocessing.Pool(24)

frame, score, path, marginals = marginals.pick(b, g,
                                               last = stop,
                                               pool = pool,
                                               pairwisecost = .01,
                                               dim = (40, 40),
                                               sigma = 1,
                                               erroroverlap = 0.5,
                                               hogbin = 8,
                                               clickradius = 10,
                                               c = 1)

pickle.dump(marginals, open("occlusion.pkl", "w"))

visualize.save(visualize.highlight_paths(g, [path]), lambda x: "tmp/path{0}.jpg".format(x))

print "frame {0} with score {1}".format(frame, score)
示例#3
0
import pylab
import pickle

logging.basicConfig(level = logging.INFO)

g = Geppetto((720,480))

b = Rectangle((400, 100), color="white")
b.linear((400, 800), 20)
g.add(b)

#g = Geppetto()
#b = Rectangle((100, 100))
#b.linear((600, 100), 100)
#g.add(b)
#
#o = Rectangle((100, 350))
#o.linear((600, 350), 100)
#g.add(o)

pool = multiprocessing.Pool(24)
frame, score, path, m = marginals.pick([b[0], b[-1]], g, pool = pool,
                                    pairwisecost = .001,
                                    sigma = .1,
                                    erroroverlap = 0.5)


#visualize.save(visualize.highlight_paths(g, [path, b], width = 3, colors = ["red", "green"]), lambda x: "tmp/path{0}.jpg".format(x))

print "frame {0} with score {1}".format(frame, score)
示例#4
0
from vision import *
from vision.alearn import marginals
from vision import visualize, model
from vision.toymaker import *
import os
import multiprocessing
import logging
import random
import pylab
import pickle

logging.basicConfig(level=logging.INFO)

g = Geppetto((720, 480))

b = Rectangle((400, 100), color="white")
b.linear((400, 800), 20)
g.add(b)

pool = multiprocessing.Pool(24)
frame, score, path, m = marginals.pick([b[0], b[-1]],
                                       g,
                                       pool=pool,
                                       pairwisecost=.001,
                                       sigma=.1,
                                       erroroverlap=0.5)

print "frame {0} with score {1}".format(frame, score)
示例#5
0
文件: track.py 项目: zolanda/pyvision
    def __call__(self, video, gtruths, cpfs, pool=None):
        result = {}
        pathdict = {}
        for id, gtruth in gtruths.items():
            gtruth.sort(key=lambda x: x.frame)
            pathdict[id] = dict((x.frame, x) for x in gtruth)

        requests = {}
        for id, gtruth in gtruths.items():
            frame, score, predicted, _ = marginals.pick(
                [gtruth[0]],
                video,
                last=gtruth[-1].frame,
                pool=pool,
                pairwisecost=self.pairwisecost,
                upperthreshold=self.upperthreshold,
                sigma=self.sigma,
                erroroverlap=self.erroroverlap,
                skip=self.skip,
                rgbbin=self.rgbbin,
                hogbin=self.hogbin)

            requests[id] = (score, frame, predicted, [gtruth[0]])
            result[id] = {}
        usedclicks = len(gtruths)

        logger.info("Used {0} clicks!".format(usedclicks))

        numframes = sum(x[-1].frame - x[0].frame for x in gtruths.values())
        reqclicks = [(int(numframes * x), x) for x in cpfs]
        reqclicks.sort()

        for clicks, cpf in reqclicks:
            for _ in range(clicks - usedclicks):
                id = max((y[0], x) for x, y in requests.items())[1]

                givens = list(requests[id][3])
                givens.append(pathdict[id][requests[id][1]])
                givens.sort(key=lambda x: x.frame)

                frame, score, predicted, _ = marginals.pick(
                    givens,
                    video,
                    last=max(pathdict[id]),
                    pool=pool,
                    pairwisecost=self.pairwisecost,
                    upperthreshold=self.upperthreshold,
                    sigma=self.sigma,
                    erroroverlap=self.erroroverlap,
                    skip=self.skip,
                    rgbbin=self.rgbbin,
                    hogbin=self.hogbin)

                requests[id] = (score, frame, predicted, givens)
                usedclicks += 1

                logger.info(
                    "Used {0} clicks with {1} total in this cpf!".format(
                        usedclicks, clicks))

            for id, (_, _, path, _) in requests.iteritems():
                result[id][cpf] = path
        return result
示例#6
0
#
#stop = 1768

g = frameiterator("/scratch/vatic/syn-occlusion2")
b = [Box(592, 48, 592 + 103, 48 + 326, 20)]
stop = 22

g = frameiterator("/scratch/virat/frames/VIRAT_S_000302_04_000453_000484")
b = [Box(156, 96, 156 + 50, 96 + 24, 270),
     Box(391, 83, 391 + 48, 83 + 22, 459)]
stop = 500

pool = multiprocessing.Pool(24)

frame, score, path, marginals = marginals.pick(b, g,
                                               last = stop,
                                               pool = pool,
                                               pairwisecost = .01,
                                               dim = (40, 40),
                                               sigma = 1,
                                               erroroverlap = 0.5,
                                               hogbin = 8,
                                               clickradius = 10,
                                               c = 1)

pickle.dump(marginals, open("occlusion.pkl", "w"))

visualize.save(visualize.highlight_paths(g, [path]), lambda x: "tmp/path{0}.jpg".format(x))

print "frame {0} with score {1}".format(frame, score)