From aecd2f9fbeab0788bec071413e8b3eda5f4e78a4 Mon Sep 17 00:00:00 2001 From: Emiliana <38952746+emilianavt@users.noreply.github.com> Date: Sun, 21 Mar 2021 21:07:08 +0100 Subject: [PATCH] Reordered device capabilities to show most useful options first. --- Examples/OpenSeeWebcamInfo.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Examples/OpenSeeWebcamInfo.cs b/Examples/OpenSeeWebcamInfo.cs index bd118be..6663f28 100644 --- a/Examples/OpenSeeWebcamInfo.cs +++ b/Examples/OpenSeeWebcamInfo.cs @@ -57,15 +57,25 @@ public class OpenSeeWebcam { public List prettyCaps = null; private List> splitCaps = null; + + bool ge(bool a, bool b) { + return a || (!a && !b); + } private int CompareCaps(OpenSeeWebcamCapability a, OpenSeeWebcamCapability b) { - if (a.rating < b.rating) + int aRes = a.minCX * a.minCY; + int bRes = b.minCX * b.minCY; + bool aGoodFps = a.minInterval <= 670000; + bool bGoodFps = a.minInterval <= 670000; + bool aGoodRes = aRes >= 850000 && aRes <= 2200000; + bool bGoodRes = bRes >= 850000 && bRes <= 2200000; + if (a.rating < b.rating && ge(aGoodFps, bGoodFps) && ge(aGoodRes, bGoodRes)) return -1; - if (a.rating > b.rating) + if (a.rating > b.rating && ge(bGoodFps, aGoodFps) && ge(bGoodRes, aGoodRes)) return 1; - if (a.minCX * a.minCY > b.minCX * b.minCY) + if (aRes > bRes && ge(aGoodFps, bGoodFps) && ge(aGoodRes, bGoodRes)) return -1; - if (a.minCX * a.minCY < b.minCX * b.minCY) + if (aRes < bRes && ge(bGoodFps, aGoodFps) && ge(bGoodRes, aGoodRes)) return 1; if (a.minInterval < b.minInterval) return -1;