metaloom/video4j: java视频处理库

23-03-03 banq

Video4j是org.openpnp:opencv上面的一个高级库,它提供了在Java中处理视频媒体的API。

可以在 java 中进行视频处理。这些库在使用 JNI 的引擎盖下使用 openpnp opencv。

特点:帧流、通过 jdlib 进行视频人脸检测和特征提取、缩略图生成、视频指纹识别。

<dependency>
  <groupId>io.metaloom.video</groupId>
  <artifactId>video4j</artifactId>
  <version>1.2.0</version>
</dependency>


代码:

// Load native lib libopencv_java451
Video4j.init();

// Open the video
try (Video video = Videos.open(BIG_BUCK_BUNNY2_PATH)) {
    // Video dimensions
    video.width();
    video.height();

    // Configured FPS
    video.fps();

    // Total frames of the video
    video.length();

    // Seek to specific frame
    video.seekToFrame(1020);

    // Or just to the 50% point of the video
    video.seekToFrameRatio(0.5d);

    // Return the number of the current frame
    video.currentFrame();

    // Read the next frame as matrice (lower level access)
    Mat mat = video.frameToMat();

    // Read the next frame as image (mat gets automatically converted to image)
    BufferedImage image = video.frameToImage();

    // Read the frame and resize it to a width of 256 pixel.
    BufferedImage image2 = video.boxedFrameToImage(256);

    // Display the frame in a window
    ImageUtils.show(image);
}   


详细点击标题

1