Skip to content

Commit

Permalink
Merge pull request #13 from keijiro/rssdk-2.20
Browse files Browse the repository at this point in the history
Rssdk 2.20
  • Loading branch information
keijiro committed Apr 17, 2019
2 parents e8466ac + 316b07b commit d9ec503
Show file tree
Hide file tree
Showing 23 changed files with 316 additions and 101 deletions.
39 changes: 36 additions & 3 deletions Assets/RealSenseSDK2.0/Editor/RsDeviceInspectorEditor.cs
Expand Up @@ -5,7 +5,7 @@
using Intel.RealSense;
using System;
using System.Linq;

using System.IO;

public static class CameraOptionExtensions
{
Expand Down Expand Up @@ -66,13 +66,44 @@ public override void OnInspectorGUI()
return;
}

var dev = deviceInspector.device;

EditorGUILayout.Space();
var devName = deviceInspector.device.Info[CameraInfo.Name];
var devSerial = deviceInspector.device.Info[CameraInfo.SerialNumber];
var devName = dev.Info[CameraInfo.Name];
var devSerial = dev.Info[CameraInfo.SerialNumber];
DrawHorizontal("Device", devName);
DrawHorizontal("Device S/N", devSerial);
EditorGUILayout.Space();

if (dev.Info.Supports(CameraInfo.AdvancedMode))
{
var adv = dev.As<AdvancedDevice>();
if (adv.AdvancedModeEnabled)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Preset", GUILayout.Width(EditorGUIUtility.labelWidth - 4));
if (GUILayout.Button("Load", GUILayout.ExpandWidth(true)))
{
var path = EditorUtility.OpenFilePanel("Load Preset", "", "JSON");
if (path.Length != 0)
{
adv.JsonConfiguration = File.ReadAllText(path);
cachedValue.Clear();
EditorUtility.SetDirty(target);
}
}
if (GUILayout.Button("Save", GUILayout.ExpandWidth(true)))
{
var path = EditorUtility.SaveFilePanel("Save Preset", "", "preset", "JSON");
if (path.Length != 0)
{
File.WriteAllText(path, adv.JsonConfiguration);
}
}
EditorGUILayout.EndHorizontal();
}
}

foreach (var kvp in deviceInspector.sensors)
{
string sensorName = kvp.Key;
Expand Down Expand Up @@ -100,7 +131,9 @@ void DrawOption(Sensor sensor, IOption opt)
if (opt.ReadOnly)
{
EditorGUILayout.BeginHorizontal();
GUI.enabled = false;
EditorGUILayout.LabelField(k, GUILayout.Width(EditorGUIUtility.labelWidth - 4));
GUI.enabled = true;
EditorGUILayout.SelectableLabel(v.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
EditorGUILayout.EndHorizontal();
}
Expand Down
Binary file modified Assets/RealSenseSDK2.0/Plugins/Intel.RealSense.dll 100644 → 100755
Binary file not shown.
Binary file modified Assets/RealSenseSDK2.0/Plugins/librealsense2.so
Binary file not shown.
84 changes: 84 additions & 0 deletions Assets/RealSenseSDK2.0/Plugins/realsense2.bundle.meta

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

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

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

Binary file not shown.

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

Binary file modified Assets/RealSenseSDK2.0/Plugins/realsense2.dll
Binary file not shown.
@@ -0,0 +1,62 @@
using Intel.RealSense;
using UnityEngine;

[ProcessingBlockDataAttribute(typeof(ThresholdFilter))]
[HelpURL("https://github.com/IntelRealSense/librealsense/blob/master/doc/post-processing-filters.md#hole-filling-filter")]
public class RsThresholdFilter : RsProcessingBlock
{
/// <summary>
/// Min range in meters
/// </summary>
[Range(0f, 16f)]
public float MinDistance = 0.1f;

/// <summary>
/// Max range in meters
/// </summary>
[Range(0f, 16f)]
public float MaxDistance = 4f;

private ThresholdFilter _pb;

private IOption minOption;
private IOption maxOption;

public void Init()
{
_pb = new ThresholdFilter();
minOption = _pb.Options[Option.MinDistance];
maxOption = _pb.Options[Option.MaxDistance];
}

void OnDisable()
{
if (_pb != null)
_pb.Dispose();
}

public override Frame Process(Frame frame, FrameSource frameSource)
{
if (_pb == null)
{
Init();
}

UpdateOptions();

return _pb.Process(frame);
}

public void SetMinDistance(float v) {
MinDistance = v;
}
public void SetMaxDistance(float v) {
MaxDistance = v;
}

private void UpdateOptions()
{
minOption.Value = MinDistance;
maxOption.Value = MaxDistance;
}
}

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

40 changes: 19 additions & 21 deletions Assets/RealSenseSDK2.0/Scripts/RsDevice.cs
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Threading;
using UnityEngine;
using Intel.RealSense;
Expand Down Expand Up @@ -73,8 +70,7 @@ void OnEnable()
using (var cfg = DeviceConfiguration.ToPipelineConfig())
ActiveProfile = m_pipeline.Start(cfg);

using (var activeStreams = ActiveProfile.Streams)
DeviceConfiguration.Profiles = activeStreams.Select(RsVideoStreamRequest.FromProfile).ToArray();
DeviceConfiguration.Profiles = ActiveProfile.Streams.Select(RsVideoStreamRequest.FromProfile).ToArray();

if (processMode == ProcessMode.Multithread)
{
Expand Down Expand Up @@ -109,33 +105,39 @@ void OnDisable()
if (Streaming && OnStop != null)
OnStop();

if (ActiveProfile != null)
{
ActiveProfile.Dispose();
ActiveProfile = null;
}

if (m_pipeline != null)
{
// if (Streaming)
// m_pipeline.Stop();
// m_pipeline.Stop();
m_pipeline.Dispose();
m_pipeline = null;
}

Streaming = false;

if (ActiveProfile != null)
{
ActiveProfile.Dispose();
ActiveProfile = null;
}
}

void OnDestroy()
{
// OnStart = null;
OnStop = null;

if (ActiveProfile != null)
{
ActiveProfile.Dispose();
ActiveProfile = null;
}

if (m_pipeline != null)
{
m_pipeline.Dispose();
m_pipeline = null;

// Instance = null;
m_pipeline = null;
}
}

private void RaiseSampleEvent(Frame frame)
Expand All @@ -155,8 +157,7 @@ private void WaitForFrames()
while (!stopEvent.WaitOne(0))
{
using (var frames = m_pipeline.WaitForFrames())
using (var frame = frames.AsFrame())
RaiseSampleEvent(frame);
RaiseSampleEvent(frames);
}
}

Expand All @@ -172,10 +173,7 @@ void Update()
if (m_pipeline.PollForFrames(out frames))
{
using (frames)
using (var frame = frames.AsFrame())
{
RaiseSampleEvent(frame);
}
RaiseSampleEvent(frames);
}
}

Expand Down

0 comments on commit d9ec503

Please sign in to comment.