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);
}
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));
}
}
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));
}
}
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);
}
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));
}
}
Aggregations