Пример #1
0
        private string GetPrettyCapability(OpenSeeWebcamCapability cap)
        {
            float  fps       = 10000000f / (float)cap.minInterval;
            string prettyCap = cap.minCX + "x" + cap.minCY + ", " + fps.ToString("0.##") + "fps (" + cap.format.ToString() + ")";

            return(prettyCap);
        }
Пример #2
0
 private int CompareCaps(OpenSeeWebcamCapability a, OpenSeeWebcamCapability b)
 {
     if (a.minCX * a.minCY > b.minCX * b.minCY)
     {
         return(-1);
     }
     if (a.minCX * a.minCY < b.minCX * b.minCY)
     {
         return(1);
     }
     if (a.rating < b.rating)
     {
         return(-1);
     }
     if (a.rating > b.rating)
     {
         return(1);
     }
     if (a.minInterval < b.minInterval)
     {
         return(-1);
     }
     if (a.minInterval > b.minInterval)
     {
         return(1);
     }
     return(0);
 }
Пример #3
0
        private int CompareCaps(OpenSeeWebcamCapability a, OpenSeeWebcamCapability b)
        {
            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 && ge(bGoodFps, aGoodFps) && ge(bGoodRes, aGoodRes))
            {
                return(1);
            }
            if (aRes > bRes && ge(aGoodFps, bGoodFps) && ge(aGoodRes, bGoodRes))
            {
                return(-1);
            }
            if (aRes < bRes && ge(bGoodFps, aGoodFps) && ge(bGoodRes, aGoodRes))
            {
                return(1);
            }
            if (a.minInterval < b.minInterval)
            {
                return(-1);
            }
            if (a.minInterval > b.minInterval)
            {
                return(1);
            }
            return(0);
        }
Пример #4
0
        public List <string> GetPrettyCapabilities()
        {
            if (splitCaps != null && prettyCaps != null)
            {
                return(prettyCaps);
            }

            splitCaps = new List <Tuple <OpenSeeWebcamCapability, int> >();

            for (int i = 0; i < caps.Length; i++)
            {
                if (caps[i].minCX == caps[i].maxCX && caps[i].minCY == caps[i].maxCY)
                {
                    splitCaps.Add(new Tuple <OpenSeeWebcamCapability, int>(caps[i], i));
                }
                else
                {
                    OpenSeeWebcamCapability min = caps[i];
                    OpenSeeWebcamCapability max = caps[i];
                    min.maxCX = min.minCX;
                    min.maxCY = min.minCY;
                    max.minCX = max.maxCX;
                    max.minCY = max.maxCY;
                    splitCaps.Add(new Tuple <OpenSeeWebcamCapability, int>(min, i));
                    splitCaps.Add(new Tuple <OpenSeeWebcamCapability, int>(max, i));
                }
            }

            splitCaps.Sort((a, b) => CompareCaps(a.Item1, b.Item1));

            prettyCaps = new List <string>();
            if (type == OpenSeeWebcamType.DirectShow)
            {
                prettyCaps.Add("Default settings");
            }
            foreach (var cap in splitCaps)
            {
                prettyCaps.Add(GetPrettyCapability(cap.Item1));
            }

            return(prettyCaps);
        }
Пример #5
0
        public OpenSeeWebcamCapability GetCapabilityByPrettyIndex(int index)
        {
            int dshowOffset = 0;

            if (type == OpenSeeWebcamType.DirectShow)
            {
                if (index == 0)
                {
                    OpenSeeWebcamCapability cap = new OpenSeeWebcamCapability();
                    cap.id          = -1;
                    cap.format      = OpenSeeWebcamFormat.Any;
                    cap.minInterval = 10000000 / 60;
                    return(cap);
                }
                dshowOffset = 1;
            }

            if (splitCaps == null || index >= splitCaps.Count + dshowOffset || index < 0)
            {
                throw new InvalidOperationException("Invalid capability index.");
            }

            return(caps[splitCaps[index - dshowOffset].Item2]);
        }