mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-11-05 11:56:37 +00:00
sort camera pixel formats on linux only
This commit is contained in:
parent
e31aa7fc80
commit
0975d12155
2 changed files with 12 additions and 8 deletions
|
|
@ -3,12 +3,10 @@ package com.sparrowwallet.sparrow.control;
|
||||||
import com.sparrowwallet.drongo.OsType;
|
import com.sparrowwallet.drongo.OsType;
|
||||||
|
|
||||||
public enum WebcamPixelFormat {
|
public enum WebcamPixelFormat {
|
||||||
PIX_FMT_420V("420v", true, true),
|
//Only V4L2 formats defined in linux/videodev2.h are required here
|
||||||
PIX_FMT_YUVS("yuvs", true, true),
|
|
||||||
PIX_FMT_RGB24("RGB3", true, true),
|
PIX_FMT_RGB24("RGB3", true, true),
|
||||||
PIX_FMT_YUYV("YUYV", true, true),
|
PIX_FMT_YUYV("YUYV", true, true),
|
||||||
PIX_FMT_MJPG("MJPG", true, false),
|
PIX_FMT_MJPG("MJPG", true, false),
|
||||||
PIX_FMT_YUY2("YUY2", true, true),
|
|
||||||
PIX_FMT_NV12("NV12", false, false);
|
PIX_FMT_NV12("NV12", false, false);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
|
||||||
import com.google.zxing.common.HybridBinarizer;
|
import com.google.zxing.common.HybridBinarizer;
|
||||||
import com.google.zxing.qrcode.QRCodeReader;
|
import com.google.zxing.qrcode.QRCodeReader;
|
||||||
import com.sparrowwallet.bokmakierie.Bokmakierie;
|
import com.sparrowwallet.bokmakierie.Bokmakierie;
|
||||||
|
import com.sparrowwallet.drongo.OsType;
|
||||||
import com.sparrowwallet.sparrow.io.Config;
|
import com.sparrowwallet.sparrow.io.Config;
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
|
|
@ -135,11 +136,16 @@ public class WebcamService extends ScheduledService<Image> {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CaptureFormat> deviceFormats = new ArrayList<>(device.getFormats());
|
List<CaptureFormat> deviceFormats = new ArrayList<>(device.getFormats());
|
||||||
|
|
||||||
|
//On *nix prioritise supported camera pixel formats, preferring RGB3 and YUYV over MJPG
|
||||||
|
//On macOS and Windows, camera pixel format is largely abstracted away
|
||||||
|
if(OsType.getCurrent() == OsType.UNIX) {
|
||||||
deviceFormats.sort((f1, f2) -> {
|
deviceFormats.sort((f1, f2) -> {
|
||||||
WebcamPixelFormat pf1 = WebcamPixelFormat.fromFourCC(f1.getFormatInfo().fourcc);
|
WebcamPixelFormat pf1 = WebcamPixelFormat.fromFourCC(f1.getFormatInfo().fourcc);
|
||||||
WebcamPixelFormat pf2 = WebcamPixelFormat.fromFourCC(f2.getFormatInfo().fourcc);
|
WebcamPixelFormat pf2 = WebcamPixelFormat.fromFourCC(f2.getFormatInfo().fourcc);
|
||||||
return Integer.compare(WebcamPixelFormat.getPriority(pf1), WebcamPixelFormat.getPriority(pf2));
|
return Integer.compare(WebcamPixelFormat.getPriority(pf1), WebcamPixelFormat.getPriority(pf2));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Map<WebcamResolution, CaptureFormat> supportedResolutions = deviceFormats.stream()
|
Map<WebcamResolution, CaptureFormat> supportedResolutions = deviceFormats.stream()
|
||||||
.filter(f -> WebcamResolution.from(f) != null)
|
.filter(f -> WebcamResolution.from(f) != null)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue