Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unity processing blocks #2164

Merged
merged 6 commits into from
Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions wrappers/csharp/Intel.RealSense/Processing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ public class FrameSource
internal FrameSource(HandleRef instance)
{
m_instance = instance;
}

public VideoFrame AllocateVideoFrame(StreamProfile profile, Frame original, int bpp, int width, int height, int stride, Extension extension = Extension.VideoFrame )
{
object error;
var fref = NativeMethods.rs2_allocate_synthetic_video_frame(m_instance.Handle, profile.m_instance.Handle, original.m_instance.Handle, bpp, width, height, stride, extension, out error);
return new VideoFrame(fref);
}

public FrameSet AllocateCompositeFrame(FramesReleaser releaser, params Frame[] frames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(RealSenseStreamTexture), true)]
[CustomEditor(typeof(RsStreamTextureRenderer), true)]
public class DefaultStreamPropertyDrawer : Editor
{
bool hasDefault = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(RealSenseDevice))]
public class RealSenseDeviceEditor : Editor
[CustomEditor(typeof(RsDevice))]
public class RsDeviceEditor : Editor
{
private SerializedProperty config;
private SerializedProperty mode;
Expand Down Expand Up @@ -39,7 +39,7 @@ public override void OnInspectorGUI()

// EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"), true);

var device = target as RealSenseDevice;
var device = target as RsDevice;
// bool isStreaming = device.ActiveProfile != null;
bool isStreaming = device.isActiveAndEnabled && device.ActiveProfile != null;

Expand All @@ -57,9 +57,9 @@ public override void OnInspectorGUI()

// EditorGUILayout.PropertyField(serializedObject.FindProperty("DeviceConfiguration"), true);

switch ((RealSenseConfiguration.Mode)mode.enumValueIndex)
switch ((RsConfiguration.Mode)mode.enumValueIndex)
{
case RealSenseConfiguration.Mode.Live:
case RsConfiguration.Mode.Live:
// EditorGUILayout.BeginHorizontal();
// var sn = config.FindPropertyRelative("RequestedSerialNumber");
// selectedSerial = EditorGUILayout.Popup(selectedSerial, names);
Expand All @@ -77,10 +77,13 @@ public override void OnInspectorGUI()

EditorGUILayout.Space();
EditorGUILayout.PropertyField(config.FindPropertyRelative("Profiles"), true);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(serializedObject.FindProperty("_processingPipe"), false);
EditorGUILayout.Space();
EditorGUI.EndDisabledGroup();
break;

case RealSenseConfiguration.Mode.Playback:
case RsConfiguration.Mode.Playback:
{
EditorGUI.BeginDisabledGroup(isStreaming);
EditorGUILayout.BeginHorizontal();
Expand All @@ -95,10 +98,11 @@ public override void OnInspectorGUI()
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
EditorGUILayout.PropertyField(serializedObject.FindProperty("_processingPipe"), false);
EditorGUILayout.Space();
EditorGUI.EndDisabledGroup();



if (isStreaming)
{
using (var playback = PlaybackDevice.FromDevice(device.ActiveProfile.Device))
Expand Down Expand Up @@ -163,7 +167,7 @@ public override void OnInspectorGUI()
}
break;

case RealSenseConfiguration.Mode.Record:
case RsConfiguration.Mode.Record:
{
EditorGUILayout.BeginHorizontal();
var prop = config.FindPropertyRelative("RecordPath");
Expand All @@ -180,6 +184,9 @@ public override void OnInspectorGUI()

EditorGUILayout.Space();
EditorGUILayout.PropertyField(config.FindPropertyRelative("Profiles"), true);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(serializedObject.FindProperty("_processingPipe"), false);
EditorGUILayout.Space();
EditorGUI.EndDisabledGroup();
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public static bool IsIntegersOnly(this Sensor.CameraOption opt)
}


[CustomEditor(typeof(RealSenseDeviceInspector))]
public class RealSenseDeviceInspectorEditor : Editor
[CustomEditor(typeof(RsDeviceInspector))]
public class RsDeviceInspectorEditor : Editor
{
public static void DrawHorizontal(string field, string value)
{
Expand All @@ -58,7 +58,7 @@ protected override bool ShouldHideOpenButton()

public override void OnInspectorGUI()
{
var deviceInspector = target as RealSenseDeviceInspector;
var deviceInspector = target as RsDeviceInspector;
if (!deviceInspector.streaming)
{
EditorGUILayout.HelpBox("Start streaming to see device settings", MessageType.Info);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public class NewPlayModeTest
[Category("Live")]
public IEnumerator TestLiveCamera()
{
var go = new GameObject("RealSenseDevice", typeof(RealSenseDevice));
var go = new GameObject("RealSenseDevice", typeof(RsDevice));
Assert.NotNull(go);
Assert.NotNull(go.GetComponent<RealSenseDevice>());
Assert.NotNull(go.GetComponent<RsDevice>());

var rs = RealSenseDevice.Instance;
var rs = RsDevice.Instance;
Assert.NotNull(rs);

bool started = false;
Expand All @@ -39,31 +39,31 @@ public IEnumerator TestLiveCamera()
GameObject.Destroy(go);
yield return null;
Assert.That(go == null);
Assert.IsNull(RealSenseDevice.Instance);
Assert.IsNull(RsDevice.Instance);
}

[UnityTest]
[Category("Live")]
public IEnumerator TestLiveDepthTexture()
{
var go = new GameObject("RealSenseDevice", typeof(RealSenseDevice));
var go = new GameObject("RealSenseDevice", typeof(RsDevice));

var depth_go = new GameObject("Depth");
var depth = depth_go.AddComponent<RealSenseStreamTexture>();
var depth = depth_go.AddComponent<RsStreamTextureRenderer>();

depth._stream = Stream.Depth;
depth._format = Format.Z16;

depth.textureBinding = new RealSenseStreamTexture.TextureEvent();
depth.textureBinding = new RsStreamTextureRenderer.TextureEvent();
Assert.IsNotNull(depth.textureBinding);

Texture depth_tex = null;
depth.textureBinding.AddListener(t => depth_tex = t);

yield return new WaitUntil(() => RealSenseDevice.Instance.Streaming);
yield return new WaitUntil(() => RsDevice.Instance.Streaming);
Assert.IsNotNull(depth_tex);

using (var depth_profile = RealSenseDevice.Instance.ActiveProfile.GetStream(Stream.Depth) as VideoStreamProfile)
using (var depth_profile = RsDevice.Instance.ActiveProfile.GetStream(Stream.Depth) as VideoStreamProfile)
{
Assert.AreEqual(depth_tex.width, depth_profile.Width);
Assert.AreEqual(depth_tex.height, depth_profile.Height);
Expand All @@ -78,8 +78,8 @@ public IEnumerator TestLiveDepthTexture()
[Category("Live")]
public IEnumerator TestDisabledNoStart()
{
var go = new GameObject("RealSenseDevice", typeof(RealSenseDevice));
var rs = RealSenseDevice.Instance;
var go = new GameObject("RealSenseDevice", typeof(RsDevice));
var rs = RsDevice.Instance;

rs.OnStop += Assert.Fail;
rs.OnStart += delegate
Expand All @@ -92,15 +92,15 @@ public IEnumerator TestDisabledNoStart()
GameObject.Destroy(go);
yield return null;
Assert.That(go == null);
Assert.IsNull(RealSenseDevice.Instance);
Assert.IsNull(RsDevice.Instance);
}

[UnityTest]
[Category("Live")]
public IEnumerator TestDisableStop()
{
var go = new GameObject("RealSenseDevice", typeof(RealSenseDevice));
var rs = RealSenseDevice.Instance;
var go = new GameObject("RealSenseDevice", typeof(RsDevice));
var rs = RsDevice.Instance;

bool started = false;
rs.OnStart += delegate
Expand Down Expand Up @@ -129,8 +129,8 @@ public IEnumerator TestDisableStop()
[Category("Live")]
public void TestExtrinsics()
{
var go = new GameObject("RealSenseDevice", typeof(RealSenseDevice));
var rs = RealSenseDevice.Instance;
var go = new GameObject("RealSenseDevice", typeof(RsDevice));
var rs = RsDevice.Instance;

var depth = rs.ActiveProfile.GetStream(Stream.Depth);
Assert.IsNotNull(depth);
Expand All @@ -149,13 +149,13 @@ public void TestExtrinsics()
[Category("Live"), Category("Record")]
public IEnumerator TestRecord()
{
var go = new GameObject("RealSenseDevice", typeof(RealSenseDevice));
var rs = RealSenseDevice.Instance;
var go = new GameObject("RealSenseDevice", typeof(RsDevice));
var rs = RsDevice.Instance;

go.SetActive(false);

rs.processMode = RealSenseDevice.ProcessMode.UnityThread;
rs.DeviceConfiguration.mode = RealSenseConfiguration.Mode.Record;
rs.processMode = RsDevice.ProcessMode.UnityThread;
rs.DeviceConfiguration.mode = RsConfiguration.Mode.Record;
var path = "D:/test.bag";
rs.DeviceConfiguration.RecordPath = path;

Expand Down Expand Up @@ -186,15 +186,15 @@ public IEnumerator TestPlayback()
var go = new GameObject("RealSenseDevice");
go.SetActive(false);

var rs = go.AddComponent<RealSenseDevice>();
var rs = go.AddComponent<RsDevice>();

Debug.Log(JsonUtility.ToJson(rs.DeviceConfiguration, true));

var path = "D:/test.bag";
var fi = new System.IO.FileInfo(path);
Assert.True(fi.Exists);
rs.DeviceConfiguration.PlaybackFile = path;
rs.DeviceConfiguration.mode = RealSenseConfiguration.Mode.Playback;
rs.DeviceConfiguration.mode = RsConfiguration.Mode.Playback;
rs.DeviceConfiguration.Profiles = null;

Debug.Log(JsonUtility.ToJson(rs.DeviceConfiguration, true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using System.Threading;
using UnityEngine;

public class RealSenseDeviceListener : MonoBehaviour
public class RsDeviceListener : MonoBehaviour
{
public static RealSenseDeviceListener Instance { get; private set; }
public static RsDeviceListener Instance { get; private set; }
private Context ctx;
private Pipeline pipeline;
readonly List<Device> m_added = new List<Device>();
Expand Down Expand Up @@ -39,9 +39,9 @@ void Update()
{
if (e.WaitOne(0))
{
var avail = FindObjectsOfType<RealSenseStreamAvailability>();
var avail = FindObjectsOfType<RsStreamAvailability>();
AutoResetEvent done = new AutoResetEvent(false);
Dictionary<RealSenseStreamAvailability, bool> resolvables = new Dictionary<RealSenseStreamAvailability, bool>();
Dictionary<RsStreamAvailability, bool> resolvables = new Dictionary<RsStreamAvailability, bool>();
int tasks = avail.Count();
foreach (var a in avail)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System;
using UnityEngine.Events;

public class RealSenseStreamAvailability : MonoBehaviour
public class RsStreamAvailability : MonoBehaviour
{
public RealSenseConfiguration DeviceConfiguration;
public RsConfiguration DeviceConfiguration;

[Space]
public UnityEvent OnDeviceAvailable;
Expand Down
32 changes: 15 additions & 17 deletions wrappers/unity/Assets/RealSenseSDK2.0/Prefabs/PointCloud.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,45 @@ Prefab:
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1749190083057562}
m_RootGameObject: {fileID: 1308323762867094}
m_IsPrefabParent: 1
--- !u!1 &1749190083057562
--- !u!1 &1308323762867094
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4810509327237356}
- component: {fileID: 33048205770214360}
- component: {fileID: 23076220388684884}
- component: {fileID: 114128454867765796}
- component: {fileID: 4093320342193112}
- component: {fileID: 33879412422067796}
- component: {fileID: 23213942756892742}
- component: {fileID: 114148710568042142}
m_Layer: 0
m_Name: PointCloud
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4810509327237356
--- !u!4 &4093320342193112
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1749190083057562}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_GameObject: {fileID: 1308323762867094}
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_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &23076220388684884
--- !u!23 &23213942756892742
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1749190083057562}
m_GameObject: {fileID: 1308323762867094}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
Expand Down Expand Up @@ -77,23 +77,21 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &33048205770214360
--- !u!33 &33879412422067796
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1749190083057562}
m_GameObject: {fileID: 1308323762867094}
m_Mesh: {fileID: 0}
--- !u!114 &114128454867765796
--- !u!114 &114148710568042142
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1749190083057562}
m_GameObject: {fileID: 1308323762867094}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 701924db2ae3d894aafb2d751551e249, type: 3}
m_Name:
m_EditorClassIdentifier:
stream: 1
DebugDrawing: 1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading