JavaCV - 无法操纵相机分辨率

时间:2016-03-04 13:18:53

标签: java opencv javacv

我将下面的代码用于保存图片。但无论我为ImageWidth和ImageHeight设置什么,这对分辨率都没有影响。分辨率始终为640x480。我正在使用支持720p的Microsoft Life Cam Cinema。

    FrameGrabber grabber = new VideoInputFrameGrabber(1);
    try{
        grabber.start();
    } catch (FrameGrabber.Exception e) {
        System.out.println("Exception grabber start");
    }
    grabber.setImageHeight(720);
    grabber.setImageWidth(1280);
    grabber.setGamma(25);
    double gamma = grabber.getGamma();
    int camHeight= grabber.getImageHeight();
    int camWidth= grabber.getImageWidth();
    IplImage img = null;
    Frame frame = null;
    try{
        frame = grabber.grabFrame();

    } catch (FrameGrabber.Exception e){
        System.out.println("Exception grabbing frame");
    }
    OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage();      
    img = converter.convert(frame);
    cvSaveImage("img.jpg", img);

1 个答案:

答案 0 :(得分:0)

grabber.setImageHeight(720);grabber.setImageWidth(1280);必须在grabber.start();

之前