Items with no label
3335 Discussions

How do i set 60fps with SR300(Color Camera , FaceTracking)

松拓也
Novice
1,621 Views

Hi.

I'm trying to set 60fps with SR300(Color Camera , FaceTracking).

I'm using Unity and C# Script.

C# Script sets SR300.

When I read the specification of SR300, it was written that 720p Mode is able to set 60fps.

But, I don't know how to set it.

Could you teach me it??

I'm writting the code below.

public GameObject colorPlane; //Object to display color feed texture on

public Texture2D colorTexture2D; //Color Texture

private PXCMImage colorImage = null;//PXCMImage for color

private FaceRenderer faceRenderer; //Rendererer for Visualization

private int MaxPoints = 78;

private PXCMSenseManager psm; //SenseManager Instance

private pxcmStatus sts; //Check error status

private PXCMFaceModule faceAnalyzer; //FaceModule Instance

void Start () {

faceRenderer = gameObject.GetComponent();

/* Initialize a PXCMSenseManager instance */

psm = PXCMSenseManager.CreateInstance();

if (psm == null)

{

Debug.LogError("SenseManager Initialization Failed");

return;

}

/* Enable the color stream of size 640x480 */

psm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 60);

/* Enable the face tracking module*/

sts = psm.EnableFace();

if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR) Debug.LogError("PXCSenseManager.EnableFace: " + sts);

/* Retrieve an instance of face to configure */

faceAnalyzer = psm.QueryFace();

if (faceAnalyzer == null) Debug.LogError("PXCSenseManager.QueryFace");

/* Initialize the execution pipeline */

sts = psm.Init();

if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR)

{

Debug.LogError("PXCMSenseManager.Init Failed");

OnDisable();

return;

}

/* Retrieve a PXCMFaceConfiguration instance from a face to enable Gestures and Alerts */

PXCMFaceConfiguration config = faceAnalyzer.CreateActiveConfiguration();

config.detection.isEnabled = true; // 3D detection is the default tracking mode.config.landmarks.isEnabled = true;

config.pose.isEnabled = true;

config.QueryExpressions().Enable();

config.QueryExpressions().EnableExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_MOUTH_OPEN);

config.EnableAllAlerts();

config.ApplyChanges();

config.Dispose();

}
0 Kudos
9 Replies
MartyG
Honored Contributor III
453 Views

It looks as though you have already correctly set it to 60 fps.

STREAM_TYPE_COLOR, 640, 480, 60);

The first two numbers set the resolution (640, 480 is 640x480 resolution). The third number on the end (60) is the FPS. So by setting it at 60, you have set it as 640x480 resolution at 60 FPS.

If you wanted to set the stream type to color instead of depth, it would be:

sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH,640,480,60);

0 Kudos
松拓也
Novice
453 Views

Thank you for your answer.

umm...When i disable the FaceTracking Script, Unity runs 60fps.

0 Kudos
MartyG
Honored Contributor III
453 Views

Unity always shows the FPS at 60 because of a feature called VSync, which sets the maximum FPS at 60. If you wish, VSync can be disabled by going to Edit > Project Settings > Quality and, in the "Other" section of the settings, set the 'V Sync Count' option to 'Don't Sync'.

The Quality section allows you to set settings for each of Unity's run-quality modes. So select each quality setting in turn and turn V Sync Count off in each one to ensure that it is always inactive.

0 Kudos
松拓也
Novice
453 Views

Thank you very much!

Following your advise, i set the Unity.

But Unity runs 30fps.

The following sample runs 60fps.

Intel RealSense SDK Sample Brower -> Unity -> Hands Animation

I don't understand why it runs 60fps.

0 Kudos
MartyG
Honored Contributor III
453 Views

Once VSync is turned off, you can use the targetFrameRate instruction to force your application to try to run at the FPS that you specify.

https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html Unity - Scripting API: Application.targetFrameRate

0 Kudos
松拓也
Novice
453 Views

Thank you for your advise!

But, Unity runs 30FPS. orz

0 Kudos
MartyG
Honored Contributor III
453 Views

Somebody on the Unity forums who targetFrameRate did not work for tried this script instead.

secondsThisFrame += Time.deltaTime;

if(secondsThisFrame < 1.0f / FPS){

return;

}else{

secondsThisFrame = 0;

}

0 Kudos
松拓也
Novice
453 Views

Hi.

 

When i updated a RealSense Driver and SDK, Unity run 60FPS!!

 

Thank you for helping!
0 Kudos
MartyG
Honored Contributor III
453 Views

I'm glad you found a solution to your problem. Please visit the forum again if you have further problems. Thanks!

0 Kudos
Reply