Using NFaceView in a WPF application

General information about Neurotechnology and its software

Using NFaceView in a WPF application

Postby knelt7 » Dec 06, 2018 22:16

I am trying to use the NFaceView control in a WPF application. I have no problem capturing and creating a template with the biometric client, but am having problems getting the NFaceView control to work in the wpf form.

I use the following code to add the control to the XAML form:
Code: Select all
             xmlns:neurotec="clr-namespace:Neurotec.Biometrics.Gui;assembly=Neurotec.Biometrics.Gui"

                    <WindowsFormsHost HorizontalAlignment="Left" Height="200" Margin="10,10,10,10" VerticalAlignment="Top" Width="400">
                         <neurotec:NFaceView x:Name="faceView" Size="50,50" BackColor="Green" ForeColor="Yellow" TokenImageRectangleColor="Red" ShowEmotionsConfidence="True" ShowExpressionConfidence="True" ShowEyesConfidence="True" ShowFaceConfidence="True" ShowGenderConfidence="True" ShowIcaoArrows="True" ShowMouthConfidence="True" ShowNoseConfidence="True" ShowPropertiesConfidence="True" ShowTokenImageRectangle="True" Visible="True" AutoSize="True" AutoScroll="True"/>
                    </WindowsFormsHost>

In the code behind:

Code: Select all
               faceView.Face = face;

Stepping through the code, I see that the faceView object is created, but when I set the Face to the face(NFace object), the capture still works, but I never see an image in the control and I get an exception after I release the components.

The exception is "Safe handle has been closed" with the following call stack:
Code: Select all
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
   at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
   at Neurotec.Biometrics.NFace.ObjectCollection.NFaceGetObjects(HNObject hFace, IntPtr& arhValues, Int32& valueCount)
   at Neurotec.Biometrics.NFace.ObjectCollection.GetAllOutNative(HNObject handle, IntPtr& arhValues, Int32& valueCount)
   at Neurotec.Collections.ObjectModel.NObjectReadOnlyCollection`1.GetAllOutInternal()
   at Neurotec.Collections.ObjectModel.NSimpleReadOnlyCollection`1.ToArray()
   at Neurotec.Biometrics.Gui.NFaceView.OnPaint(PaintEventArgs pe)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


I used the CaptureIcaoCompliantImage class from SimpleFacesSampleCS as a guide for setting the properties for the control.

Any idea of what I am missing or WPF sample code if anyone has any?


If I can't get the control to work in WPF, I will probably try subscribing to Face NLAttributes similar to the IcaoWarningView. How do those attributes compare to the visual cues in NFaceView? I haven't been able to find a description in the documentation.

Thank you,

Ken




VeriLook Extended 9.0 SDK, Revision #158289

WPF, .NET Framework 4.5.1, platform target x86
knelt7
 
Posts: 10
Joined: Oct 12, 2018 14:04

Re: Using NFaceView in a WPF application

Postby Martynas » Dec 07, 2018 08:57

Hello,

create small test application, which would allow to reproduce the same issue and send it to support@neurotechnology.com with detailed issue description.
Best regards,

Martynas
Software Consultant
Neurotechnology
Martynas
Neurotechnology
 
Posts: 2243
Joined: Sep 19, 2008 10:02
Location: Vilnius, Lithuania

Re: Using NFaceView in a WPF application

Postby zerokewl88 » Feb 14, 2019 01:28

Hello,

Did you ever find a way to enable the NFaceView control using WPF and inserting the class in via XAML and updating it in the code behind ?

I am also trying this and not finding much examples in the documentation / sample code.

Thank you.
zerokewl88
 
Posts: 9
Joined: Feb 14, 2019 01:26

Re: Using NFaceView in a WPF application

Postby zerokewl88 » Feb 14, 2019 01:52

In regards, to the above - did you get this working ?

Is there any other way using the NCamera to output it"s current video source / stream via a Event Handler to allow us to pass the image array ?

Thank you.
zerokewl88
 
Posts: 9
Joined: Feb 14, 2019 01:26

Re: Using NFaceView in a WPF application

Postby Martynas » Feb 15, 2019 10:22

Hi,

we do not provide any samples or tutorials for WPF, but previously all our customers were able to use NView controls in their WFP applications by adding Windows.Forms component in their applications.
If you are experiencing any issues, then please provide the small test application to support@neurotechnology.com with issue description.
Best regards,

Martynas
Software Consultant
Neurotechnology
Martynas
Neurotechnology
 
Posts: 2243
Joined: Sep 19, 2008 10:02
Location: Vilnius, Lithuania

Re: Using NFaceView in a WPF application

Postby zerokewl88 » Feb 16, 2019 11:54

Hello,

Thank you for your response.

I did end up researching further and found that using a Windows Forms Host inside the WPF Application was able to get it working fine.

Here's a little quick guide for anyone else looking for this information.

https://docs.microsoft.com/en-us/dotnet ... rol-in-wpf

Thank you.
zerokewl88
 
Posts: 9
Joined: Feb 14, 2019 01:26


Return to Public

Who is online

Users browsing this forum: No registered users and 2 guests