Skip to content

Commit

Permalink
4.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Bvallon-sl committed Oct 3, 2023
1 parent 7797605 commit 1239d08
Show file tree
Hide file tree
Showing 4 changed files with 777 additions and 139 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This package lets you use the ZED stereo camera in C#. The C# API is a wrapper a
- Visual Studio 2017 with C# extensions
- Cmake 3.23 at least
- [C wrapper](https://github.com/stereolabs/zed-c-api) of the ZED SDK
- [ZED SDK **4.0.5**](https://www.stereolabs.com/developers/release/) and its dependency ([CUDA](https://developer.nvidia.com/cuda-downloads))
- [ZED SDK **4.0.6**](https://www.stereolabs.com/developers/release/) and its dependency ([CUDA](https://developer.nvidia.com/cuda-downloads))

## From NuGet

Expand Down
32 changes: 24 additions & 8 deletions Stereolabs.zed/src/ZEDCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public bool IsCameraReady
private static extern IntPtr dllz_find_floor_plane(int cameraID, out Quaternion rotation, out Vector3 translation, Quaternion priorQuaternion, Vector3 priorTranslation);

[DllImport(nameDll, EntryPoint = "sl_find_plane_at_hit")]
private static extern IntPtr dllz_find_plane_at_hit(int cameraID, Vector2 HitPixel, bool refine);
private static extern IntPtr dllz_find_plane_at_hit(int cameraID, Vector2 HitPixel, ref sl_PlaneDetectionParameters plane_params, bool refine);

[DllImport(nameDll, EntryPoint = "sl_convert_floorplane_to_mesh")]
private static extern int dllz_convert_floorplane_to_mesh(int cameraID, [In, Out] Vector3[] vertices, int[] triangles, out int numVertices, out int numTriangles);
Expand Down Expand Up @@ -780,7 +780,6 @@ struct sl_initParameters
/// </summary>
public float grabComputeCappingFPS;


/// <summary>
/// Copy constructor.
/// </summary>
Expand Down Expand Up @@ -902,6 +901,16 @@ struct sl_SpatialMappingParameters
public int stabilityCounter;
};

/// <summary>
/// DLL-friendly version of PlaneDetectionParameters (found in ZEDCommon.cs).
/// </summary>
[StructLayout(LayoutKind.Sequential)]
struct sl_PlaneDetectionParameters
{
public float maxDistanceThreshold;
public float normalSimilarityThreshold;
};

/// <summary>
/// Checks if the ZED camera is plugged in and opens it.
/// </summary>
Expand Down Expand Up @@ -1042,7 +1051,6 @@ public InitParameters GetInitParameters()
openTimeoutSec = sl_parameters.openTimeoutSec,
asyncGrabCameraRecovery = sl_parameters.asyncGrabCameraRecovery,
grabComputeCappingFPS = sl_parameters.grabComputeCappingFPS

};
return parameters;
}
Expand Down Expand Up @@ -1726,7 +1734,7 @@ public ERROR_CODE GetSensorsData(ref SensorsData data, TIME_REFERENCE referenceT
/// <summary>
/// Defines a region of interest to focus on for all the SDK, discarding other parts.
/// </summary>
/// <param name="roiMask">the Mat defining the requested region of interest, all pixel set to 0 will be discard. If empty, set all pixels as valid, otherwise should fit the resolution of the current instance and its type should be U8_C1.</param>
/// <param name="roiMask">the Mat defining the requested region of interest, pixels lower than 127 will be discard. If empty, set all pixels as valid, otherwise should fit the resolution of the current instance and its type should be U8_C1/C3/C4.</param>
/// <returns></returns>
public ERROR_CODE SetRegionOfInterest(sl.Mat roiMask)
{
Expand Down Expand Up @@ -2273,13 +2281,17 @@ public int ConvertFloorPlaneToMesh(Vector3[] vertices, int[] triangles, out int
/// <param name="screenPos">Point on the ZED image to check for a plane.</param>
/// <returns></returns>
[Obsolete("This Method is Deprecated, use FindPlaneAtHit instead", false)]
public sl.ERROR_CODE findPlaneAtHit(ref PlaneData plane, Vector2 coord)
public sl.ERROR_CODE findPlaneAtHit(ref PlaneData plane, Vector2 coord, ref PlaneDetectionParameters planeDetectionParameters)
{
IntPtr p = IntPtr.Zero;
Quaternion out_quat = Quaternion.Identity;
Vector3 out_trans = Vector3.Zero;

p = dllz_find_plane_at_hit(CameraID, coord, false);
sl_PlaneDetectionParameters plane_params = new sl_PlaneDetectionParameters();
plane_params.maxDistanceThreshold = planeDetectionParameters.maxDistanceThreshold;
plane_params.normalSimilarityThreshold= planeDetectionParameters.normalSimilarityThreshold;

p = dllz_find_plane_at_hit(CameraID, coord, ref plane_params, false);
plane.Bounds = new Vector3[256];

if (p != IntPtr.Zero)
Expand All @@ -2297,13 +2309,17 @@ public sl.ERROR_CODE findPlaneAtHit(ref PlaneData plane, Vector2 coord)
/// <param name="plane">Data on the detected plane.</param>
/// <param name="screenPos">Point on the ZED image to check for a plane.</param>
/// <returns></returns>
public sl.ERROR_CODE FindPlaneAtHit(ref PlaneData plane, Vector2 coord)
public sl.ERROR_CODE FindPlaneAtHit(ref PlaneData plane, Vector2 coord, ref PlaneDetectionParameters planeDetectionParameters)
{
IntPtr p = IntPtr.Zero;
Quaternion out_quat = Quaternion.Identity;
Vector3 out_trans = Vector3.Zero;

p = dllz_find_plane_at_hit(CameraID, coord, false);
sl_PlaneDetectionParameters plane_params = new sl_PlaneDetectionParameters();
plane_params.maxDistanceThreshold = planeDetectionParameters.maxDistanceThreshold;
plane_params.normalSimilarityThreshold = planeDetectionParameters.normalSimilarityThreshold;

p = dllz_find_plane_at_hit(CameraID, coord, ref plane_params, false);
plane.Bounds = new Vector3[256];

if (p != IntPtr.Zero)
Expand Down
Loading

0 comments on commit 1239d08

Please sign in to comment.