Esempio n. 1
0
        static void Main(string[] args)
        {
            int    iArg      = 0;
            Detect det       = new Detect();
            string imageFile = @"G:\src\BingApi\images\happy\030408_happy.jpg";

            try
            {
                while (iArg < args.Length - 1)
                {
                    switch (args[iArg].ToLower())
                    {
                    case "-nnfile":
                        det.SetFaceFeatureFile(args[++iArg]);
                        break;

                    case "-help":
                    case "-h":
                        Usage();
                        return;

                    default:
                        Console.WriteLine("Unrecognized option {0}", args[iArg]);
                        Usage();
                        return;
                    }
                    ++iArg;
                }

                if (iArg < args.Length)
                {
                    imageFile = args[iArg];
                }

                det.DetectFile(imageFile);
                det.PrintResults();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error processing input {0}", e.Message);
            }
        }
Esempio n. 2
0
        public int ReadArgs(string[] args, int iArg)
        {
            List <int> coords = new List <int>();

            try
            {
                while (iArg < args.Length)
                {
                    switch (args[iArg].ToLower())
                    {
                    case "-base":
                        _imageBase = args[++iArg];
                        break;

                    case "-dontrun":
                        _dontRun = true;
                        break;

                    case "-basepts4":
                        coords.Clear();
                        for (int i = 0; i < 4; i++)
                        {
                            int val = (int)Math.Round(Convert.ToSingle(args[++iArg]));
                            coords.Add(val);
                            Console.Write("{0} ", val);
                        }
                        Console.WriteLine();
                        _basePoints = Detect.FaceAnchorPoints(coords[0], coords[1], coords[2], coords[3]);
                        break;

                    case "-basepts6":
                        coords.Clear();
                        for (int i = 0; i < 6; i++)
                        {
                            int val = (int)Math.Round(Convert.ToSingle(args[++iArg]));
                            coords.Add(val);
                            Console.Write("{0} ", val);
                        }
                        Console.WriteLine();
                        _basePoints.AddRange(coords);
                        break;

                    case "-srcpts4":
                        coords.Clear();
                        for (int i = 0; i < 4; i++)
                        {
                            int val = (int)Math.Round(Convert.ToSingle(args[++iArg]));
                            coords.Add(val);
                            Console.Write("{0} ", val);
                        }
                        Console.WriteLine();
                        _srcPoints = Detect.FaceAnchorPoints(coords[0], coords[1], coords[2], coords[3]);
                        break;

                    case "-srcpts6":
                        coords.Clear();
                        for (int i = 0; i < 6; i++)
                        {
                            int val = (int)Math.Round(Convert.ToSingle(args[++iArg]));
                            coords.Add(val);
                            Console.Write("{0} ", val);
                        }
                        Console.WriteLine();
                        _srcPoints.AddRange(coords);
                        break;

                    case "-src":
                        _imageSrc = args[++iArg];
                        break;

                    case "-thumbnailsize":
                        _thumbnailSize = Convert.ToInt32(args[++iArg]);
                        break;


                    case "-res":
                        _imageRes = args[++iArg];
                        break;

                    case "-mask":
                        _imageMask = args[++iArg];
                        break;

                    case "-maskpath":
                        _maskPath = args[++iArg];
                        break;


                    case "-nn":
                        _det.SetFaceFeatureFile(args[++iArg]);
                        break;

                    default:
                        Usage();
                        throw new Exception(String.Format("Unrecognized option |{0}|", args[iArg]));
                    }
                    ++iArg;
                }


                if (_basePoints.Count == 0)
                {
                    _basePoints = _det.FindFacePoints(_imageBase);
                }
                if (_srcPoints.Count == 0)
                {
                    _srcPoints = _det.FindFacePoints(_imageSrc);
                }
            }
            catch (Exception e)
            {
                throw new Exception(String.Format("Error processing input {0}", e.Message));
            }
            return(iArg);
        }
Esempio n. 3
0
 public void MatePair(string[] args, int iArg)
 {
     ReadArgs(args, iArg);
     Detect.Blend(_imageBase, _basePoints, _imageSrc, _srcPoints, _imageMask, _maskPoints, _imageRes, _dontRun);
 }