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