Пример #1
0
        private void ConsoleOutput(DetectResult argDetectResult)
        {
            textBoxOutput.Clear();
            State tempState = State.Instance();

            if (argDetectResult.face.Count == 0)
            {
                textBoxOutput.AppendText("没有检测到人脸!" + Environment.NewLine);
                tempState.IsFindFace = false;
            }
            else
            {
                tempState.IsFindFace = true;
                for (int i = 0; i < argDetectResult.face.Count; i++)
                {
                    textBoxOutput.AppendText("编号" + i.ToString() + System.Environment.NewLine);
                    textBoxOutput.AppendText("ID: " + argDetectResult.face[i].face_id + System.Environment.NewLine);
                    textBoxOutput.AppendText(String.Format("年龄:{0:F2}~{1:F2}" + System.Environment.NewLine, (argDetectResult.face[i].attribute.age.value - argDetectResult.face[i].attribute.age.range).ToString(), (argDetectResult.face[i].attribute.age.value + argDetectResult.face[i].attribute.age.range).ToString()));
                    textBoxOutput.AppendText(String.Format("性别:{0:F2} 几率:{1:F2}" + System.Environment.NewLine, argDetectResult.face[i].attribute.gender.value, argDetectResult.face[i].attribute.gender.confidence.ToString()));
                    textBoxOutput.AppendText(String.Format("人种:{0:F2} 几率:{1:F2}" + System.Environment.NewLine, argDetectResult.face[i].attribute.race.value, argDetectResult.face[i].attribute.race.confidence.ToString()));
                    textBoxOutput.AppendText(String.Format("左眼位置:{0:F2},{1:F2}" + System.Environment.NewLine, argDetectResult.face[i].position.eye_left.x, argDetectResult.face[i].position.eye_left.y));
                    textBoxOutput.AppendText(String.Format("右眼位置:{0:F2},{1:F2}" + System.Environment.NewLine, argDetectResult.face[i].position.eye_right.x, argDetectResult.face[i].position.eye_right.y));
                    textBoxOutput.AppendText(String.Format("嘴唇左边缘:{0:F2},{1:F2}" + System.Environment.NewLine, argDetectResult.face[i].position.mouth_left.x, argDetectResult.face[i].position.mouth_left.y));
                    textBoxOutput.AppendText(String.Format("嘴唇右边缘:{0:F2},{1:F2}" + System.Environment.NewLine, argDetectResult.face[i].position.mouth_right.x, argDetectResult.face[i].position.mouth_right.y));
                    textBoxOutput.AppendText(String.Format("鼻子:{0:F2},{1:F2}" + System.Environment.NewLine, argDetectResult.face[i].position.nose.x, argDetectResult.face[i].position.nose.y));
                    textBoxOutput.AppendText(System.Environment.NewLine);
                }
            }
        }
Пример #2
0
        /*
         * END - DETECT OBJECTS - URL IMAGE
         */

        /*
         * DETECT OBJECTS - LOCAL IMAGE
         * This is an alternative way to detect objects, instead of doing so through AnalyzeImage.
         */
        public static async Task DetectObjectsLocal(ComputerVisionClient client, string localImage)
        {
            Console.WriteLine("----------------------------------------------------------");
            Console.WriteLine("DETECT OBJECTS - LOCAL IMAGE");
            Console.WriteLine();

            using (Stream stream = File.OpenRead(localImage))
            {
                // Make a call to the Computer Vision service using the local file
                DetectResult results = await client.DetectObjectsInStreamAsync(stream);

                Console.WriteLine($"Detecting objects in local image {Path.GetFileName(localImage)}...");
                Console.WriteLine();

                // For each detected object in the picture, print out the bounding object detected, confidence of that detection and bounding box within the image
                Console.WriteLine("Detected objects:");
                if (results.Objects != null)
                {
                    foreach (var obj in results.Objects)
                    {
                        Console.WriteLine($"{obj.ObjectProperty} with confidence {obj.Confidence} at location {obj.Rectangle.X}, " +
                                          $"{obj.Rectangle.X + obj.Rectangle.W}, {obj.Rectangle.Y}, {obj.Rectangle.Y + obj.Rectangle.H}");
                    }
                }
                Console.WriteLine();
            }
        }
        private void AddResultItem(ref ResultItemMap resultItemMap, string value, bool?result)
        {
            DetectResult detectResult = new DetectResult();

            switch (result)
            {
            case true:
                detectResult = DetectResult.Supported;
                break;

            case false:
                detectResult = DetectResult.UnSupported;
                break;

            case null:
                detectResult = DetectResult.DetectFail;
                break;

            default:
                break;
            }

            ResultItem item = new ResultItem()
            {
                DetectedResult = detectResult, Name = value
            };

            resultItemMap.ResultItemList.Add(item);
        }
Пример #4
0
        public void FaceppThread( )
        {
            facesDetected = smallGrayFrame.DetectHaarCascade(
                haar,
                1.1,
                10,
                Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                new Size(20, 20))[0];
            int NUM = 0;

            for (int i = 0; i < facesDetected.Length; i++)
            {
                MCvAvgComp f = facesDetected[i];
                DETECTED = true;
                this.smallGrayFrame.ROI = f.rect;
                Image <Gray, Byte> roiImage = new Image <Gray, Byte> (f.rect.Size);
                this.smallGrayFrame.Copy(roiImage, smallGrayFrame);
                fsFileName = "DECT.jpg";
                roiImage.Save(fsFileName);
                DetectResult res_ = fs.Detection_DetectImg(this.smallGrayFrame);
                DetectResult res  = fs.Detection_DetectImg(System.Environment.CurrentDirectory + "\\" + fsFileName);
                if (res.face.Count > 0)
                {
                    age[NUM]    = res.face[0].attribute.age;
                    gender[NUM] = res.face[0].attribute.gender;
                    NUM++;
                }
            }
            if (DETECTED == true)
            {
                processingData( );
            }
        }
Пример #5
0
        private void AddLdapServer(ref ResultItemMap resultMap, Server server, DetectResult result)
        {
            if (!string.IsNullOrEmpty(server.ldapService.LdapServiceName))
            {
                AddResultItem(ref resultMap, "LdapServiceName: ", server.ldapService.LdapServiceName, result);
            }
            else
            {
                AddResultItem(ref resultMap, "LdapServiceName: ", server.ldapService.LdapServiceName, DetectResult.DetectFail);
            }

            if (!string.IsNullOrEmpty(server.ldapService.Port))
            {
                AddResultItem(ref resultMap, "LdapPort: ", server.ldapService.Port, result);
            }
            else
            {
                AddResultItem(ref resultMap, "LdapPort: ", server.ldapService.Port, DetectResult.DetectFail);
            }
            if (!string.IsNullOrEmpty(server.ldapService.GssToken))
            {
                AddResultItem(ref resultMap, "LdapGssToken: ", server.ldapService.GssToken, result);
            }
            else
            {
                AddResultItem(ref resultMap, "LdapGssToken: ", server.ldapService.GssToken, DetectResult.DetectFail);
            }
        }
        private void AddResultItem(ResultItemMap resultItemMap, string value, DetectResult result)
        {
            string imagePath = string.Empty;

            switch (result)
            {
            case DetectResult.Supported:
                imagePath = "/SMBDPlugin;component/Icons/supported.png";
                break;

            case DetectResult.UnSupported:
                imagePath = "/SMBDPlugin;component/Icons/unsupported.png";
                break;

            case DetectResult.DetectFail:
                imagePath = "/SMBDPlugin;component/Icons/undetected.png";
                break;

            default:
                break;
            }

            ResultItem item = new ResultItem()
            {
                DetectedResult = result, ImageUrl = imagePath, Name = value
            };

            resultItemMap.ResultItemList.Add(item);
        }
Пример #7
0
        public void Detect()
        {
            DetectResult result = OVR.Detect(0);

            Assert.AreEqual(result.IsOculusServiceRunning, true, "The Oculus service isn't running.");
            Assert.AreEqual(result.IsOculusHMDConnected, true, "The HMD isn't connected.");
        }
Пример #8
0
 private void AddDomain(ref ResultItemMap resultMap, DomainInfo domain, DetectResult result)
 {
     AddResultItem(ref resultMap, "DomainName: ", domain.Name, result);
     AddResultItem(ref resultMap, "DomainAdmin: ", domain.Admin, result);
     AddResultItem(ref resultMap, "DomainAdminPwd: ", domain.AdminPassword, result);
     AddResultItem(ref resultMap, "DomainFunctionLevel: ", domain.FunctionalLevel, result);
 }
Пример #9
0
 internal ChallengeSolver(HttpClient client, CloudflareHandler handler, Uri siteUrl, DetectResult detectResult)
 {
     HttpClient        = client;
     CloudflareHandler = handler;
     SiteUrl           = siteUrl;
     DetectResult      = detectResult;
 }
Пример #10
0
        public void DetectImageInStreamTest()
        {
            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                HttpMockServer.Initialize(this.GetType().FullName, "DetectImageInStreamTest");

                using (IComputerVisionClient client = GetComputerVisionClient(HttpMockServer.CreateInstance()))
                    using (FileStream stream = new FileStream(GetTestImagePath("people.jpg"), FileMode.Open))
                    {
                        DetectResult result = client.DetectObjectsInStreamAsync(stream).Result;

                        Assert.NotNull(result.Objects);
                        Assert.Equal(5, result.Objects.Count);
                        Assert.Equal("person", result.Objects[0].ObjectProperty);
                        Assert.Equal("person", result.Objects[1].ObjectProperty);
                        Assert.Equal("person", result.Objects[2].ObjectProperty);
                        Assert.Equal("person", result.Objects[3].ObjectProperty);

                        var firstObject = result.Objects[0];
                        Assert.Equal(0, firstObject.Rectangle.X);
                        Assert.Equal(46, firstObject.Rectangle.Y);
                        Assert.Equal(698, firstObject.Rectangle.H);
                        Assert.Equal(229, firstObject.Rectangle.W);
                        Assert.Equal(0.554, result.Objects[0].Confidence);

                        var secondObject = result.Objects[1];
                        Assert.Equal(5, secondObject.Rectangle.X);
                        Assert.Equal(71, secondObject.Rectangle.Y);
                        Assert.Equal(671, secondObject.Rectangle.H);
                        Assert.Equal(532, secondObject.Rectangle.W);
                        Assert.Equal(0.953, secondObject.Confidence);
                    }
            }
        }
Пример #11
0
        private void AddResultItem(ref ResultItemMap resultItemMap, string name, DetectResult result)
        {
            string imagePath = string.Empty;

            switch (result)
            {
            case DetectResult.Supported:
                imagePath = "/BranchCachePlugin;component/Icons/supported.png";
                break;

            case DetectResult.UnSupported:
                imagePath = "/BranchCachePlugin;component/Icons/unsupported.png";
                break;

            case DetectResult.DetectFail:
                imagePath = "/BranchCachePlugin;component/Icons/undetected.png";
                break;

            default:
                break;
            }
            ResultItem item = new ResultItem(result, imagePath, name);

            resultItemMap.ResultItemList.Add(item);
        }
        private void AddResultItem(ref ResultItemMap resultItemMap, string value, bool?result)
        {
            string       imagePath    = string.Empty;
            DetectResult detectResult = new DetectResult();

            switch (result)
            {
            case true:
                imagePath    = "/RDPClientPlugin;component/Icons/supported.png";;
                detectResult = DetectResult.Supported;
                break;

            case false:
                imagePath    = "/RDPClientPlugin;component/Icons/unsupported.png";
                detectResult = DetectResult.UnSupported;
                break;

            case null:
                imagePath    = "/RDPClientPlugin;component/Icons/undetected.png";
                detectResult = DetectResult.DetectFail;
                break;

            default:
                break;
            }

            ResultItem item = new ResultItem()
            {
                DetectedResult = detectResult, ImageUrl = imagePath, Name = value
            };

            resultItemMap.ResultItemList.Add(item);
        }
Пример #13
0
        private void DefaultStage(DetectResult detectResult)
        {
            if (detectResult.face.Count == 1)
            {
                VerifyResult person = fs.Recognition_VerifyByName(detectResult.face[0].face_id, userName.Text);
                status.Content = "Hello " + userName.Text + ", What would you like to do?";

                if (person == null)
                {
                    PersonBasicInfo info = fs.Person_Create(userName.Text, detectResult.face[0].face_id);
                    AsyncResult     a    = fs.Train_VerifyById(info.person_id);
                }
                else
                {
                    if (!person.is_same_person)
                    {
                        status.Content = "NO! You are not " + userName.Text;
                    }
                    else
                    {
                        lockFile.IsEnabled   = true;
                        UnlockFile.IsEnabled = true;
                        Increase.IsEnabled   = true;
                    }
                }
            }
            else
            {
                status.Content = "No face detected";
            }
        }
Пример #14
0
        private string GetFaceToken(Face face)
        {
            HttpMethods httpMethods = new HttpMethods();
            string      token       = null;
            var         dic         = new Dictionary <object, object>();

            dic.Add("api_key", API_KEY);
            dic.Add("api_secret", API_SECRET);
            string strResult = null;

            try
            {
                strResult = httpMethods.HttpPost(DETECT_URL, dic, face.fileName);
            }
            catch (Exception ex)
            {
                Console.WriteLine("GetFaceToken >>>>>>> " + ex.Message);
            }
            if (strResult != null)
            {
                DetectResult decResult = (DetectResult)JsonConvert.DeserializeObject(strResult, typeof(DetectResult));
                foreach (HttpConnect.Face eleFace in decResult.faces)
                {
                    token = eleFace.face_token;
                }
            }
            face.face_token = token;
            return(token);
        }
Пример #15
0
 internal JsChallengeSolver(CloudflareHandler handler, Uri siteUrl, DetectResult detectResult, [Optional] int clearanceDelay)
     : base(handler, siteUrl, detectResult)
 {
     if (clearanceDelay != default(int))
     {
         ClearanceDelay = clearanceDelay;
     }
 }
Пример #16
0
 internal JsChallengeSolver(CloudflareHandler handler, Uri siteUrl, DetectResult detectResult, string userAgent, [Optional] int?clearanceDelay)
     : base(handler, siteUrl, detectResult, userAgent)
 {
     if (clearanceDelay.HasValue)
     {
         ClearanceDelay = clearanceDelay.Value;
     }
 }
Пример #17
0
 public static void PrintDetectResult(DetectResult results)
 {
     Console.WriteLine("Printing DetectResult objects...");
     foreach (var obj in results.Objects)
     {
         Console.WriteLine($"{obj.ObjectProperty} with confidence {obj.Confidence} at location {obj.Rectangle.X}, " +
                           $"{obj.Rectangle.X + obj.Rectangle.W}, {obj.Rectangle.Y}, {obj.Rectangle.Y + obj.Rectangle.H}");
     }
     Console.WriteLine();
 }
Пример #18
0
        /// <summary>
        /// Check if the server supports RSVD.
        /// </summary>
        public DetectResult CheckRsvdSupport(ref DetectionInfo info)
        {
            DetectResult result = DetectResult.DetectFail;

            logWriter.AddLog(LogLevel.Information, "Share path: " + info.targetShareFullPath);

            #region Copy test VHD file to the target share to begin detecting RSVD

            string vhdOnSharePath = Path.Combine(info.targetShareFullPath, vhdName);
            CopyTestVHD(info.targetShareFullPath, vhdOnSharePath);
            #endregion

            try
            {
                #region RSVD version 2

                bool versionTestRes = TestRsvdVersion(vhdName + fileNameSuffix, info.BasicShareName, RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2);
                if (versionTestRes)
                {
                    info.RsvdVersion = RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2;
                    result           = DetectResult.Supported;
                    logWriter.AddLog(LogLevel.Information, "RSVD version 2 is supported");
                    return(result);
                }
                else
                {
                    logWriter.AddLog(LogLevel.Information, "The server doesn't support RSVD version 2.");
                }
                #endregion

                #region RSVD version 1
                versionTestRes = TestRsvdVersion(vhdName + fileNameSuffix, info.BasicShareName, RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1);
                if (versionTestRes)
                {
                    info.RsvdVersion = RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1;
                    result           = DetectResult.Supported;
                    logWriter.AddLog(LogLevel.Information, "RSVD version 1 is supported");
                    return(result);
                }
                else
                {
                    result = DetectResult.UnSupported;
                    logWriter.AddLog(LogLevel.Information, @"The server doesn't support RSVD.");
                }
                #endregion
            }
            catch (Exception e)
            {
                logWriter.AddLog(LogLevel.Information, @"Detect RSVD failed with exception: " + e.Message);
            }

            DeleteTestVHD(info.targetShareFullPath, vhdOnSharePath);
            return(result);
        }
Пример #19
0
 private static void DisplayObjects(DetectResult analysis)
 {
     Console.WriteLine("Objects:");
     foreach (var obj in analysis.Objects)
     {
         Console.WriteLine("{0} with confidence {1} at location {2},{3},{4},{5}",
                           obj.ObjectProperty, obj.Confidence,
                           obj.Rectangle.X, obj.Rectangle.X + obj.Rectangle.W,
                           obj.Rectangle.Y, obj.Rectangle.Y + obj.Rectangle.H);
     }
     Console.WriteLine("\n");
 }
Пример #20
0
        // Analyze a remote image
        private static async Task DetectObjectsFromUrlAsync(ComputerVisionClient computerVision, string imageUrl)
        {
            if (!Uri.IsWellFormedUriString(imageUrl, UriKind.Absolute))
            {
                Console.WriteLine("\nInvalid remote image url:\n{0} \n", imageUrl);
                return;
            }

            DetectResult analysis = await computerVision.DetectObjectsAsync(imageUrl);

            Console.WriteLine(imageUrl);
            DisplayObjects(analysis);
        }
        /// <summary>
        /// Check if the server supports SQOS.
        /// </summary>
        public DetectResult CheckSqosSupport(ref DetectionInfo info)
        {
            logWriter.AddLog(LogLevel.Information, "Share name: " + info.targetShareFullPath);

            DetectResult result = DetectResult.UnSupported;

            if (info.smb2Info.MaxSupportedDialectRevision < DialectRevision.Smb311)
            {
                return(result);
            }

            #region copy test VHD file to share
            string vhdOnSharePath = Path.Combine(info.targetShareFullPath, vhdName);
            CopyTestVHD(info.targetShareFullPath, vhdOnSharePath);
            #endregion

            #region SQOS dialect 1.1

            bool versionTestRes = TestSqosVersion(info.BasicShareName, SQOS_PROTOCOL_VERSION.Sqos11);
            if (versionTestRes)
            {
                info.SqosVersion = SQOS_PROTOCOL_VERSION.Sqos11;
                result           = DetectResult.Supported;
                logWriter.AddLog(LogLevel.Information, "SQOS dialect 1.1 is supported");
                return(result);
            }
            else
            {
                logWriter.AddLog(LogLevel.Information, "The server doesn't support SQOS version 2.");
            }
            #endregion

            #region SQOS dialect 1.0
            versionTestRes = TestSqosVersion(info.BasicShareName, SQOS_PROTOCOL_VERSION.Sqos10);
            if (versionTestRes)
            {
                info.SqosVersion = SQOS_PROTOCOL_VERSION.Sqos10;
                result           = DetectResult.Supported;
                logWriter.AddLog(LogLevel.Information, "SQOS dialect 1.0 is supported");
                return(result);
            }
            else
            {
                result = DetectResult.UnSupported;
                logWriter.AddLog(LogLevel.Information, @"The server doesn't support SQOS.");
            }
            #endregion

            DeleteTestVHD(info.targetShareFullPath, vhdOnSharePath);
            return(result);
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title            = "选择文件";
            openFileDialog.Filter           = "jpg文件|*.jpg|png文件|*.png|所有文件|*.*";
            openFileDialog.FileName         = string.Empty;
            openFileDialog.FilterIndex      = 1;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.DefaultExt       = "jpg";
            DialogResult result = openFileDialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            String filepath = openFileDialog.FileName;

            BitmapImage bitmap = new BitmapImage();

            bitmap.BeginInit();
            bitmap.UriSource         = new Uri(filepath);
            bitmap.DecodePixelHeight = (int)image1.Height;
            bitmap.DecodePixelWidth  = (int)image1.Width;
            bitmap.EndInit();
            image1.Source = bitmap;
            PngBitmapEncoder pngE = new PngBitmapEncoder();

            pngE.Frames.Add(BitmapFrame.Create(bitmap));
            using (Stream stream = File.Create(System.IO.Path.Combine(System.Environment.CurrentDirectory, "temp.jpg")))
            {
                pngE.Save(stream);
            }
            DetectResult res = fs.Detection_DetectImg(System.IO.Path.Combine(System.Environment.CurrentDirectory, "temp.jpg"));

            canvas1.Children.Clear();
            for (int i = 0; i < res.face.Count; ++i)
            {
                RectangleGeometry rect = new RectangleGeometry();
                rect.Rect = new Rect(max(res.face[i].position.center.x * image1.Width / 100.0 - res.face[i].position.width * image1.Width / 200.0, 0),
                                     max(res.face[i].position.center.y * image1.Height / 100.0 - res.face[i].position.height * image1.Height / 200.0, 0),
                                     res.face[i].position.width * image1.Width / 100.0, res.face[i].position.height * image1.Height / 100.0);
                System.Windows.Shapes.Path myPath = new System.Windows.Shapes.Path();
                myPath.Stroke          = Brushes.Red;
                myPath.StrokeThickness = 3;
                myPath.Data            = rect;
                label1.Content         = label1.Content + String.Format("({0:F2},{1:F2})", res.face[0].position.center.x, res.face[0].position.center.y);
                label2.Content         = label2.Content + String.Format("({0:F2},{1:F2})", res.face[0].position.width, res.face[0].position.height);
                canvas1.Children.Add(myPath);
            }
        }
Пример #23
0
    DetectResult BrickDetect(Transform trans)
    {
        DetectResult detectResult = new DetectResult();
        RaycastHit   hit;

        //Debug.Log("yeah");
        if (Physics.Raycast(trans.position, trans.forward, out hit, Mathf.Infinity, layerMask))
        {
            //Debug.Log("point: " + hit.point);
            //Debug.Log("normal" + hit.normal);

            //if(hit.normal.x != (int)(hit.normal.x) || hit.normal.y != (int)(hit.normal.y) || hit.normal.z != (int)(hit.normal.z)){
            if (!HelperFunc.Equal(hit.normal.x, (int)(hit.normal.x)) || !HelperFunc.Equal(hit.normal.y, (int)(hit.normal.y)) || !HelperFunc.Equal(hit.normal.z, (int)(hit.normal.z)))
            {
                //Debug.Log("normalCheckFailed");
                detectResult.point      = new Vector3Int(0, 0, 0);
                detectResult.detectable = false;
                return(detectResult);
            }
            else
            {
                //Debug.Log("normal check ok");
                setPoint = Hitpoint2Grid(hit.point, hit.normal);
                //Debug.Log(setPoint);
                intersectingCols = Physics.OverlapSphere(setPoint, 0.01f);
                if (intersectingCols.Length == 0)
                {
                    Debug.DrawLine(transform.position, setPoint, Color.red);
                    detectResult.point      = setPoint;
                    detectResult.detectable = true;
                    return(detectResult);
                }
                else
                {
                    detectResult.point      = new Vector3Int(0, 0, 0);
                    detectResult.detectable = false;
                    return(detectResult);
                }
            }
            //return true;
        }
        else
        {
            detectResult.point      = new Vector3Int(0, 0, 0);
            detectResult.detectable = false;
            return(detectResult);
            //return false;
        }
    }
        /// <summary>
        /// sending server face rect image.
        /// </summary>
        /// <param name="faces"></param>
        /// <returns></returns>
        private IEnumerator SendCertificationRequest(MatOfRect faces)
        {
            string jsonString = "";

            Rect [] rects = faces.toArray();
            for (int i = 0; i < rects.Length; i++)
            {
                Debug.Log(name);
                Debug.Log("request start");
                WWWForm form = new WWWForm();
                // TODO convert rect to json
                jsonString = jsonConvertFace(rects[i]);

                // send detect data to facecertification.net
                // Request https://facecertification.net/checkFace
                byte[] postData = System.Text.Encoding.UTF8.GetBytes(jsonString);
                UnityEngine.Networking.UnityWebRequest www = new UnityEngine.Networking.UnityWebRequest("https://facecertification.net/checkFace", "POST");
//                UnityEngine.Networking.UnityWebRequest www = new UnityEngine.Networking.UnityWebRequest("http://localhost:5001/checkFace", "POST");
                www.uploadHandler   = (UnityEngine.Networking.UploadHandler) new UnityEngine.Networking.UploadHandlerRaw(postData);
                www.downloadHandler = (UnityEngine.Networking.DownloadHandler) new UnityEngine.Networking.DownloadHandlerBuffer();
                www.SetRequestHeader("Content-Type", "application/json");

                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    Debug.Log("request complete!");
                    Debug.Log(www.downloadHandler.text);
                    DetectResult detectResulat = JsonUtility.FromJson <DetectResult>(www.downloadHandler.text);
                    if (detectResulat.predict != null && detectResulat.predict.Length > 0)
                    {
                        Debug.Log(detectResulat.predict);
                        float max = detectResulat.predict.Max();
                        for (int j = 0; j < detectResulat.predict.Length; j++)
                        {
                            if (max == detectResulat.predict[j])
                            {
                                Debug.Log("predict: " + detectResulat.predict[j] + "predict category: " + detectResulat.categories[j]);
                                break;
                            }
                        }
                    }
                }
            }
        }
Пример #25
0
        /// <summary>
        /// Detects cloudflare protection type for a specific website.
        /// </summary>
        /// <param name="httpClient">HttpClient to use in detection process.</param>
        /// <param name="httpClientHandler">HttpClientHandler of the HttpClient.</param>
        /// <param name="targetUri">The uri of the website.</param>
        /// <param name="requireHttps">Https is required.</param>
        public static async Task <DetectResult> Detect(HttpClient httpClient, HttpClientHandler httpClientHandler, Uri targetUri, bool requireHttps = false)
        {
            DetectResult result = default(DetectResult);

            //await _locker.LockAsync(async () =>
            //{
            var cloudflareHandler = new CloudflareHandler(httpClientHandler);

            result = await Detect(httpClient, cloudflareHandler, targetUri, requireHttps);

            //cloudflareHandler.Dispose();
            //});

            return(result);
        }
Пример #26
0
        private void RunCamera(string stage)
        {
            if (videoSource == null)
            {
                videoSource = new VideoCaptureDevice();
            }

            if (videoSource.IsRunning)
            {
                videoSource.SignalToStop();
                videoSource.NewFrame -= videoSource_NewFrame;
                videoSource           = null;
                PngBitmapEncoder pngE = new PngBitmapEncoder();
                pngE.Frames.Add(BitmapFrame.Create((BitmapSource)personImage.Source));
                using (Stream stream = File.Create(System.Environment.CurrentDirectory + "/temp.jpg"))
                {
                    pngE.Save(stream);
                }
                DetectResult detectResult = fs.Detection_DetectImg(System.Environment.CurrentDirectory + "/temp.jpg");
                File.Delete(System.Environment.CurrentDirectory + "/temp.jpg");
                if (stage == "Default")
                {
                    DefaultStage(detectResult);
                    camera.Content = "Run Camera";
                }

                else
                {
                    AddFaceStage(detectResult);
                    cameraTab.Content = "Run Camera";
                }
                //videoSource.Stop();
            }
            else
            {
                videoSource           = new VideoCaptureDevice(videoDevices[deviceComboBox.SelectedIndex].MonikerString);
                videoSource.NewFrame += videoSource_NewFrame;
                videoSource.Start();
                if (stage == "Default")
                {
                    camera.Content = "Detect";
                }
                else
                {
                    cameraTab.Content = "Detect";
                }
            }
        }
Пример #27
0
 /// <summary>
 /// To reset the detection information.
 /// </summary>
 public void ResetDetectResult()
 {
     F_CopyOffload           = new DetectResult[] { DetectResult.UnSupported, DetectResult.UnSupported };
     F_IntegrityInfo         = new DetectResult[] { DetectResult.UnSupported, DetectResult.UnSupported };
     F_FileLevelTrim         = DetectResult.UnSupported;
     F_ResilientHandle       = DetectResult.UnSupported;
     F_ValidateNegotiateInfo = DetectResult.UnSupported;
     F_AppInstanceId         = DetectResult.UnSupported;
     F_HandleV1_BatchOplock  = DetectResult.UnSupported;
     F_HandleV1_LeaseV1      = DetectResult.UnSupported;
     F_HandleV2_BatchOplock  = DetectResult.UnSupported;
     F_HandleV2_LeaseV1      = DetectResult.UnSupported;
     F_HandleV2_LeaseV2      = DetectResult.UnSupported;
     F_Leasing_V1            = DetectResult.UnSupported;
     F_Leasing_V2            = DetectResult.UnSupported;
 }
Пример #28
0
        // Analyze a local image
        private static async Task DetectObjectsFromStreamAsync(ComputerVisionClient computerVision, string imagePath)
        {
            if (!File.Exists(imagePath))
            {
                Console.WriteLine("\nUnable to open or read local image path:\n{0} \n", imagePath);
                return;
            }

            using (Stream imageStream = File.OpenRead(imagePath))
            {
                DetectResult analysis = await computerVision.DetectObjectsInStreamAsync(imageStream);

                Console.WriteLine(imagePath);
                DisplayObjects(analysis);
            }
        }
        /*
         * DETECT OBJECTS - URL IMAGE
         */
        public static async Task <DetectResult> DetectObjectsUrl(ComputerVisionClient client, string urlImage)
        {
            Console.WriteLine("----------------------------------------------------------");
            Console.WriteLine("DETECT OBJECTS - URL IMAGE");
            Console.WriteLine();

            Console.WriteLine($"Detecting objects in URL image {Path.GetFileName(urlImage)}...");
            Console.WriteLine();
            // Detect the objects
            DetectResult detectObjectAnalysis = await client.DetectObjectsAsync(urlImage);

            // For each detected object in the picture, print out the bounding object detected, confidence of that detection and bounding box within the image
            Console.WriteLine("Detected objects:");
            Console.WriteLine();

            return(detectObjectAnalysis);
        }
Пример #30
0
 /** 将筛选出的数据封装为DetectResult类型 **/
 private void GetDetectResult()
 {
     detectResults.Clear();
     foreach (var item in cloneInformation)
     {
         if (item.BeginToken > item.EndToken)
         {
             //处理可能出现的脏数据
             continue;
         }
         else
         {
             //寻找token对应的信息
             var temp = new DetectResult(tokenList[item.BeginToken].BeginRow, tokenList[item.EndToken].EndRow, item.FileName, item.RNR);
             detectResults.Add(temp);
         }
     }
 }
 /// <summary>
 /// To reset the detection information.
 /// </summary>
 public void ResetDetectResult()
 {
     F_CopyOffload = new DetectResult[] { DetectResult.UnSupported, DetectResult.UnSupported };
     F_IntegrityInfo = new DetectResult[] { DetectResult.UnSupported, DetectResult.UnSupported };
     F_FileLevelTrim = DetectResult.UnSupported;
     F_ResilientHandle = DetectResult.UnSupported;
     F_ValidateNegotiateInfo = DetectResult.UnSupported;
     F_AppInstanceId = DetectResult.UnSupported;
     F_HandleV1_BatchOplock = DetectResult.UnSupported;
     F_HandleV1_LeaseV1 = DetectResult.UnSupported;
     F_HandleV2_BatchOplock = DetectResult.UnSupported;
     F_HandleV2_LeaseV1 = DetectResult.UnSupported;
     F_HandleV2_LeaseV2 = DetectResult.UnSupported;
     F_Leasing_V1 = DetectResult.UnSupported;
     F_Leasing_V2 = DetectResult.UnSupported;
 }
        private CaseSelectRule CreateRule(string ruleCategoryName, bool? hasFlag = true, DetectResult detectResult = DetectResult.Supported)
        {
            CaseSelectRule rule = null;

            if (hasFlag == null)
            {
                switch (detectResult)
                {
                    case DetectResult.Supported:
                        rule = new CaseSelectRule() { Name = ruleCategoryName, Status = RuleStatus.Selected };
                        break;
                    case DetectResult.DetectFail:
                        rule = new CaseSelectRule() { Name = ruleCategoryName, Status = RuleStatus.NotSupported };
                        break;
                    case DetectResult.UnSupported:
                        rule = new CaseSelectRule() { Name = ruleCategoryName, Status = RuleStatus.NotSupported };
                        break;
                    default:
                        break;
                }
            }
            else if (hasFlag.Value)
                rule = new CaseSelectRule() { Name = ruleCategoryName, Status = RuleStatus.Selected };
            else
                rule = new CaseSelectRule() { Name = ruleCategoryName, Status = RuleStatus.NotSupported };

            return rule;
        }