Skip to content
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ sysinfo.txt
*.apk
*.unitypackage

ZEDCamera/Assets/XR/
ZEDCamera/Assets/XRI/
ZEDCamera/Assets/StreamingAssets/
ZEDCamera/Assets/OpenCVForUnity/
ZEDCamera/Assets/SteamVR/
ZEDCamera/Assets/Oculus/
ZEDCamera/Assets/Benjamin
Expand Down
5 changes: 4 additions & 1 deletion ZEDCamera/Assets/Editor/Scripts/ZEDPluginInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ static void UpdateWnd()

if (!sl.ZEDCamera.CheckPlugin())
{
errorMessage = ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.SDK_DEPENDENCIES_ISSUE);
if (sl.ZEDSDKVersionValidator.ValidationComplete && !sl.ZEDSDKVersionValidator.IsSDKCompatible)
errorMessage = ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.SDK_VERSION_MISMATCH);
else
errorMessage = ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.SDK_DEPENDENCIES_ISSUE);
showErrorMode = true;
window = GetWindow<ZEDPluginInspector>(true);
window.maxSize = new Vector2(400, 600);
Expand Down
2 changes: 1 addition & 1 deletion ZEDCamera/Assets/Prefabs/ZED_Rig_Mono.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ MonoBehaviour:
cameraID: 0
depthMode: 5
inputType: 0
resolution: 9
resolution: 11
FPS: -1
serialNumber: 0
svoInputFileName: Assets/Recording.svo
Expand Down
2 changes: 1 addition & 1 deletion ZEDCamera/Assets/Prefabs/ZED_Rig_Stereo.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ MonoBehaviour:
cameraID: 0
depthMode: 5
inputType: 0
resolution: 9
resolution: 11
FPS: -1
serialNumber: 0
svoInputFileName:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static void Blur(RenderTexture source, RenderTexture dest, Material mat,
return;
}

RenderTexture buffer = RenderTexture.GetTemporary(source.width / downscale, source.height / downscale, source.depth, source.format, RenderTextureReadWrite.Default);
RenderTexture buffer = RenderTexture.GetTemporary(source.width / downscale, source.height / downscale, 0, source.format, RenderTextureReadWrite.Default);

if (mat == null)
{
Expand All @@ -111,7 +111,7 @@ public static void Blur(RenderTexture source, RenderTexture dest, Material mat,
bool oddEven = false;

//Create two buffers to make a multi-pass blur.
RenderTexture buffer2 = RenderTexture.GetTemporary(source.width / downscale, source.height / downscale, source.depth, source.format, RenderTextureReadWrite.Default);
RenderTexture buffer2 = RenderTexture.GetTemporary(source.width / downscale, source.height / downscale, 0, source.format, RenderTextureReadWrite.Default);


Graphics.Blit(source, buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ private void SetForward()

if (mask == null || !mask.IsCreated())
{
mask = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.R8);
mask = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.RHalf);
}

//Set up the post-processing material.
Expand Down Expand Up @@ -824,7 +824,7 @@ private void SetDeferred()

if (mask == null || !mask.IsCreated())
{
mask = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.R8);
mask = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.RHalf);
}
//Set the post process buffer
postProcessBuffer[(int)ZED_RENDERING_MODE.DEFERRED] = new CommandBuffer();
Expand Down Expand Up @@ -1408,14 +1408,16 @@ private void OnRenderImage(RenderTexture source, RenderTexture destination)
Graphics.Blit(buffer, mask, matComposeMask);

ApplyPostProcess(source, destination, bluredMask);

RenderTexture.ReleaseTemporary(buffer);
RenderTexture.ReleaseTemporary(bluredMask);
}
else //Forward path.
{
RenderTexture bluredMask = RenderTexture.GetTemporary(mask.width, mask.height, mask.depth, mask.format);

ApplyPostProcess(source, destination, bluredMask);

RenderTexture.ReleaseTemporary(bluredMask);
}
}
Expand All @@ -1434,7 +1436,7 @@ private void OnRenderImage(RenderTexture source, RenderTexture destination)
/// <param name="bluredMask">Mask used to apply blurring effects.</param>
private void ApplyPostProcess(RenderTexture source, RenderTexture destination, RenderTexture bluredMask)
{
RenderTexture tempDestination = RenderTexture.GetTemporary(source.width, source.height, source.depth, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
RenderTexture tempDestination = RenderTexture.GetTemporary(source.width, source.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);

Graphics.Blit(source, tempDestination, postprocessMaterial);
ZEDPostProcessingTools.Blur(mask, bluredMask, blurMaterial, 3, 1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class ZEDMixedRealityPlugin : MonoBehaviour
{
#region DLL Calls
const string nameDll = sl.ZEDCommon.NameDLL;
const string nameDll = sl.ZEDCommon.NameDLLUnity;
[DllImport(nameDll, EntryPoint = "sl_compute_size_plane_with_gamma")]
private static extern System.IntPtr dllz_compute_size_plane_with_gamma(int width, int height, float perceptionDistance, float eyeToZedDistance, float planeDistance, float HMDFocal, float zedFocal);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public DetectedBody(BodyData bdata, ZEDManager viewingmanager, Vector3 campos, Q
camPositionAtDetection = campos;
camRotationAtDetection = camrot;

maskMat = new ZEDMat(bdata.mask);
//maskTexture = ZEDMatToTexture_CPU(maskMat);
if (bdata.mask != IntPtr.Zero)
maskMat = new ZEDMat(bdata.mask);

}

Expand Down Expand Up @@ -290,6 +290,12 @@ public Vector3[] Get3DWorldCorners()
/// <returns>True if texture was successfully retrieved; false otherwise.</returns>
public bool GetMaskTexture(out Texture2D masktex, bool fliponYaxis)
{
if (maskMat == null)
{
masktex = null;
return false;
}

if (!fliponYaxis)
{
if (maskTexture == null)
Expand Down Expand Up @@ -398,7 +404,7 @@ private static Texture2D ZEDMatToTexture_CPU(sl.ZEDMat zedmat, bool flipYcoords
}
else
{
Debug.LogError("Pointer to texture was null - returning null.");
Debug.LogWarning("ZEDMat mask data not available - returning null.");
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public DetectedObject(ObjectData odata, ZEDManager viewingmanager, Vector3 campo
camPositionAtDetection = campos;
camRotationAtDetection = camrot;

maskMat = new ZEDMat(odata.mask);
//maskTexture = ZEDMatToTexture_CPU(maskMat);
if (odata.mask != IntPtr.Zero)
maskMat = new ZEDMat(odata.mask);

}

Expand Down Expand Up @@ -312,12 +312,18 @@ public Vector3[] Get3DWorldCorners()
/// <returns>True if texture was successfully retrieved; false otherwise.</returns>
public bool GetMaskTexture(out Texture2D masktex, bool fliponYaxis)
{
if (maskMat == null)
{
masktex = null;
return false;
}

if (!fliponYaxis)
{
if (maskTexture == null)
{
IntPtr maskpointer = maskMat.GetPtr(sl.ZEDMat.MEM.MEM_CPU);

if (maskpointer != IntPtr.Zero)
{
maskTexture = ZEDMatToTexture_CPU(maskMat, false);
Expand Down Expand Up @@ -386,9 +392,10 @@ private static Texture2D ZEDMatToTexture_CPU(sl.ZEDMat zedmat, bool flipYcoords
int height = zedmat.GetHeight();

IntPtr maskpointer = zedmat.GetPtr(sl.ZEDMat.MEM.MEM_CPU);
if (maskpointer != IntPtr.Zero && zedmat.IsInit() && width > 0 && height > 0)
int stepBytes = zedmat.GetStepBytes();
if (maskpointer != IntPtr.Zero && zedmat.IsInit() && width > 0 && height > 0 && stepBytes > 0)
{
byte[] texbytes = new byte[zedmat.GetStepBytes() * height];
byte[] texbytes = new byte[stepBytes * height];
System.Runtime.InteropServices.Marshal.Copy(maskpointer, texbytes, 0, texbytes.Length);

if (flipYcoords)
Expand All @@ -412,7 +419,7 @@ private static Texture2D ZEDMatToTexture_CPU(sl.ZEDMat zedmat, bool flipYcoords
}
else
{
//Debug.LogError("Pointer to texture was null - returning null.");
Debug.LogWarning("ZEDMat mask data not available - returning null.");
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,23 @@ 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, sl.POSITIONAL_TRACKING_MODE.GEN_1, false, false, System.IO.File.Exists(basePath + ".area") ? basePath + ".area" : "") != sl.ERROR_CODE.SUCCESS)
sl.PositionalTrackingParameters positionalTrackingParameters = new sl.PositionalTrackingParameters()
{
enableIMUFusion = true,
enableAreaMemory = true,
mode = sl.POSITIONAL_TRACKING_MODE.GEN_1,
InitialWorldPosition = tr,
InitialWorldRotation = quat,
enablePoseSmoothing = false,
setFloorAsOrigin = false,
setAsStatic = false,
depthMinRange = -1.0f,
setGravityAsOrigin = true,
enableLocalizationOnly = false,
enable2DGroundMode = false
};

if (zedCamera.EnableTracking(ref positionalTrackingParameters, System.IO.File.Exists(basePath + ".area") ? basePath + ".area" : "") != sl.ERROR_CODE.SUCCESS)
{
Debug.LogWarning(ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.TRACKING_NOT_INITIALIZED));
}
Expand Down
14 changes: 10 additions & 4 deletions ZEDCamera/Assets/SDK/Helpers/Scripts/Utilities/GUIMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ private void Awake()

if (!sl.ZEDCamera.CheckPlugin())
{
textmono.text = ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.SDK_NOT_INSTALLED);
if (sl.ZEDSDKVersionValidator.ValidationComplete && !sl.ZEDSDKVersionValidator.IsSDKCompatible)
textmono.text = ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.SDK_VERSION_MISMATCH);
else
textmono.text = ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.SDK_NOT_INSTALLED);
}
imagemono = warningmono.transform.GetChild(0).GetChild(1).gameObject;
imagemono.transform.parent.gameObject.SetActive(true);
Expand Down Expand Up @@ -149,10 +152,13 @@ private void Awake()
imageright = warningright.transform.GetChild(0).GetChild(1).gameObject;
imageright.transform.parent.gameObject.SetActive(true);

if (!sl.ZEDCamera.CheckPlugin()) //Warn the use there's no SDK installed.
if (!sl.ZEDCamera.CheckPlugin())
{
textleft.text = ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.SDK_NOT_INSTALLED);
textright.text = ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.SDK_NOT_INSTALLED);
var err = (sl.ZEDSDKVersionValidator.ValidationComplete && !sl.ZEDSDKVersionValidator.IsSDKCompatible)
? ZEDLogMessage.ERROR.SDK_VERSION_MISMATCH
: ZEDLogMessage.ERROR.SDK_NOT_INSTALLED;
textleft.text = ZEDLogMessage.Error2Str(err);
textright.text = ZEDLogMessage.Error2Str(err);
}

ready = false;
Expand Down
Loading