1

如何使用 Luxand API 在 Visual Studio 2010 中工作?我需要检测给定面部的下巴点,我可以使用任何其他 API 来实现吗?

我试过这个示例代码:

 OpenFileDialog openFileDialog1 = new OpenFileDialog();
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            try
            {
                FSDK.CImage image = new FSDK.CImage(openFileDialog1.FileName);

                // resize image to fit the window width
                double ratio = System.Math.Min((pictureBox1.Width + 0.4) / image.Width,
                    (pictureBox1.Height + 0.4) / image.Height);
                image = image.Resize(ratio);

                Image frameImage = image.ToCLRImage();
                Graphics gr = Graphics.FromImage(frameImage);

                FSDK.TFacePosition facePosition = image.DetectFace();
                if (0 == facePosition.w)
                    MessageBox.Show("No faces detected", "Face Detection");
                else
                {
                    int left = facePosition.xc - facePosition.w / 2;
                    int top = facePosition.yc - facePosition.w / 2;
                    gr.DrawRectangle(Pens.LightGreen, left, top, facePosition.w, facePosition.w);

                    FSDK.TPoint[] facialFeatures = image.DetectFacialFeaturesInRegion(ref facePosition);
                    int i = 0;
                    foreach (FSDK.TPoint point in facialFeatures)
                        gr.DrawEllipse((++i > 2) ? Pens.LightGreen : Pens.Blue, point.x, point.y, 3, 3);

                    gr.Flush();
                }

                // display image
                pictureBox1.Image = frameImage;
                pictureBox1.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception");
            }
        }

我收到此错误:无法加载文件或程序集“xquisite.application.exe”或其依赖项之一。此程序集由比当前加载的运行时更新的运行时构建,无法加载。

4

2 回答 2

2


你的目标设置是什么?有CPU吗?尝试x86运行时!
你添加到你的 app.config 了<startup useLegacyV2RuntimeActivationPolicy="true"/> 吗?这两个认为我忘记了,是我的错误的原因,这和你的一样。

这是我的一段代码:

        private void DetectFace()
    {
        var failerCounter = 0;
        var cameraHandler = 0;
        try
        {
            const int failerLimit = 2;
            int failerLimitFaceDetection = Properties.Settings.Default.NotDetectedLimit;
            float similarityMinimum = Properties.Settings.Default.SimilarityLimit;

            var r = FSDKCam.OpenVideoCamera(ref CameraName, ref cameraHandler);
            if (r != FSDK.FSDKE_OK)
            {
                MessageBox.Show(StringHelper.ErrorCamera);
            }
            FSDK.SetFaceDetectionParameters(
                Properties.Settings.Default.DetectionHandleArbitaryRotations,
                Properties.Settings.Default.DetectionDetermineFaceRotationAngle,
                Properties.Settings.Default.DetectionInternalResizeWidth);
            FSDK.SetFaceDetectionThreshold(Properties.Settings.Default.DetectionFaceDetectionThreshold);

            while (IsFaceDetectionActive)
            {
                var imageHandle = 0;
                if (FSDK.FSDKE_OK != FSDKCam.GrabFrame(cameraHandler, ref imageHandle))
                {
                    Application.Current.Dispatcher.Invoke(delegate { }, DispatcherPriority.Background);
                    continue;
                }
                var image = new FSDK.CImage(imageHandle);
                var frameImage = image.ToCLRImage();
                FaceContent = frameImage;
                var gr = Graphics.FromImage(frameImage);
                var facePosition = image.DetectFace();

                IsFaceDetected = facePosition.w != 0;
                if (!IsFaceDetected)
                {
                    if (failerCounter++ > failerLimitFaceDetection)
                    {
                        failerCounter = 0;
                        OnFaceNotDetected();
                    }
                }
                // if a face is detected, we detect facial features
                if (IsFaceDetected)
                {
                    var facialFeatures = image.DetectFacialFeaturesInRegion(ref facePosition);
                    SmoothFacialFeatures(ref facialFeatures);
                    FaceTemplate = image.GetFaceTemplate();
                    // Similarity = 0.5f -> fin the right value ....
                    IsFaceRecognized = FaceMetricHandler.LooksLike(FaceTemplate, similarityMinimum).Any();

                    if (IsFaceRecognized)
                    {
                        foreach (var match in FaceMetricHandler.LooksLike(FaceTemplate, similarityMinimum))
                        {
                            failerCounter = 0;
                            GreetingMessage = match.Name;
                            IsFaceDetectionActive = false;
                            OnFaceRecognized();
                            break;
                        }
                    }
                    else
                    {
                        if (failerCounter++ > failerLimit)
                        {
                            failerCounter = 0;
                            IsFaceDetectionActive = false;
                            OnFaceNotRecognized();
                        }
                    }


                    if (IsFaceFrameActive)
                    {
                        gr.DrawRectangle(Pens.Red, facePosition.xc - 2*facePosition.w/3,
                                         facePosition.yc - facePosition.w/2,
                                         4*facePosition.w/3, 4*facePosition.w/3);
                    }
                }
                else
                {
                    ResetSmoothing();
                }
                FaceContent = frameImage;
                GC.Collect();
                Application.Current.Dispatcher.Invoke(delegate { }, DispatcherPriority.Background);
            }
        }
        catch(Exception e)
        {
            logger.Fatal(e.Message);
            InitializeCamera();
        }
        finally
        {
            FSDKCam.CloseVideoCamera(cameraHandler);
            FSDKCam.FinalizeCapturing();

        }
    }


于 2013-07-10T18:43:53.393 回答
1

顺便说一句,您可以将 x64 与 win64\FaceSDK.NET.dll 一起使用

于 2013-07-12T18:03:43.303 回答