Search in sources :

Example 1 with FloatVectorImpl

use of org.vitrivr.cineast.core.data.FloatVectorImpl in project cineast by vitrivr.

the class MotionHistogramBackground method getSimilar.

@Override
public List<ScoreElement> getSimilar(SegmentContainer sc, ReadableQueryConfig qc) {
    Pair<List<Double>, ArrayList<ArrayList<Float>>> pair = getSubDivHist(1, sc.getBgPaths());
    FloatVectorImpl fv = new FloatVectorImpl(pair.second.get(0));
    return getSimilar(ReadableFloatVector.toArray(fv), qc);
}
Also used : ArrayList(java.util.ArrayList) FloatVectorImpl(org.vitrivr.cineast.core.data.FloatVectorImpl) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with FloatVectorImpl

use of org.vitrivr.cineast.core.data.FloatVectorImpl 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 3 with FloatVectorImpl

use of org.vitrivr.cineast.core.data.FloatVectorImpl 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 4 with FloatVectorImpl

use of org.vitrivr.cineast.core.data.FloatVectorImpl in project cineast by vitrivr.

the class SaturationGrid8 method computeGrid.

private Pair<FloatVector, float[]> computeGrid(SegmentContainer qc) {
    ArrayList<SummaryStatistics> stats = new ArrayList<SummaryStatistics>(64);
    for (int i = 0; i < 64; ++i) {
        stats.add(new SummaryStatistics());
    }
    MultiImage img = qc.getMostRepresentativeFrame().getImage();
    int[] colors = img.getColors();
    ArrayList<Float> saturations = new ArrayList<Float>(img.getWidth() * img.getHeight());
    ArrayList<Float> alphas = new ArrayList<Float>(img.getWidth() * img.getHeight());
    for (int c : colors) {
        saturations.add(ColorConverter.cachedRGBtoLab(c).getSaturation());
        alphas.add(ReadableRGBContainer.getAlpha(c) / 255f);
    }
    ArrayList<LinkedList<Float>> partitions = GridPartitioner.partition(saturations, img.getWidth(), img.getHeight(), 8, 8);
    ArrayList<LinkedList<Float>> alphaPartitions = GridPartitioner.partition(alphas, img.getWidth(), img.getHeight(), 8, 8);
    for (int i = 0; i < partitions.size(); ++i) {
        SummaryStatistics stat = stats.get(i);
        Iterator<Float> iter = alphaPartitions.get(i).iterator();
        for (float c : partitions.get(i)) {
            if (iter.next() < 0.5f) {
                continue;
            }
            stat.addValue(c);
        }
    }
    float[] f = new float[128];
    for (int i = 0; i < 64; ++i) {
        f[2 * i] = (float) stats.get(i).getMean();
        f[2 * i + 1] = (float) stats.get(i).getVariance();
    }
    float[] weights = new float[128];
    for (int i = 0; i < alphaPartitions.size(); ++i) {
        float w = 0;
        for (float v : alphaPartitions.get(i)) {
            w += v;
        }
        w /= alphaPartitions.get(i).size();
        weights[2 * i] = w;
        weights[2 * i + 1] = w;
    }
    return new Pair<FloatVector, float[]>(new FloatVectorImpl(f), weights);
}
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) MultiImage(org.vitrivr.cineast.core.data.raw.images.MultiImage) Pair(org.vitrivr.cineast.core.data.Pair)

Example 5 with FloatVectorImpl

use of org.vitrivr.cineast.core.data.FloatVectorImpl in project cineast by vitrivr.

the class ShapeCentroidDistance method processSegment.

@Override
public void processSegment(SegmentContainer shot) {
    BufferedImage image = shot.getAvgImg().getBufferedImage();
    List<Contour> contours = ContourHelper.getContours(image);
    List<Point2D_I32> contour = contours.get(0).internal.get(0);
    if (image != null) {
        FastFourierTransformer transformer = new FastFourierTransformer(DftNormalization.STANDARD);
        double[] distancefunction = ContourHelper.centroidDistance(contour, true);
        Complex[] signature = transformer.transform(distancefunction, TransformType.FORWARD);
        float[] descriptors = new float[DESCRIPTOR_LENGTH];
        for (int i = 1; i < DESCRIPTOR_LENGTH; i++) {
            descriptors[i] = (float) (signature[i].abs() / signature[0].abs());
        }
        this.persist(shot.getId(), new FloatVectorImpl(descriptors));
    }
}
Also used : Contour(boofcv.alg.filter.binary.Contour) Point2D_I32(georegression.struct.point.Point2D_I32) FloatVectorImpl(org.vitrivr.cineast.core.data.FloatVectorImpl) FastFourierTransformer(org.apache.commons.math3.transform.FastFourierTransformer) BufferedImage(java.awt.image.BufferedImage) Complex(org.apache.commons.math3.complex.Complex)

Aggregations

FloatVectorImpl (org.vitrivr.cineast.core.data.FloatVectorImpl)68 ArrayList (java.util.ArrayList)41 List (java.util.List)28 LinkedList (java.util.LinkedList)18 SummaryStatistics (org.apache.commons.math3.stat.descriptive.SummaryStatistics)14 FloatVector (org.vitrivr.cineast.core.data.FloatVector)13 ReadableFloatVector (org.vitrivr.cineast.core.data.ReadableFloatVector)13 MultiImage (org.vitrivr.cineast.core.data.raw.images.MultiImage)10 Pair (org.vitrivr.cineast.core.data.Pair)8 VideoFrame (org.vitrivr.cineast.core.data.frames.VideoFrame)8 ReadableLabContainer (org.vitrivr.cineast.core.color.ReadableLabContainer)5 BufferedImage (java.awt.image.BufferedImage)4 RGBContainer (org.vitrivr.cineast.core.color.RGBContainer)3 ReadableRGBContainer (org.vitrivr.cineast.core.color.ReadableRGBContainer)3 TUint8 (org.tensorflow.types.TUint8)2 HSVContainer (org.vitrivr.cineast.core.color.HSVContainer)2 LabContainer (org.vitrivr.cineast.core.color.LabContainer)2 ReadableMesh (org.vitrivr.cineast.core.data.m3d.ReadableMesh)2 DeepLabLabel (org.vitrivr.cineast.core.features.neuralnet.tf.models.deeplab.DeepLabLabel)2 Contour (boofcv.alg.filter.binary.Contour)1