org.openimaj.video.Video.getNextFrame()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中org.openimaj.video.Video.getNextFrame()方法的一些代码示例,展示了Video.getNextFrame()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Video.getNextFrame()方法的具体详情如下:
包路径:org.openimaj.video.Video
类名称:Video
方法名:getNextFrame

Video.getNextFrame介绍

[英]Get the next frame. Increments the frame counter by 1.
[中]获取下一帧。将帧计数器增加1。

代码示例

代码示例来源:origin: org.openimaj/core-video

  1. @Override
  2. public T next() {
  3. return video.getNextFrame();
  4. }

代码示例来源:origin: openimaj/openimaj

  1. @Override
  2. public T next() {
  3. return video.getNextFrame();
  4. }

代码示例来源:origin: openimaj/openimaj

  1. @Override
  2. public OUTPUT getNextFrame()
  3. {
  4. return currentFrame = translateFrame(video.getNextFrame());
  5. }

代码示例来源:origin: org.openimaj/core-video

  1. @Override
  2. public OUTPUT getNextFrame()
  3. {
  4. return currentFrame = translateFrame(video.getNextFrame());
  5. }

代码示例来源:origin: openimaj/openimaj

  1. /**
  2. * {@inheritDoc}
  3. *
  4. * @see org.openimaj.video.Video#getNextFrame()
  5. */
  6. @Override
  7. public T getNextFrame()
  8. {
  9. if (this.video == null)
  10. throw new UnsupportedOperationException(
  11. "Chain method called on non-chainable processor");
  12. currentFrame = this.video.getNextFrame();
  13. if (currentFrame == null)
  14. return null;
  15. return processFrame(currentFrame);
  16. }

代码示例来源:origin: org.openimaj/core-video

  1. /**
  2. * {@inheritDoc}
  3. *
  4. * @see org.openimaj.video.Video#getNextFrame()
  5. */
  6. @Override
  7. public T getNextFrame()
  8. {
  9. if (this.video == null)
  10. throw new UnsupportedOperationException(
  11. "Chain method called on non-chainable processor");
  12. currentFrame = this.video.getNextFrame();
  13. if (currentFrame == null)
  14. return null;
  15. return processFrame(currentFrame);
  16. }

代码示例来源:origin: openimaj/openimaj

  1. /**
  2. * Set the current frame index (i.e. skips to a certain frame). If your
  3. * video subclass can implement this in a cleverer way, then override this
  4. * method, otherwise this method will simply grab frames until it gets to
  5. * the given frame index. This method is naive and may take some time as
  6. * each frame will be decoded by the video decoder.
  7. *
  8. * @param newFrame
  9. * the new index
  10. */
  11. public synchronized void setCurrentFrameIndex(long newFrame)
  12. {
  13. // We're already at the frame?
  14. if (this.currentFrame == newFrame)
  15. return;
  16. // If we're ahread of where we want to be
  17. if (this.currentFrame > newFrame)
  18. {
  19. this.reset();
  20. }
  21. // Grab frames until we read the new frame counter
  22. // (or until the getNextFrame() method returns null)
  23. while (this.currentFrame < newFrame && getNextFrame() != null)
  24. ;
  25. }

代码示例来源:origin: org.openimaj/core-video

  1. /**
  2. * Set the current frame index (i.e. skips to a certain frame). If your
  3. * video subclass can implement this in a cleverer way, then override this
  4. * method, otherwise this method will simply grab frames until it gets to
  5. * the given frame index. This method is naive and may take some time as
  6. * each frame will be decoded by the video decoder.
  7. *
  8. * @param newFrame
  9. * the new index
  10. */
  11. public synchronized void setCurrentFrameIndex(long newFrame)
  12. {
  13. // We're already at the frame?
  14. if (this.currentFrame == newFrame)
  15. return;
  16. // If we're ahread of where we want to be
  17. if (this.currentFrame > newFrame)
  18. {
  19. this.reset();
  20. }
  21. // Grab frames until we read the new frame counter
  22. // (or until the getNextFrame() method returns null)
  23. while (this.currentFrame < newFrame && getNextFrame() != null)
  24. ;
  25. }

代码示例来源:origin: org.openimaj/core-video

  1. /**
  2. * Process the given video using this processor.
  3. *
  4. * @param video
  5. * The video to process.
  6. */
  7. public void process(Video<T> video)
  8. {
  9. T frame = null;
  10. while ((frame = video.getNextFrame()) != null)
  11. processFrame(frame);
  12. processingComplete();
  13. }

代码示例来源:origin: openimaj/openimaj

  1. @Override
  2. public ImageCollectionEntry<T> next() {
  3. final T image = video.getNextFrame();
  4. final ImageCollectionEntry<T> entry = new ImageCollectionEntry<T>();
  5. entry.meta = new HashMap<String, String>();
  6. entry.meta.put("timestamp", "" + this.frameCount / this.video.getFPS());
  7. entry.accepted = selection.acceptEntry(image);
  8. entry.image = image;
  9. this.frameCount++;
  10. // hack to stop the iterator at the end until hasNext works properly
  11. if (image == null)
  12. frameCount = -1;
  13. return entry;
  14. }

代码示例来源:origin: openimaj/openimaj

  1. /**
  2. * Process the given video using this processor.
  3. *
  4. * @param video
  5. * The video to process.
  6. */
  7. public void process(Video<T> video)
  8. {
  9. T frame = null;
  10. while ((frame = video.getNextFrame()) != null)
  11. processFrame(frame);
  12. processingComplete();
  13. }

代码示例来源:origin: org.openimaj/core-video

  1. nextFrame = this.video.getNextFrame();
  2. nextFrameTimestamp = this.video.getTimeStamp();
  3. nextFrame = this.video.getNextFrame();
  4. nextFrameTimestamp = this.video.getTimeStamp();
  5. if (this.currentFrame == null && (this.timeKeeper instanceof VideoDisplay.BasicVideoTimeKeeper))

代码示例来源:origin: org.openimaj/core-video

  1. /**
  2. * Cache the whole of the given video.
  3. * @param <I> Type of {@link Image}
  4. *
  5. * @param video The video to cache
  6. * @return A {@link VideoCache}
  7. */
  8. public static <I extends Image<?,I>> VideoCache<I> cacheVideo( Video<I> video )
  9. {
  10. VideoCache<I> vc = new VideoCache<I>( video.getWidth(),
  11. video.getHeight(), video.getFPS() );
  12. video.reset();
  13. while( video.hasNextFrame() )
  14. vc.addFrame( video.getNextFrame().clone() );
  15. return vc;
  16. }

代码示例来源:origin: openimaj/openimaj

  1. /**
  2. * Cache the whole of the given video.
  3. * @param <I> Type of {@link Image}
  4. *
  5. * @param video The video to cache
  6. * @return A {@link VideoCache}
  7. */
  8. public static <I extends Image<?,I>> VideoCache<I> cacheVideo( Video<I> video )
  9. {
  10. VideoCache<I> vc = new VideoCache<I>( video.getWidth(),
  11. video.getHeight(), video.getFPS() );
  12. video.reset();
  13. while( video.hasNextFrame() )
  14. vc.addFrame( video.getNextFrame().clone() );
  15. return vc;
  16. }

代码示例来源:origin: openimaj/openimaj

  1. /**
  2. * Cache the given time range from the given video.
  3. *
  4. * @param <I> The type of the video frames
  5. * @param video The video to cache
  6. * @param start The start of the video to cache
  7. * @param end The end of the video to cache
  8. * @return A {@link VideoCache}
  9. */
  10. public static <I extends Image<?,I>> VideoCache<I> cacheVideo( Video<I> video,
  11. VideoTimecode start, VideoTimecode end )
  12. {
  13. VideoCache<I> vc = new VideoCache<I>( video.getWidth(),
  14. video.getHeight(), video.getFPS() );
  15. video.setCurrentFrameIndex( start.getFrameNumber() );
  16. while( video.hasNextFrame() &&
  17. video.getCurrentFrameIndex() < end.getFrameNumber() )
  18. vc.addFrame( video.getNextFrame().clone() );
  19. return vc;
  20. }
  21. }

代码示例来源:origin: org.openimaj/core-video

  1. /**
  2. * Cache the given time range from the given video.
  3. *
  4. * @param <I> The type of the video frames
  5. * @param video The video to cache
  6. * @param start The start of the video to cache
  7. * @param end The end of the video to cache
  8. * @return A {@link VideoCache}
  9. */
  10. public static <I extends Image<?,I>> VideoCache<I> cacheVideo( Video<I> video,
  11. VideoTimecode start, VideoTimecode end )
  12. {
  13. VideoCache<I> vc = new VideoCache<I>( video.getWidth(),
  14. video.getHeight(), video.getFPS() );
  15. video.setCurrentFrameIndex( start.getFrameNumber() );
  16. while( video.hasNextFrame() &&
  17. video.getCurrentFrameIndex() < end.getFrameNumber() )
  18. vc.addFrame( video.getNextFrame().clone() );
  19. return vc;
  20. }
  21. }

代码示例来源:origin: org.openimaj/sandbox

  1. FeatureTable trackFeatures(Video<FImage> video, int nFeatures, boolean replace) {
  2. final TrackingContext tc = new TrackingContext();
  3. final FeatureList fl = new FeatureList(nFeatures);
  4. final FeatureTable ft = new FeatureTable(nFeatures);
  5. final KLTTracker tracker = new KLTTracker(tc, fl);
  6. tc.setSequentialMode(true);
  7. tc.setWriteInternalImages(false);
  8. tc.setAffineConsistencyCheck(-1);
  9. FImage prev = video.getCurrentFrame();
  10. tracker.selectGoodFeatures(prev);
  11. ft.storeFeatureList(fl, 0);
  12. while (video.hasNextFrame()) {
  13. final FImage next = video.getNextFrame();
  14. tracker.trackFeatures(prev, next);
  15. if (replace)
  16. tracker.replaceLostFeatures(next);
  17. prev = next;
  18. ft.storeFeatureList(fl, video.getCurrentFrameIndex());
  19. }
  20. return ft;
  21. }

代码示例来源:origin: openimaj/openimaj

  1. FeatureTable trackFeatures(Video<FImage> video, int nFeatures, boolean replace) {
  2. final TrackingContext tc = new TrackingContext();
  3. final FeatureList fl = new FeatureList(nFeatures);
  4. final FeatureTable ft = new FeatureTable(nFeatures);
  5. final KLTTracker tracker = new KLTTracker(tc, fl);
  6. tc.setSequentialMode(true);
  7. tc.setWriteInternalImages(false);
  8. tc.setAffineConsistencyCheck(-1);
  9. FImage prev = video.getCurrentFrame();
  10. tracker.selectGoodFeatures(prev);
  11. ft.storeFeatureList(fl, 0);
  12. while (video.hasNextFrame()) {
  13. final FImage next = video.getNextFrame();
  14. tracker.trackFeatures(prev, next);
  15. if (replace)
  16. tracker.replaceLostFeatures(next);
  17. prev = next;
  18. ft.storeFeatureList(fl, video.getCurrentFrameIndex());
  19. }
  20. return ft;
  21. }

代码示例来源:origin: openimaj/openimaj

  1. image = video.getNextFrame();

代码示例来源:origin: org.openimaj/video-processing

  1. image = video.getNextFrame();

相关文章