Skip to content

Commit

Permalink
Get unsupported resolution work with predefined sizes, refs #327
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed Apr 16, 2015
1 parent feb8cce commit a2dd852
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public V4l4jDevice(File file) {

/**
* Create video device from file.
*
*
* @param file the video descriptor file
* @return The {@link VideoDevice}
*/
Expand All @@ -111,6 +111,12 @@ private static DeviceInfo getVideoDeviceInfo(VideoDevice device) {

LOG.trace("Get video device info");

LOG.trace("Support BGR conversion {}", device.supportBGRConversion());
LOG.trace("Support JPG conversion {}", device.supportJPEGConversion());
LOG.trace("Support RGB conversion {}", device.supportRGBConversion());
LOG.trace("Support YUV conversion {}", device.supportYUVConversion());
LOG.trace("Support YVU conversion {}", device.supportYVUConversion());

DeviceInfo info = null;
try {
info = device.getDeviceInfo();
Expand Down Expand Up @@ -147,16 +153,14 @@ private static ImageFormat getVideoBestImageFormat(VideoDevice device) {

switch (type) {
case UNSUPPORTED:
LOG.trace("Ignore {}, resolution type not supported", name);
continue;
case DISCRETE:
case STEPWISE:
break;
default:
throw new WebcamException("Unknown resolution type " + type);
}

LOG.trace("Testing {}", name);
LOG.trace("Testing {} ({})", name, type);

for (int i = 0; i < BEST_FORMATS.length; i++) {
if (name.startsWith(BEST_FORMATS[i]) && i < min) {
Expand Down Expand Up @@ -214,9 +218,17 @@ private static List<Dimension> getResolutionsStepwise(ResolutionInfo info) {
return resolutions;
}

private static List<Dimension> getResolutionsUnsupported(ResolutionInfo info) {
List<Dimension> resolutions = new ArrayList<Dimension>();
resolutions.add(WebcamResolution.QQVGA.getSize());
resolutions.add(WebcamResolution.QVGA.getSize());
resolutions.add(WebcamResolution.VGA.getSize());
return resolutions;
}

/**
* Get video resolutions from {@link ImageFormat}.
*
*
* @param format the {@link ImageFormat} to test
* @return List of resolutions supported by given format
*/
Expand All @@ -235,8 +247,9 @@ private static List<Dimension> getVideoResolutions(ImageFormat format) {
case STEPWISE:
return getResolutionsStepwise(info);
case UNSUPPORTED:
return getResolutionsUnsupported(info);
default:
throw new WebcamException("Unsupported resolution type " + type);
throw new WebcamException("Unknown resolution type " + type);
}
}

Expand Down

0 comments on commit a2dd852

Please sign in to comment.