Search in sources :

Example 1 with VideoFrame

use of org.vitrivr.cineast.core.data.frames.VideoFrame in project cineast by vitrivr.

the class ImageQueryTermContainer method getMostRepresentativeFrame.

@Override
public VideoFrame getMostRepresentativeFrame() {
    if (this.videoFrame == null) {
        int id = (getStart() + getEnd()) / 2;
        this.videoFrame = new VideoFrame(id, 0, this.img, new VideoDescriptor(25, 40, this.img.getWidth(), this.img.getHeight()));
    }
    return this.videoFrame;
}
Also used : VideoFrame(org.vitrivr.cineast.core.data.frames.VideoFrame) VideoDescriptor(org.vitrivr.cineast.core.data.frames.VideoDescriptor)

Example 2 with VideoFrame

use of org.vitrivr.cineast.core.data.frames.VideoFrame in project cineast by vitrivr.

the class SkeletonPose method processSegment.

@Override
public void processSegment(SegmentContainer segmentContainer) {
    if (phandler.idExists(segmentContainer.getId())) {
        return;
    }
    VideoFrame representativeFrame = segmentContainer.getMostRepresentativeFrame();
    if (representativeFrame == VideoFrame.EMPTY_VIDEO_FRAME) {
        return;
    }
    this.persist(detectSkeletons(representativeFrame.getImage()).stream().map(it -> new Pair<>(segmentContainer.getId(), it)).collect(Collectors.toList()));
}
Also used : VideoFrame(org.vitrivr.cineast.core.data.frames.VideoFrame)

Example 3 with VideoFrame

use of org.vitrivr.cineast.core.data.frames.VideoFrame in project cineast by vitrivr.

the class STMP7EH method processSegment.

@Override
public void processSegment(SegmentContainer shot) {
    if (shot.getMostRepresentativeFrame() == VideoFrame.EMPTY_VIDEO_FRAME) {
        return;
    }
    if (!phandler.idExists(shot.getId())) {
        List<VideoFrame> videoFrames = shot.getVideoFrames();
        float[] hist = new float[80];
        SummaryStatistics[] stats = new SummaryStatistics[80];
        for (int i = 0; i < 80; ++i) {
            stats[i] = new SummaryStatistics();
        }
        for (VideoFrame f : videoFrames) {
            MultiImage img = f.getImage();
            hist = process(img, hist);
            for (int i = 0; i < 80; ++i) {
                stats[i].addValue(hist[i]);
                hist[i] = 0f;
            }
        }
        float[] vec = new float[160];
        for (int i = 0; i < 80; ++i) {
            vec[i] = (float) stats[i].getMean();
            vec[i + 80] = (float) Math.sqrt(stats[i].getVariance());
        }
        persist(shot.getId(), new FloatVectorImpl(vec));
    }
}
Also used : VideoFrame(org.vitrivr.cineast.core.data.frames.VideoFrame) MultiImage(org.vitrivr.cineast.core.data.raw.images.MultiImage) SummaryStatistics(org.apache.commons.math3.stat.descriptive.SummaryStatistics) FloatVectorImpl(org.vitrivr.cineast.core.data.FloatVectorImpl)

Example 4 with VideoFrame

use of org.vitrivr.cineast.core.data.frames.VideoFrame in project cineast by vitrivr.

the class SaturationGrid8 method processSegment.

@Override
public void processSegment(SegmentContainer shot) {
    if (shot.getMostRepresentativeFrame() == VideoFrame.EMPTY_VIDEO_FRAME) {
        return;
    }
    if (!phandler.idExists(shot.getId())) {
        ArrayList<SummaryStatistics> stats = new ArrayList<SummaryStatistics>(64);
        for (int i = 0; i < 64; ++i) {
            stats.add(new SummaryStatistics());
        }
        List<VideoFrame> videoFrames = shot.getVideoFrames();
        ArrayList<Float> saturations = null;
        int width = 0, height = 0;
        for (VideoFrame f : videoFrames) {
            if (saturations == null) {
                width = f.getImage().getWidth();
                height = f.getImage().getHeight();
                saturations = new ArrayList<Float>(width * height);
            } else {
                saturations.clear();
            }
            int[] colors = f.getImage().getColors();
            for (int c : colors) {
                saturations.add(ColorConverter.cachedRGBtoLab(c).getSaturation());
            }
            ArrayList<LinkedList<Float>> partitions = GridPartitioner.partition(saturations, width, height, 8, 8);
            for (int i = 0; i < partitions.size(); ++i) {
                SummaryStatistics stat = stats.get(i);
                for (float c : partitions.get(i)) {
                    stat.addValue(c);
                }
            }
        }
        float[] result = new float[128];
        for (int i = 0; i < 64; ++i) {
            result[2 * i] = (float) stats.get(i).getMean();
            result[2 * i + 1] = (float) stats.get(i).getVariance();
        }
        persist(shot.getId(), new FloatVectorImpl(result));
    }
}
Also used : ArrayList(java.util.ArrayList) SummaryStatistics(org.apache.commons.math3.stat.descriptive.SummaryStatistics) FloatVectorImpl(org.vitrivr.cineast.core.data.FloatVectorImpl) LinkedList(java.util.LinkedList) VideoFrame(org.vitrivr.cineast.core.data.frames.VideoFrame)

Example 5 with VideoFrame

use of org.vitrivr.cineast.core.data.frames.VideoFrame in project cineast by vitrivr.

the class RepresentativeFrameExporter method processSegment.

@Override
public void processSegment(SegmentContainer segment) {
    File outFolder = new File(this.folder, segment.getSuperId());
    outFolder.mkdirs();
    File outFile = new File(outFolder, segment.getId() + ".png");
    VideoFrame f = segment.getMostRepresentativeFrame();
    try {
        ImageIO.write(f.getImage().getBufferedImage(), "PNG", outFile);
    } catch (IOException e) {
        LOGGER.error("Could not write representative frame: {}", e.getMessage());
    }
    persist(segment.getId(), f.getId());
}
Also used : VideoFrame(org.vitrivr.cineast.core.data.frames.VideoFrame) IOException(java.io.IOException) File(java.io.File)

Aggregations

VideoFrame (org.vitrivr.cineast.core.data.frames.VideoFrame)23 MultiImage (org.vitrivr.cineast.core.data.raw.images.MultiImage)9 FloatVectorImpl (org.vitrivr.cineast.core.data.FloatVectorImpl)8 LinkedList (java.util.LinkedList)7 ArrayList (java.util.ArrayList)6 SummaryStatistics (org.apache.commons.math3.stat.descriptive.SummaryStatistics)6 File (java.io.File)3 IOException (java.io.IOException)3 VideoSegment (org.vitrivr.cineast.core.data.segments.VideoSegment)3 BufferedImage (java.awt.image.BufferedImage)2 Pair (org.vitrivr.cineast.core.data.Pair)2 DecodingError (org.vitrivr.cineast.core.util.DecodingError)2 PkltConfig (boofcv.alg.tracker.klt.PkltConfig)1 PyramidKltFeature (boofcv.alg.tracker.klt.PyramidKltFeature)1 AssociatedPair (boofcv.struct.geo.AssociatedPair)1 GrayS16 (boofcv.struct.image.GrayS16)1 GrayU8 (boofcv.struct.image.GrayU8)1 Point2D_F32 (georegression.struct.point.Point2D_F32)1 BytePointer (org.bytedeco.javacpp.BytePointer)1 HSVContainer (org.vitrivr.cineast.core.color.HSVContainer)1