Video Processing Library for Java

前端 未结 4 2100
面向向阳花
面向向阳花 2021-02-03 13:54

I want to extract frames from a video and apply some filters on it such as gabor/hough etc. Which Java library would be perfect for handling all kinds of video encodings? I have

4条回答
  •  走了就别回头了
    2021-02-03 14:37

    You can try Marvin Framework. It uses JavaCV for video encodings and device access, but all image processing algorithms are pure Java.

    It's very easy to load a video and process the frames in real time, as shown in the edge detection example below.

    Source code:

    import static marvin.MarvinPluginCollection.*;
    
    public class SimpleVideoProcessing extends JFrame implements Runnable{
    
        private MarvinVideoInterface    videoAdapter = new MarvinJavaCVAdapter();
        private MarvinImagePanel        videoPanel = new MarvinImagePanel();
        private MarvinImage             videoFrame, videoOut = new MarvinImage(640,480);
    
        public SimpleVideoProcessing() throws MarvinVideoInterfaceException{
            super("Simple Video Processing using Marvin");
            add(videoPanel);
            // Load video file and start the processing thread
            videoAdapter.loadResource("./res/snooker.wmv");
            new Thread(this).start();
            setSize(640,500);
            setVisible(true);
        }
    
        public void run() {
            try {
                while(true){
                    // Request, process and show the video frame.
                    videoOut.clear();
                    videoFrame = videoAdapter.getFrame();
                    prewitt(videoFrame.clone(), videoOut);
                    videoPanel.setImage(videoOut);
                }
            } catch (MarvinVideoInterfaceException e) {
                e.printStackTrace();
            }
        }
    
        public static void main(String[] args) throws MarvinVideoInterfaceException {
            new SimpleVideoProcessing().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
    }
    

提交回复
热议问题