本文整理了Java中com.github.sarxos.webcam.Webcam.setCustomViewSizes()
方法的一些代码示例,展示了Webcam.setCustomViewSizes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Webcam.setCustomViewSizes()
方法的具体详情如下:
包路径:com.github.sarxos.webcam.Webcam
类名称:Webcam
方法名:setCustomViewSizes
[英]Set custom resolution. If you are using this method you have to make sure that your webcam device can support this specific resolution.
[中]设置自定义分辨率。如果你使用这种方法,你必须确保你的网络摄像头设备能够支持这种特定的分辨率。
代码示例来源:origin: stackoverflow.com
Dimension[] nonStandardResolutions = new Dimension[] {
WebcamResolution.PAL.getSize(),
WebcamResolution.HD720.getSize(),
new Dimension(2000, 1000),
new Dimension(1000, 500),
};
// your camera have to support HD720p to run this code
Webcam webcam = Webcam.getDefault();
webcam.setCustomViewSizes(nonStandardResolutions);
webcam.setViewSize(WebcamResolution.HD720.getSize());
代码示例来源:origin: org.boofcv/boofcv-WebcamCapture
public static void adjustResolution( Webcam webcam , int desiredWidth , int desiredHeight ) {
// Bug in the library where it doesn't list all the camera's possible resolutions
// Dimension[] sizes = webcam.getViewSizes();
// int bestError = Integer.MAX_VALUE;
// Dimension best = sizes[0]; // to get rid of null warning
// for( Dimension d : sizes ) {
// int error = (d.width-desiredWidth)*(d.height-desiredHeight);
// if( error < bestError ) {
// bestError = error;
// best = d;
// }
// }
Dimension[] sizes = webcam.getCustomViewSizes();
Dimension match = null;
for( Dimension d : sizes ) {
if( d.width == desiredWidth && d.height == desiredHeight ) {
match = d;
break;
}
}
if( match == null ) {
match = new Dimension(desiredWidth,desiredHeight);
webcam.setCustomViewSizes(new Dimension[]{match});
}
webcam.setViewSize(match);
}
}
代码示例来源:origin: io.rhiot/camel-webcam
private Webcam openWebcam(Webcam webcam, Dimension dimension) {
//Once started another endpoint may want to change from low res to high res, for example
if (webcam.isOpen() && isStarted() && !dimension.equals(webcam.getViewSize())) {
webcam.close();
}
if (!webcam.isOpen() && dimension != null) {
webcam.setCustomViewSizes(new Dimension[]{dimension});
webcam.setViewSize(dimension);
webcam.open(true);
} else if (!webcam.isOpen()) {
webcam.open(true);
}
return webcam;
}
内容来源于网络,如有侵权,请联系作者删除!