Items with no label
3335 Discussions

Facial Expression sr300 camera

AMiro4
Beginner
2,338 Views

It is possible to count the facial expressions with sr300 camera and display it??

0 Kudos
18 Replies
MartyG
Honored Contributor III
902 Views

Could you explain more please about what you are trying to do with face expressions? Thanks!

0 Kudos
AMiro4
Beginner
902 Views

I am using the Sr300 sensor along with the R2 SDK in Unity to create an application for human ergonomics. Based on the code from the library I want to count how many times an expression was executed. The counter should count how many times this expression is detected:

PXCMFaceData.ExpressionsData expressionData = _iFace.QueryExpressions();

if (expressionData != null)

{

PXCMFaceData.ExpressionsData.FaceExpressionResult expressionResult;

if (expressionData.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_EYES_UP, out expressionResult))

faceRenderer.DisplayExpression(expressionResult, PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_EYES_UP);

and display the counter in

public void DisplayExpression (PXCMFaceData.ExpressionsData.FaceExpressionResult expressionResult, PXCMFaceData.ExpressionsData.FaceExpression faceExpression)

 

{

 

ExpressionGUIText.GetComponent ().text = faceExpression.ToString () + "\n" + expressionResult.intensity.ToString () ;

}

 

I tried to implement a counter with a static variable but my counter is counting to infinity

0 Kudos
MartyG
Honored Contributor III
902 Views

I thought this what what you were trying to do but wanted to check to make sure.

If you are using the SR300 and Unity for your project then you are probably doing a counter the hard way by coding it yourself. The 2016 R2 SDK has a set of pre-made scripts called the Unity Toolkit. This includes a mechanism called SendMessageAction for detecting a particular face expression or gesture and then triggering a specific function in a script that you have written, such as a custom-named function called CountFaceExpression() that increments the counter value by one each time it is triggered by a recognized gesture.

0 Kudos
AMiro4
Beginner
902 Views

I tried with SendMessageAction and i get several errors. Related to the hand, the QueryHand returned null appears and for the face it says that the CountFaceExpression has no receiver. I don't know what is the cause of this

0 Kudos
MartyG
Honored Contributor III
902 Views

With SendMessageAction, there are two important things to remember:

1. The script with your counting function in has to be in the same object as the SendMessageAction component.

2. In the SendMessageAction component, you put the name of the function you want to trigger, not the name of the script that function is in. So if you have a script with a function called CountFaceExpression() then the SendMessageAction looks in every script inside the object to find one that has a function called CountFaceExpression in it.

I should add that the function name that your counter code is in can be anything you want. I just used CountFaceExpression as a random example I made up myself. Whatever function name you choose, that is the one you put in the text box in the SendMessageAction.

Also, you should not put the () brackets of the function name in the text box - just CountFaceExpression instead of CountFaceExpression(). I wrote a short illustrated guide to SendMessageAction a while ago.

0 Kudos
AMiro4
Beginner
902 Views

I did configure it following your guide and still QueryHand return null i get. I can't see where the problem is

0 Kudos
MartyG
Honored Contributor III
902 Views

Sometimes problems with using hand-related programs with the SR300 have occurred because of the processor chip in the PC being incompatible with the SR300. This problem with compatibility occurs in the olds Windows SDKs such as '2016 R2' but not the current 'SDK 2.0'. The official specification for the SR300 is at least a 6th generation Intel Core Skylake, or a newer processor such as 7th generation Intel Core Kaby Lake.

Do you know what the processor in your PC is please? You can find this information by typing 'system info' into the box at the bottom of your Windows screen to find the System Information program. On this window, the processor information is in the 'Processor' section. For example, my laptop says:

Processor Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz, 2000 Mhz, 2 Core(s), 4 Logical Processor(s)

The important part of the information is the first number after the 'i' number. The number that is there - such as '6' in mine - gives the generation number of your processor. Mine, being a '6', is a sixth generation Skylake.

Processor Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz, 2000 Mhz, 2 Core(s), 4 Logical Processor(s)

0 Kudos
AMiro4
Beginner
902 Views

Yes, i know that these are the specifications, and the generation of my laptop is 4 :Intel(R) Core(TM) i3-4010U CPU @ 1.70GHz, 1700 Mhz, 2 Core(s), 4 Logical Processor(s). I read some reviews that claimed that this would be the problem, but i guess if that would be, then the sensor wouldn't work at all, and it does work

0 Kudos
MartyG
Honored Contributor III
902 Views

There was a case two weeks ago where an SR300 user with the 2016 R2 SDK was finding that most non-hand sample programs worked but the hand samples would crash when the hand was detected. This user found that they had an incompatible processor, and the hand samples worked fine when using a 7th generation Kaby Lake PC.

0 Kudos
AMiro4
Beginner
902 Views

But my samples do work and i display the gestures in a GUItext but when i'm using the SendMessage action with this script to activate an image if the gesture is recognized i get that error. I used the code lines:

public class EneableImage : MonoBehaviour {

 

public Image Image1;

 

private void Awake()

 

{

 

Image1 = GetComponent<</span>UnityEngine.UI.Image>();

HideImage();

 

}

 

 

public void HideImage()

 

{

 

Image1.enabled = false ;

 

 

}

 

void OnTriggerShow(){

 

Image1.enabled = true ;

 

}

 

 

}

 

0 Kudos
MartyG
Honored Contributor III
902 Views

In my own Unity programming, if I am only using one hand in a program instead of putting both hands in front of the camera, I always tick the 'Continuous' box on the SendMessageAction. Can you try this please?

0 Kudos
AMiro4
Beginner
902 Views

Thank you for your help. I will try this tomorrow and come back with an answer. Hope this will work

0 Kudos
MartyG
Honored Contributor III
902 Views

Thank you very much. Good luck!

0 Kudos
AMiro4
Beginner
902 Views

I checked the continuous tracking in the inspector and the error with QueryHand persists. But this error appears when the sensor is initialized, before i can make the gesture. If i remove the SendMessage action from the inspector, the error disappears.

0 Kudos
MartyG
Honored Contributor III
902 Views

I remember that some gestures did not work as well as others, and some caused outright crashes of Unity when triggered. The most reliable gestures, I recall, were Hand Closed and Thumb Up. Could you try changing your SendMessageAction's gesture to one of these gestures please and see if it makes a difference?

0 Kudos
AMiro4
Beginner
902 Views

I tried and same error occurs

0 Kudos
MartyG
Honored Contributor III
902 Views

Using a 4th generation processor with an SR300 instead of a 6th generation one remains the most likely cause of your problems. A 5th generation Xeon processor only has a 50-50 chance of working, and I can only think of two occasions when a 4th generation processor has worked with the SR300 in the old 2016 R2 SDK.

0 Kudos
AMiro4
Beginner
902 Views

Thank you for your responses

0 Kudos
Reply