Skip to content

Commit 4e27234

Browse files
committed
update to 4.1
1 parent f37dc6e commit 4e27234

3 files changed

Lines changed: 575 additions & 201 deletions

File tree

Stereolabs.zed/src/ZEDCamera.cs

Lines changed: 114 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,23 @@ public bool IsCameraReady
279279
[DllImport(nameDll, EntryPoint = "sl_pause_recording")]
280280
private static extern void dllz_pause_recording(int cameraID, bool status);
281281

282+
// Recording Gen 2 functions
283+
284+
[DllImport(nameDll, EntryPoint = "sl_ingest_data_into_svo")]
285+
private static extern ERROR_CODE dllz_ingest_data_into_svo(int cameraID, ref SVOData data);
286+
287+
[DllImport(nameDll, EntryPoint = "sl_get_svo_data_size")]
288+
private static extern int dllz_get_svo_data_size(int cameraID, string key, ulong ts_begin, ulong ts_end);
289+
290+
[DllImport(nameDll, EntryPoint = "sl_retrieve_svo_data")]
291+
private static extern ERROR_CODE dllz_retrieve_svo_data(int cameraID, string key, int nb_data, [Out] SVOData[] data, ulong ts_begin, ulong ts_end);
292+
293+
[DllImport(nameDll, EntryPoint = "sl_get_svo_data_size")]
294+
private static extern int dllz_get_svo_data_keys_size(int cameraID);
295+
296+
[DllImport(nameDll, EntryPoint = "sl_get_svo_data_keys")]
297+
private static extern void dllz_get_svo_data_keys(int cameraID, int nb_keys, [Out] string[] keys);
298+
282299
/*
283300
* Camera control functions.
284301
*/
@@ -414,6 +431,9 @@ public bool IsCameraReady
414431
[DllImport(nameDll, EntryPoint = "sl_get_position")]
415432
private static extern int dllz_get_position(int cameraID, ref Quaternion quat, ref Vector3 vec, int reference_frame);
416433

434+
[DllImport(nameDll, EntryPoint = "sl_get_positional_tracking_status")]
435+
private static extern IntPtr dllz_get_positional_tracking_status(int cameraID);
436+
417437
[DllImport(nameDll, EntryPoint = "sl_get_position_at_target_frame")]
418438
private static extern int dllz_get_position_at_target_frame(int cameraID, ref Quaternion quaternion, ref Vector3 translation, ref Quaternion targetQuaternion, ref Vector3 targetTranslation, int reference_frame);
419439

@@ -436,10 +456,10 @@ public bool IsCameraReady
436456
private static extern int dllz_get_area_export_state(int cameraID);
437457

438458
[DllImport(nameDll, EntryPoint = "sl_set_region_of_interest")]
439-
private static extern int dllz_sl_set_region_of_interest(int cameraID, IntPtr roiMask);
459+
private static extern int dllz_set_region_of_interest(int cameraID, IntPtr roiMask, bool[] module);
440460

441461
[DllImport(nameDll, EntryPoint = "sl_get_region_of_interest")]
442-
private static extern int dllz_get_region_of_interest(int cameraID, IntPtr roiMask, int width, int height);
462+
private static extern int dllz_get_region_of_interest(int cameraID, IntPtr roiMask, int width, int height, MODULE module);
443463

444464
[DllImport(nameDll, EntryPoint = "sl_start_region_of_interest_auto_detection")]
445465
private static extern int dllz_start_region_of_interest_auto_detection(int cameraID, ref RegionOfInterestParameters roiParams);
@@ -554,9 +574,6 @@ public bool IsCameraReady
554574
[DllImport(nameDll, EntryPoint = "sl_get_body_tracking_parameters")]
555575
private static extern IntPtr dllz_get_body_tracking_parameters(int cameraID);
556576

557-
[DllImport(nameDll, EntryPoint = "sl_pause_body_tracking")]
558-
private static extern IntPtr dllz_pause_body_tracking(int cameraID, bool status, uint instanceID);
559-
560577
[DllImport(nameDll, EntryPoint = "sl_disable_body_tracking")]
561578
private static extern IntPtr dllz_disable_body_tracking(int cameraID, uint instanceID, bool forceDisableAllInstances);
562579

@@ -575,9 +592,6 @@ public bool IsCameraReady
575592
[DllImport(nameDll, EntryPoint = "sl_disable_object_detection")]
576593
private static extern void dllz_disable_object_detection(int cameraID, uint instanceID, bool forceDisableAllInstances);
577594

578-
[DllImport(nameDll, EntryPoint = "sl_pause_object_detection")]
579-
private static extern void dllz_pause_object_detection(int cameraID, bool status, uint instanceID);
580-
581595
[DllImport(nameDll, EntryPoint = "sl_ingest_custom_box_objects")]
582596
private static extern int dllz_ingest_custom_box_objects(int cameraID, int nb_objects, CustomBoxObjectData[] objects_in);
583597

@@ -1540,8 +1554,9 @@ public static void GetSDKVersion(ref int major, ref int minor, ref int patch)
15401554
}
15411555
}
15421556

1557+
15431558
/// <summary>
1544-
/// List all the streaming devices with their associated information.
1559+
/// List all the connected devices with their associated information.
15451560
///
15461561
/// This method lists all the cameras available and provides their serial number, models and other information.
15471562
/// </summary>
@@ -1555,7 +1570,7 @@ public static sl.DeviceProperties[] GetDeviceList(out int nbDevices)
15551570
}
15561571

15571572
/// <summary>
1558-
/// List all the connected devices with their associated information.
1573+
/// List all the streaming devices with their associated information.
15591574
///
15601575
/// This method lists all the cameras available and provides their serial number, models and other information.
15611576
/// </summary>
@@ -1787,6 +1802,22 @@ public POSITIONAL_TRACKING_STATE GetPosition(ref Quaternion rotation, ref Vector
17871802
return (POSITIONAL_TRACKING_STATE)dllz_get_position(CameraID, ref rotation, ref position, (int)referenceType);
17881803
}
17891804

1805+
/// <summary>
1806+
/// Returns the current status of positional tracking module.
1807+
/// </summary>
1808+
/// <returns> The current status of positional tracking module. </returns>
1809+
public PositionalTrackingStatus GetPositionalTrackingStatus()
1810+
{
1811+
IntPtr p = dllz_get_positional_tracking_status(CameraID);
1812+
if (p == IntPtr.Zero)
1813+
{
1814+
return new PositionalTrackingStatus();
1815+
}
1816+
1817+
PositionalTrackingStatus positionalTrackingStatus = (PositionalTrackingStatus)Marshal.PtrToStructure(p, typeof(PositionalTrackingStatus));
1818+
return positionalTrackingStatus;
1819+
}
1820+
17901821
/// <summary>
17911822
/// Gets the current position of the camera and state of the tracking, with an optional offset to the tracking frame.
17921823
/// </summary>
@@ -1855,9 +1886,7 @@ public POSITIONAL_TRACKING_STATE GetPosition(ref Pose pose, REFERENCE_FRAME refe
18551886
/// <param name="rotation">Prior rotation.</param>
18561887
public ERROR_CODE SetIMUOrientationPrior(ref Quaternion rotation)
18571888
{
1858-
sl.ERROR_CODE trackingStatus = sl.ERROR_CODE.CAMERA_NOT_DETECTED;
1859-
trackingStatus = (sl.ERROR_CODE)dllz_set_imu_prior_orientation(CameraID, rotation);
1860-
return trackingStatus;
1889+
return (sl.ERROR_CODE)dllz_set_imu_prior_orientation(CameraID, rotation);
18611890
}
18621891

18631892
/// <summary>
@@ -1868,9 +1897,7 @@ public ERROR_CODE SetIMUOrientationPrior(ref Quaternion rotation)
18681897
/// <param name="rotation">Rotation from the IMU.</param>
18691898
public ERROR_CODE GetIMUOrientation(ref Quaternion rotation, TIME_REFERENCE referenceTime = TIME_REFERENCE.IMAGE)
18701899
{
1871-
sl.ERROR_CODE err = sl.ERROR_CODE.CAMERA_NOT_DETECTED;
1872-
err = (sl.ERROR_CODE)dllz_get_internal_imu_orientation(CameraID, ref rotation, (int)referenceTime);
1873-
return err;
1900+
return (sl.ERROR_CODE)dllz_get_internal_imu_orientation(CameraID, ref rotation, (int)referenceTime);
18741901
}
18751902

18761903
/// <summary>
@@ -1882,39 +1909,36 @@ public ERROR_CODE GetIMUOrientation(ref Quaternion rotation, TIME_REFERENCE refe
18821909
/// <returns>An sl.ERROR_CODE status.</returns>
18831910
public ERROR_CODE GetSensorsData(ref SensorsData data, TIME_REFERENCE referenceTime = TIME_REFERENCE.IMAGE)
18841911
{
1885-
sl.ERROR_CODE err = sl.ERROR_CODE.CAMERA_NOT_DETECTED;
1886-
err = (sl.ERROR_CODE)dllz_get_internal_sensors_data(CameraID, ref data, (int)referenceTime);
1887-
return err;
1912+
return (sl.ERROR_CODE)dllz_get_internal_sensors_data(CameraID, ref data, (int)referenceTime);
18881913
}
18891914

18901915
/// <summary>
18911916
/// Defines a region of interest to focus on for all the SDK, discarding other parts.
18921917
/// </summary>
1893-
/// <param name="roiMask">
1918+
/// <param name="roiMask"> The Mat defining the requested region of interest, pixels lower than 127 will be discarded from all modules: depth, positional tracking, etc.
1919+
/// If empty, set all pixels as valid. The mask can be either at lower or higher resolution than the current images.</param>
1920+
/// <param name="module"> Apply the ROI to a list of SDK module, all by default. Must of size sl.MODULE.LAST.
18941921
/// The Mat defining the requested region of interest, pixels lower than 127 will be discarded from all modules: depth, positional tracking, etc.
18951922
/// If empty, set all pixels as valid. The mask can be either at lower or higher resolution than the current images.
18961923
/// </param>
18971924
/// <returns>An sl.ERROR_CODE if something went wrong.</returns>
1898-
public ERROR_CODE SetRegionOfInterest(sl.Mat roiMask)
1925+
public ERROR_CODE SetRegionOfInterest(sl.Mat roiMask, bool[] module)
18991926
{
1900-
sl.ERROR_CODE err = sl.ERROR_CODE.FAILURE;
1927+
if (module.Length != (int)MODULE.LAST) return sl.ERROR_CODE.FAILURE;
19011928

1902-
err = (sl.ERROR_CODE)dllz_sl_set_region_of_interest(CameraID, roiMask.GetPtr());
1903-
return err;
1929+
return (sl.ERROR_CODE)dllz_set_region_of_interest(CameraID, roiMask.GetPtr(), module);
19041930
}
19051931

19061932
/// <summary>
19071933
/// Get the previously set or computed region of interest.
19081934
/// </summary>
19091935
/// <param name="roiMask">The \ref Mat returned</param>
19101936
/// <param name="resolution">The optional size of the returned mask</param>
1937+
/// <param name="module"> Specifies the module from which the ROI is to be obtained. </param>
19111938
/// <returns>An sl.ERROR_CODE if something went wrong.</returns>
1912-
public ERROR_CODE GetRegionOfInterest(sl.Mat roiMask, sl.Resolution resolution = new sl.Resolution())
1939+
public ERROR_CODE GetRegionOfInterest(sl.Mat roiMask, sl.Resolution resolution = new sl.Resolution(), MODULE module = MODULE.ALL)
19131940
{
1914-
sl.ERROR_CODE err = sl.ERROR_CODE.FAILURE;
1915-
1916-
err = (sl.ERROR_CODE)dllz_get_region_of_interest(CameraID, roiMask.GetPtr(), (int)resolution.width, (int)resolution.height);
1917-
return err;
1941+
return (sl.ERROR_CODE)dllz_get_region_of_interest(CameraID, roiMask.MatPtr, (int)resolution.width, (int)resolution.height, module);
19181942
}
19191943

19201944
/// <summary>
@@ -1929,12 +1953,9 @@ public ERROR_CODE SetRegionOfInterest(sl.Mat roiMask)
19291953
/// </summary>
19301954
/// <param name="roiParams"></param>
19311955
/// <returns>An sl.ERROR_CODE if something went wrong.</returns>
1932-
public ERROR_CODE StartRegionOfInterestAutoDetection(ref RegionOfInterestParameters roiParams)
1956+
public ERROR_CODE StartRegionOfInterestAutoDetection(RegionOfInterestParameters roiParams)
19331957
{
1934-
sl.ERROR_CODE err = sl.ERROR_CODE.FAILURE;
1935-
dllz_start_region_of_interest_auto_detection(CameraID, ref roiParams);
1936-
1937-
return err;
1958+
return (sl.ERROR_CODE)dllz_start_region_of_interest_auto_detection(CameraID, ref roiParams);
19381959
}
19391960

19401961
/// <summary>
@@ -2731,6 +2752,65 @@ public void DisableRecording()
27312752
dllz_disable_recording(CameraID);
27322753
}
27332754

2755+
/// <summary>
2756+
/// Ingest SVOData in a SVO file.
2757+
/// </summary>
2758+
/// <param name="data">Data to ingest in the SVO file..</param>
2759+
/// Note: The method works only if the camera is recording.
2760+
/// <returns></returns>
2761+
public ERROR_CODE IngestDataIntoSVO(ref SVOData data)
2762+
{
2763+
ERROR_CODE err = dllz_ingest_data_into_svo(CameraID, ref data);
2764+
return err;
2765+
}
2766+
2767+
/// <summary>
2768+
/// Retrieves SVO data from the SVO file at the given channel key and in the given timestamp range.
2769+
/// </summary>
2770+
/// <param name="key"> The key of the SVOData that is going to be retrieved.</param>
2771+
/// <param name="data"> The map to be filled with SVOData objects, with timestamps as keys.</param>
2772+
/// <param name="tsBegin"> The beginning of the range.</param>
2773+
/// <param name="tsEnd">The end of the range.</param>
2774+
/// <returns>sl.ERROR_CODE.SUCCESS in case of success, sl.ERROR_CODE.FAILURE otherwise.</returns>
2775+
public ERROR_CODE RetrieveSVOData(string key, ref List<SVOData> data, ulong tsBegin, ulong tsEnd)
2776+
{
2777+
ERROR_CODE err = ERROR_CODE.FAILURE;
2778+
2779+
int nb_data = dllz_get_svo_data_size(CameraID, key, tsBegin, tsEnd);
2780+
2781+
if (nb_data > 0)
2782+
{
2783+
SVOData[] data_array = new SVOData[nb_data];
2784+
2785+
err = dllz_retrieve_svo_data(CameraID, key, nb_data, data_array, tsBegin, tsEnd);
2786+
data = new List<SVOData>(data_array);
2787+
}
2788+
2789+
return err;
2790+
}
2791+
2792+
/// <summary>
2793+
/// Gets the external channels that can be retrieved from the SVO file.
2794+
/// </summary>
2795+
/// <returns>List of available keys.</returns>
2796+
public List<string> GetSVODataKeys()
2797+
{
2798+
int nb_keys = dllz_get_svo_data_keys_size(CameraID);
2799+
2800+
if (nb_keys > 0)
2801+
{
2802+
string[] keys_array = new string[nb_keys];
2803+
2804+
dllz_get_svo_data_keys(CameraID, nb_keys, keys_array);
2805+
2806+
List<string> keys = new List<string>(keys_array);
2807+
2808+
return keys;
2809+
}
2810+
2811+
return new List<string>();
2812+
}
2813+
27342814
///@}
27352815

27362816
///@{
@@ -2972,30 +3052,6 @@ public sl.BodyTrackingParameters GetBodyTrackingParameters()
29723052

29733053
return parameters;
29743054
}
2975-
2976-
/// <summary>
2977-
/// Pause or resume the object detection.
2978-
///
2979-
/// The RetrieveObjects() method will keep on returning the last objects detected while in pause.
2980-
/// </summary>
2981-
/// <param name="status">If true, object detection is paused. If false, object detection is resumed.</param>
2982-
/// <param name="instanceID">Id of the instance to pause/resume. Used when multiple instances of the object detection module are enabled at the same time.</param>
2983-
public void PauseObjectDetection(bool status, uint instanceID = 0)
2984-
{
2985-
dllz_pause_object_detection(CameraID, status, instanceID);
2986-
}
2987-
2988-
/// <summary>
2989-
/// Pause or resume the body tracking.
2990-
///
2991-
/// The RetrieveBodies() method will keep on returning the last bodies detected while in pause.
2992-
/// </summary>
2993-
/// <param name="status">If true, body tracking is paused. If false, body tracking is resumed.</param>
2994-
/// <param name="instanceID">Id of the instance to pause/resume. Used when multiple instances of the body tracking module are enabled at the same time.</param>
2995-
public void PauseBodyTracking(bool status, uint instanceID = 0)
2996-
{
2997-
dllz_pause_body_tracking(CameraID, status, instanceID);
2998-
}
29993055

30003056
/// <summary>
30013057
/// Feed the 3D Object tracking method with your own 2D bounding boxes from your own detection algorithm.

0 commit comments

Comments
 (0)