bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.55k stars 1.58k forks source link

Images obtained from FFmpegFrameGrabber are too bright. #1952

Closed Gamebuster19901 closed 1 year ago

Gamebuster19901 commented 1 year ago

I'm using this code to display a portion of my desktop into a window. In the image below, you can see the actual color of my desktop compared to what is displayed.

How can I correct this?

public static void main(String args[]) throws Exception {
        int x = 0, y = 0, w = 1024, h = 768;
        FFmpegLogCallback.set();
        FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(":1.0+" + x + "," + y);
        grabber.setFormat("x11grab");
        grabber.setImageWidth(w);
        grabber.setImageHeight(h);
        grabber.start();

        CanvasFrame frame = new CanvasFrame("Screen Capture");
        while (frame.isVisible()) {
            frame.showImage(grabber.grab());
        }
        frame.dispose();
        grabber.stop();
}

image

saudet commented 1 year ago

That's CanvasFrame doing gamma correction. If you don't need it, make sure to set the gamma parameter to 1.0.

Gamebuster19901 commented 1 year ago

Thank you very much, didn't realize there was a second constructor which took a gamma parameter.