Skip to content

Commit

Permalink
push to 4.0.4 (#259)
Browse files Browse the repository at this point in the history
* ignore wrapper if in folder

* remove body 70 & add skeleton smoothing & add warning when no animator

* change plugin version to 4.0.4

* add positional tracking mode parameter

* add positional tracking mode in zedmanager inspector

* fix opencv sample

* change default aruco in opencv scene

* readd body 70

* update linux lib

* add default constructor to Rect struct

---------

Co-authored-by: Jean-Loup Macarit <[email protected]>
  • Loading branch information
Bvallon-sl and SLJLMacarit authored Jun 27, 2023
1 parent b25cf15 commit 3c3d4a7
Show file tree
Hide file tree
Showing 13 changed files with 284 additions and 345 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*
unity-wrapper/

# Visual Studio cache directory
.vs/
Expand Down
9 changes: 9 additions & 0 deletions ZEDCamera/Assets/ZED/Editor/Scripts/ZEDCameraEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class ZEDCameraEditor : Editor
private SerializedProperty pathSMProperty;
private SerializedProperty floorAsOriginProperty;
private SerializedProperty trackingIsStaticProperty;
private SerializedProperty positionalTrackingModeProperty;

//Rendering Prop
private SerializedProperty depthOcclusionProperty;
Expand Down Expand Up @@ -147,6 +148,7 @@ public class ZEDCameraEditor : Editor
// runtime params
private SerializedProperty BT_Confidence;
private SerializedProperty BT_MinimumKPThresh;
private SerializedProperty BT_SkSmoothing;

/// <summary>
/// Layout option used to draw the '...' button for opening a File Explorer window to find a mesh file.
Expand Down Expand Up @@ -259,6 +261,7 @@ private void OnEnable()
pathSMProperty = serializedObject.FindProperty("pathSpatialMemory");
floorAsOriginProperty = serializedObject.FindProperty("setFloorAsOrigin");
trackingIsStaticProperty = serializedObject.FindProperty("trackingIsStatic");
positionalTrackingModeProperty = serializedObject.FindProperty("positionalTrackingMode");


///Rendering Serialized Properties
Expand Down Expand Up @@ -317,6 +320,7 @@ private void OnEnable()
BT_BodySelection = serializedObject.FindProperty("bodySelection");

BT_Confidence = serializedObject.FindProperty("bodyTrackingConfidenceThreshold");
BT_SkSmoothing = serializedObject.FindProperty("bodyTrackingSkeletonSmoothing");
//Recording Serialized Properties
svoOutputFileNameProperty = serializedObject.FindProperty("svoOutputFileName");
svoOutputCompressionModeProperty = serializedObject.FindProperty("svoOutputCompressionMode");
Expand Down Expand Up @@ -593,6 +597,8 @@ public override void OnInspectorGUI()
"Can be useful for stationary cameras where you still need tracking enabled, such as in Object Detection.");
trackingIsStaticProperty.boolValue = EditorGUILayout.Toggle(trackingIsStaticPropertyLabel, trackingIsStaticProperty.boolValue);

GUIContent positionalTrackingModePropertyLabel = new GUIContent("Positional Tracking Mode", "Lists the mode of positional tracking that can be used.");
positionalTrackingModeProperty.enumValueIndex = (int)(sl.POSTIONAL_TRACKING_MODE)EditorGUILayout.EnumPopup(positionalTrackingModePropertyLabel, (sl.POSTIONAL_TRACKING_MODE)positionalTrackingModeProperty.enumValueIndex);

EditorGUI.indentLevel--;

Expand Down Expand Up @@ -1016,6 +1022,9 @@ public override void OnInspectorGUI()
"an object exists to report it.\r\n\nEx: If the threshold is 80, then only objects where the SDK is 80% sure or greater will appear in the list of detected objects.");
BT_Confidence.intValue = EditorGUILayout.IntSlider(BodyTrackingConfidenceLabel, BT_Confidence.intValue, 1, 99);

GUIContent BT_SkSmoothingLabel = new GUIContent("Skeleton Smoothing", "From 0 (no smoothing) to 1 (max smoothing), amount of smoothing applied to the skeleton data during the fitting. Higher values will have more latency, but less jitter.");
BT_SkSmoothing.floatValue = EditorGUILayout.Slider(BT_SkSmoothingLabel, BT_SkSmoothing.floatValue, 0, 1.0f);

GUI.enabled = cameraIsReady;

GUILayout.Space(10);
Expand Down
500 changes: 180 additions & 320 deletions ZEDCamera/Assets/ZED/Examples/Body Tracking/Scene/BodyTrackingMulti.unity

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -214,6 +215,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0.1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1380222653}
m_RootOrder: 0
Expand Down Expand Up @@ -273,6 +275,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -4.2, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2010391085}
m_Father: {fileID: 0}
Expand Down Expand Up @@ -316,6 +319,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -369,6 +373,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0.1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 599479602}
m_RootOrder: 0
Expand All @@ -380,7 +385,7 @@ LightingSettings:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Settings.lighting
serializedVersion: 3
serializedVersion: 4
m_GIWorkflowMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
Expand All @@ -393,7 +398,7 @@ LightingSettings:
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_TextureCompression: 1
m_LightmapCompression: 3
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
Expand Down Expand Up @@ -434,10 +439,10 @@ LightingSettings:
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0
--- !u!114 &407337776 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 114711245158774928, guid: e13ee7e0790c7d243b7aa67fe604acac,
type: 3}
m_CorrespondingSourceObject: {fileID: 114711245158774928, guid: e13ee7e0790c7d243b7aa67fe604acac, type: 3}
m_PrefabInstance: {fileID: 883453435}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
Expand Down Expand Up @@ -501,6 +506,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.15, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 126909665}
m_Father: {fileID: 0}
Expand Down Expand Up @@ -534,6 +540,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.0008588135, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1094516502}
m_Father: {fileID: 0}
Expand Down Expand Up @@ -657,6 +664,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1436819744}
m_Father: {fileID: 0}
Expand Down Expand Up @@ -711,7 +719,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
imageRetriever: {fileID: 859701131}
markerWidthMeters: 0.175
markerDictionary: 9
markerDictionary: 0
--- !u!4 &857114140
Transform:
m_ObjectHideFlags: 0
Expand All @@ -722,6 +730,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
Expand Down Expand Up @@ -766,6 +775,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.46380258, y: 0.45984256, z: 3.7793646}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
Expand Down Expand Up @@ -809,13 +819,11 @@ PrefabInstance:
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114711245158774928, guid: e13ee7e0790c7d243b7aa67fe604acac,
type: 3}
- target: {fileID: 114711245158774928, guid: e13ee7e0790c7d243b7aa67fe604acac, type: 3}
propertyPath: showarrig
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114711245158774928, guid: e13ee7e0790c7d243b7aa67fe604acac,
type: 3}
- target: {fileID: 114711245158774928, guid: e13ee7e0790c7d243b7aa67fe604acac, type: 3}
propertyPath: advancedPanelOpen
value: 1
objectReference: {fileID: 0}
Expand Down Expand Up @@ -850,6 +858,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0.1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 757982340}
m_RootOrder: 0
Expand All @@ -865,6 +874,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -971,6 +981,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -2.1, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 81208245}
m_Father: {fileID: 0}
Expand Down Expand Up @@ -1004,6 +1015,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 771887902}
m_RootOrder: 0
Expand Down Expand Up @@ -1145,6 +1157,7 @@ Transform:
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
Expand Down Expand Up @@ -1187,6 +1200,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -1240,6 +1254,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0.1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 98179969}
m_RootOrder: 0
Expand Down Expand Up @@ -1282,6 +1297,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -1335,6 +1351,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0.1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2101091372}
m_RootOrder: 0
Expand Down Expand Up @@ -1369,6 +1386,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
Expand Down Expand Up @@ -1401,6 +1419,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
Expand Down Expand Up @@ -1460,6 +1479,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.05, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2035212747}
m_Father: {fileID: 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ private void DeployGrabbedEvent(Camera cam, ref ZEDMat zedmat, VIEW view, ZEDMat
Mat buffermat = GetOpenCVBufferMat(zedCam.ImageHeight, zedCam.ImageWidth, SLMatType2CVMatType(mattype));

//copyToMat(zedmat.GetPtr(), cvMat);
MatUtils.copyFromMat(buffermat, zedmat.GetPtr());
//MatUtils.copyFromMat(buffermat, zedmat.GetPtr());
MatUtils.copyToMat(zedmat.GetPtr(), buffermat);

ConvertColorSpace(buffermat, ref cvMat, conversionatend);
//Mat convertedmat = ConvertColorSpace(buffermat, conversionatend);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ private void UpdateCurrentValues(sl.BODY_FORMAT pBodyFormat)
currentKeypointsCount = JointType_70_COUNT;
break;
default:
Debug.LogError("Error: Invalid BODY_MODEL! Please use either BODY_34, BODY_38 or BODY_70.");
Debug.LogError("Error: Invalid BODY_MODEL! Please use either BODY_34 or BODY_38.");
#if UNITY_EDITOR
EditorApplication.ExitPlaymode();
#else
Expand Down Expand Up @@ -1074,9 +1074,10 @@ public void InitSkeleton(int person_id, Material skBaseMat)
//sphere.layer = LayerMask.NameToLayer("tagInvisibleToZED");
sphere.GetComponent<Renderer>().material = skBaseMat;
skBaseMat.color = color;
sphere.transform.localScale = (BodyFormat == sl.BODY_FORMAT.BODY_70 && j >= JointType_70_LEFT_HAND_THUMB_1)
sphere.transform.localScale = (BodyFormat == sl.BODY_FORMAT.BODY_70 && j >= JointType_70_LEFT_HAND_THUMB_1)
? new Vector3(width, width, width)
: new Vector3(width * 2, width * 2, width * 2);
//sphere.transform.localScale = new Vector3(width * 2, width * 2, width * 2);
sphere.transform.parent = skeleton.transform;
sphere.name = currentSpheresList[j].ToString();
spheres[j] = sphere;
Expand Down Expand Up @@ -1119,10 +1120,11 @@ void UpdateSkeleton(Vector3 offsetSDK, bool mirrorMode = false)

bones[i].SetActive(true);
Vector3 offset = end - start;
// if hands, thinner cylinders
Vector3 scale = (BodyFormat == sl.BODY_FORMAT.BODY_70 && i >= 29 )
? new Vector3(width/2f, offset.magnitude / 2.0f, width/2f)
// if hands Body70, thinner cylinders
Vector3 scale = (BodyFormat == sl.BODY_FORMAT.BODY_70 && i >= 29)
? new Vector3(width / 2f, offset.magnitude / 2.0f, width / 2f)
: new Vector3(width, offset.magnitude / 2.0f, width);
//Vector3 scale = new Vector3(width, offset.magnitude / 2.0f, width);
Vector3 position = start + (offset / 2.0f);

bones[i].transform.position = position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ void Start()
zedManager = FindObjectOfType<ZEDManager>();
}

if(avatar.GetComponent<Animator>().runtimeAnimatorController == null)
{
Debug.LogWarning("Animator has no animator controller. Animation from ZED plugin will not work.");
}

if (zedManager)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ public bool LoadMesh(string meshFilePath = "ZEDMesh.obj")
zedCamera.DisableTracking();
Quaternion quat = Quaternion.identity; Vector3 tr = Vector3.zero;

if (zedCamera.EnableTracking(ref quat, ref tr, true, false, false, false, true, -1.0f, true, System.IO.File.Exists(basePath + ".area") ? basePath + ".area" : "") != sl.ERROR_CODE.SUCCESS)
if (zedCamera.EnableTracking(ref quat, ref tr, true, false, false, false, true, -1.0f, true, sl.POSTIONAL_TRACKING_MODE.STANDARD, System.IO.File.Exists(basePath + ".area") ? basePath + ".area" : "") != sl.ERROR_CODE.SUCCESS)
{
Debug.LogWarning(ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.TRACKING_NOT_INITIALIZED));
}
Expand Down
Loading

0 comments on commit 3c3d4a7

Please sign in to comment.