Esempio n. 1
0
    def dumpmatlab(self, file, data, video, scale):
        results = []
        for id, track in enumerate(data):
            for box in track.boxes:
                if not box.lost:
                    data = {}
                    data['id'] = id
                    data['xtl'] = box.xtl
                    data['ytl'] = box.ytl
                    data['xbr'] = box.xbr
                    data['ybr'] = box.ybr
                    data['frame'] = box.frame
                    data['lost'] = box.lost
                    data['occluded'] = box.occluded
                    data['label'] = track.label
                    data['attributes'] = box.attributes
                    data['generated'] = box.generated
                    results.append(data)

        from scipy.io import savemat as savematlab
        savematlab(file,
            {"annotations": results,
             "num_frames": video.totalframes,
             "slug": video.slug,
             "skip": video.skip,
             "width": int(video.width * scale),
             "height": int(video.height * scale),
             "scale": scale}, oned_as="row")
Esempio n. 2
0
    def dumpmatlab(self, file, data, video, scale):
        results = []
        for id, track in enumerate(data):
            for box in track.boxes:
                if not box.lost:
                    data = {}
                    data['id'] = id
                    data['xtl'] = box.xtl
                    data['ytl'] = box.ytl
                    data['xbr'] = box.xbr
                    data['ybr'] = box.ybr
                    data['frame'] = box.frame
                    data['lost'] = box.lost
                    data['occluded'] = box.occluded
                    data['label'] = track.label
                    data['attributes'] = box.attributes
                    data['generated'] = box.generated
                    results.append(data)

        from scipy.io import savemat as savematlab
        savematlab(file, {
            "annotations": results,
            "num_frames": video.totalframes,
            "slug": video.slug,
            "skip": video.skip,
            "width": int(video.width * scale),
            "height": int(video.height * scale),
            "scale": scale
        },
                   oned_as="row")
Esempio n. 3
0
def dumpmatlab(file, data, video, scale, fields):
    results = []
    for id, track in enumerate(data):
        for box in track.boxes:
            if not box.lost:
                data = {}
                for f in fields:
                    d = trackletdataforfield(track, id, f)
                    if d is None:
                        d = boxdataforfield(box, track.velocities[box.frame],
                                            f)
                    if data:
                        data[f] = d

                results.append(data)

    from scipy.io import savemat as savematlab
    savematlab(file, {
        "annotations": results,
        "num_frames": video.totalframes,
        "slug": video.slug,
        "skip": video.skip,
        "width": int(video.width * scale),
        "height": int(video.height * scale),
        "scale": scale
    },
               oned_as="row")
Esempio n. 4
0
    def dumpmatlab(self, file, data):
        results = []
        for id, track in enumerate(data):
            for box in track.boxes:
                data = {}
                data['id'] = id
                data['xtl'] = box.xtl
                data['ytl'] = box.ytl
                data['xbr'] = box.xbr
                data['ybr'] = box.ybr
                data['frame'] = box.frame
                data['lost'] = box.lost
                data['occluded'] = box.occluded
                data['label'] = track.label
                data['attributes'] = box.attributes
                results.append(data)

        from scipy.io import savemat as savematlab
        savematlab(file, {"annotations": results}, oned_as="row")
Esempio n. 5
0
    def dumpmatlab(self, file, data):
        results = []
        for id, track in enumerate(data):
            for box in track.boxes:
                data = {}
                data['id'] = id
                data['xtl'] = box.xtl
                data['ytl'] = box.ytl
                data['xbr'] = box.xbr
                data['ybr'] = box.ybr
                data['frame'] = box.frame
                data['lost'] = box.lost
                data['occluded'] = box.occluded
                data['label'] = track.label
                data['attributes'] = box.attributes
                results.append(data)

        from scipy.io import savemat as savematlab
        savematlab(file,
            {"annotations": results}, oned_as="row")
Esempio n. 6
0
def dumpmatlab(file, data, video, scale, fields):
    results = []
    for id, track in enumerate(data):
        for box in track.boxes:
            if not box.lost:
                data = {}
                for f in fields:
                    d = trackletdataforfield(track, id, f)
                    if d is None:
                        d = boxdataforfield(box, track.velocities[box.frame], f)
                    if data:
                        data[f] = d

                results.append(data)

    from scipy.io import savemat as savematlab
    savematlab(file,
        {"annotations": results,
         "num_frames": video.totalframes,
         "slug": video.slug,
         "skip": video.skip,
         "width": int(video.width * scale),
         "height": int(video.height * scale),
         "scale": scale}, oned_as="row")
Esempio n. 7
0
                               model.dim,
                               model.hogweights(),
                               model.rgbweights(),
                               hogbin=model.hogbin)

x, y = numpy.unravel_index(numpy.argmin(costs), costs.shape)
x = int((x) / wr)
y = int((y) / hr)
result = Box(x, y, x + b.width, y + b.height, stop)

f = features.rgbmean(frames[b.frame].crop(b[0:4]))
print f, numpy.dot(f.transpose(), model.rgbweights())
f = features.rgbmean(frames[result.frame].crop(result[0:4]))
print f, numpy.dot(f.transpose(), model.rgbweights())

savematlab(open("weight.mat", "w"), {"w": model.hogweights()}, oned_as="row")

#numpy.set_printoptions(threshold='nan')
print model.hogweights().shape
print model.rgbweights()

print "Given", b
print "Predicted", result

pylab.figure(1)
pylab.subplot(221)
pylab.title("training")
pylab.imshow(numpy.asarray(highlight_box(frames[b.frame], b)))

pylab.subplot(222)
pylab.title("best")
Esempio n. 8
0
from vision import features
from PIL import Image
from scipy.io import savemat as savematlab

im = Image.open("/scratch/vatic/syn-bounce-level/0/0/0.jpg")
f = features.hog(im)
savematlab(open("features.mat", "w"), {"py": f})
Esempio n. 9
0
image = image.resize((int(wr * image.size[0]), int(hr * image.size[1])), 2)
costs = convolution.hogrgbmean(image, model.dim,
                            model.hogweights(), model.rgbweights(),
                            hogbin = model.hogbin)

x, y = numpy.unravel_index(numpy.argmin(costs), costs.shape)
x = int((x) / wr)
y = int((y) / hr)
result = Box(x, y, x + b.width, y + b.height, stop)

f = features.rgbmean(frames[b.frame].crop(b[0:4]))
print f, numpy.dot(f.transpose(), model.rgbweights())
f = features.rgbmean(frames[result.frame].crop(result[0:4]))
print f, numpy.dot(f.transpose(), model.rgbweights())

savematlab(open("weight.mat", "w"), {"w": model.hogweights()}, oned_as="row")

#numpy.set_printoptions(threshold='nan')
print model.hogweights().shape
print model.rgbweights()

print "Given", b
print "Predicted", result

pylab.figure(1)
pylab.subplot(221)
pylab.title("training")
pylab.imshow(numpy.asarray(highlight_box(frames[b.frame], b)))

pylab.subplot(222)
pylab.title("best")
Esempio n. 10
0
from vision import features
import Image
from scipy.io import savemat as savematlab

im = Image.open("/scratch/vatic/syn-bounce-level/0/0/0.jpg")
f = features.hog(im)
savematlab(open("features.mat", "w"), {"py": f})