mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-11-05 11:56:37 +00:00
request rgb3 pixel format on linux where returned format is unsupported
This commit is contained in:
parent
31ce3ce68a
commit
8885e48ed9
2 changed files with 15 additions and 3 deletions
|
|
@ -6,8 +6,7 @@ public enum WebcamPixelFormat {
|
||||||
//Only V4L2 formats defined in linux/videodev2.h are required here, declared in order of priority for supported formats
|
//Only V4L2 formats defined in linux/videodev2.h are required here, declared in order of priority for supported formats
|
||||||
PIX_FMT_RGB24("RGB3", true),
|
PIX_FMT_RGB24("RGB3", true),
|
||||||
PIX_FMT_YUYV("YUYV", true),
|
PIX_FMT_YUYV("YUYV", true),
|
||||||
PIX_FMT_MJPG("MJPG", true),
|
PIX_FMT_MJPG("MJPG", true);
|
||||||
PIX_FMT_NV12("NV12", false);
|
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final boolean supported;
|
private final boolean supported;
|
||||||
|
|
@ -25,6 +24,14 @@ public enum WebcamPixelFormat {
|
||||||
return supported;
|
return supported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFourCC() {
|
||||||
|
char a = name.charAt(0);
|
||||||
|
char b = name.charAt(1);
|
||||||
|
char c = name.charAt(2);
|
||||||
|
char d = name.charAt(3);
|
||||||
|
return ((int) a) | ((int) b << 8) | ((int) c << 16) | ((int) d << 24);
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,11 @@ public class WebcamService extends ScheduledService<Image> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//On Linux, formats not defined in WebcamPixelFormat are unsupported so ask for RGB3
|
||||||
|
if(OsType.getCurrent() == OsType.UNIX && WebcamPixelFormat.fromFourCC(format.getFormatInfo().fourcc) == null) {
|
||||||
|
format.getFormatInfo().fourcc = WebcamPixelFormat.PIX_FMT_RGB24.getFourCC();
|
||||||
|
}
|
||||||
|
|
||||||
if(log.isDebugEnabled()) {
|
if(log.isDebugEnabled()) {
|
||||||
log.debug("Opening capture stream on " + device + " with format " + format.getFormatInfo().width + "x" + format.getFormatInfo().height + " (" + WebcamPixelFormat.fourCCToString(format.getFormatInfo().fourcc) + ")");
|
log.debug("Opening capture stream on " + device + " with format " + format.getFormatInfo().width + "x" + format.getFormatInfo().height + " (" + WebcamPixelFormat.fourCCToString(format.getFormatInfo().fourcc) + ")");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue