Pregunta

I have a program which can print screenshot in every 1 second, But during the screen capture, when the screen contains dark pictures then, the stored image contains huge amount of noise.
Can anyone please tell me that how to reduce noise contents from these snapshot images.

Following code I am using for screen capture.

public class Beginning implements Runnable {

    private Thread thread;
    private static long counter = 0;
    private final int FRAME_CAPTURE_RATE = 1000;
    private Robot robot;

    public Beginning() throws Exception {
        robot = new Robot();
        thread = new Thread(this);
        thread.start();
    }

    public static void main(String[] args) throws Exception {
        Beginning beginning = new Beginning();
    }

    public void run() {
        for (;;) {
            try {
                Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
                BufferedImage bufferedImage = robot.createScreenCapture(screenRect);
                ImageIO.write(bufferedImage, "png", new File("D:\\CapturedFrame\\toolImage" + counter + ".png"));
                counter++;
                thread.sleep(FRAME_CAPTURE_RATE);
            } catch (Exception e) {
                System.err.println("Something fishy is going on...");
            }
        }
    }
}

Also tell me that how can I do this without playing the video in the screen, means I have to just give location of video and then my program will capture frames from it and the remove noise from it and then save it in specified location.

¿Fue útil?

Solución

If you don't need to do this programatically VLC player has an option to create images of frames see: http://www.isimonbrown.co.uk/vlc-export-frames

If you need to run from a program and don't want to have the videos play - I'd recommend using command line tool such as ffmpeg and calling it from java via Runtime exec i.e.

Runtime.getRuntime().exec("INSERT FFMPEG COMMAND HERE");

Some sample commands for ffmpeg can be found here:

http://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video

e.g. 1 frame per second:

ffmpeg -i input.flv -f image2 -vf fps=fps=1 out%d.png

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top