Skip to content

Commit

Permalink
update to sdk v4.0.7 (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bvallon-sl authored Sep 25, 2023
1 parent ab34274 commit a3ba789
Show file tree
Hide file tree
Showing 10 changed files with 3,036 additions and 1,770 deletions.
Binary file not shown.
Binary file modified Content/ZED/Levels/L_BodyTrackingSingle.umap
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ void USlCameraProxy::Internal_OpenCamera(const FSlInitParameters& InitParameters
sl_init_parameters.async_grab_camera_recovery = InitParameters.bAsyncGrabCameraRecovery;
sl_init_parameters.open_timeout_sec = InitParameters.OpenTimeoutSec;
sl_init_parameters.grab_compute_capping_fps = InitParameters.GrabComputeCappingFPS;
sl_init_parameters.enable_image_validity_check = InitParameters.bEnableImageValidityCheck;

InputType = (SL_INPUT_TYPE)InitParameters.InputType;
bool IsCameraCreated = sl_create_camera(CameraID);
Expand Down Expand Up @@ -569,6 +570,37 @@ ESlTrackingState USlCameraProxy::GetPosition(FSlPose& Pose, ESlReferenceFrame Re
SL_SCOPE_UNLOCK
}

ESlErrorCode USlCameraProxy::SetRegionOfInterest(FSlMat& Mat)
{
SL_ERROR_CODE err = (SL_ERROR_CODE)sl_set_region_of_interest(CameraID, Mat.Mat);
return sl::unreal::ToUnrealType(err);
}

ESlErrorCode USlCameraProxy::GetRegionOfInterest(FSlMat& Mat, FIntPoint& resolution)
{
if (!Mat.Mat) {
Mat.Mat = sl_mat_create_new(resolution.X, resolution.Y, SL_MAT_TYPE_U8_C1, SL_MEM_CPU);
}
SL_ERROR_CODE err = (SL_ERROR_CODE)sl_get_region_of_interest(CameraID, Mat.Mat, resolution.X, resolution.Y);
return sl::unreal::ToUnrealType(err);
}

ESlErrorCode USlCameraProxy::StartRegionOfInterestAutoDetection(FSlRegionOfInterestParameters& roiParams)
{
SL_RegionOfInterestParameters params;
params.auto_apply = roiParams.bAutoApply;
params.depth_far_threshold_meters = roiParams.depthFarThresholdMeters;
params.image_height_ratio_cutoff = roiParams.imageHeightRatioCutoff;

SL_ERROR_CODE err = (SL_ERROR_CODE)sl_start_region_of_interest_auto_detection(CameraID, &params);
return sl::unreal::ToUnrealType(err);
}

ESlRegionOfInterestAutoDetectionState USlCameraProxy::GetRegionOfInterestAutoDetectionStatus()
{
return (ESlRegionOfInterestAutoDetectionState)sl_get_region_of_interest_auto_detection_status(CameraID);
}

ESlErrorCode USlCameraProxy::GetIMUData(FSlIMUData& IMUData, ESlTimeReference TimeReference)
{
SL_ERROR_CODE ErrorCode = SL_ERROR_CODE_FAILURE;
Expand Down Expand Up @@ -846,6 +878,11 @@ FSlVideoSettings USlCameraProxy::GetCameraSettings()
return CameraSettings;
}

bool USlCameraProxy::GetCameraSetting(ESlVideoSettings CameraSetting, int& value)
{
return (sl_get_camera_settings(CameraID, (SL_VIDEO_SETTINGS)CameraSetting, &value) == SL_ERROR_CODE_SUCCESS);
}

bool USlCameraProxy::EnableSpatialMapping(const FSlSpatialMappingParameters& SpatialMappingParameters)
{
SL_ERROR_CODE ErrorCode;
Expand Down Expand Up @@ -1015,6 +1052,22 @@ bool USlCameraProxy::RetrieveMeasure(void* Mat, ESlMeasure MeasureType, ESlMemor
return (ErrorCode == SL_ERROR_CODE_SUCCESS);
}

bool USlCameraProxy::IsCameraSettingSupported(ESlVideoSettings CameraSetting)
{
return sl_is_camera_setting_supported(CameraID, (SL_VIDEO_SETTINGS)CameraSetting);
}

bool USlCameraProxy::SetCameraSetting(ESlVideoSettings NewCameraSettings, int value)
{
if (sl_is_camera_setting_supported(CameraID, (SL_VIDEO_SETTINGS)NewCameraSettings))
{
sl_set_camera_settings(CameraID, (SL_VIDEO_SETTINGS)NewCameraSettings, value);
return true;
}
return false;
}


void USlCameraProxy::SetCameraSettings(FSlVideoSettings& NewCameraSettings)
{
bool bDefault = NewCameraSettings.bDefault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ enum class ESlRetrieveResult : uint8
UENUM(BlueprintType, Category = "Stereolabs|Enum")
enum class ESlErrorCode : uint8
{
EC_CorruptedFrame = 254 UMETA(DisplayName = "Corrupted frame"),
EC_CameraRebooting = 255 UMETA(DisplayName = "Camera rebooting"),
EC_Success = 0 UMETA(DisplayName = "Success"),
EC_Failure UMETA(DisplayName = "Failure"),
Expand Down Expand Up @@ -364,6 +365,38 @@ enum class ESlErrorCode : uint8
EC_None UMETA(DisplayName = "No error")
};

/**
\brief Lists available camera settings for the camera (contrast, hue, saturation, gain, ...).
\warning All \ref VIDEO_SETTINGS are not supported for all camera models. You can find the supported \ref VIDEO_SETTINGS for each ZED camera in our <a href="https://www.stereolabs.com/docs/video/camera-controls#adjusting-camera-settings">documentation</a>.\n\n
GAIN and EXPOSURE are linked in auto/default mode (see \ref sl::Camera.setCameraSettings()).
*/
UENUM(BlueprintType, Category = "Stereolabs|Enum")
enum class ESlVideoSettings: uint8
{
VS_BRIGHTNESS UMETA(DisplayName = "Brightness"), /**< Brightness control \n Affected value should be between 0 and 8. \note Not available for ZED X/X Mini cameras.*/
VS_CONTRAST UMETA(DisplayName = "Contrast"), /**< Contrast control \n Affected value should be between 0 and 8. \note Not available for ZED X/X Mini cameras.*/
VS_HUE UMETA(DisplayName = "Hue"), /**< Hue control \n Affected value should be between 0 and 11. \note Not available for ZED X/X Mini cameras.*/
VS_SATURATION UMETA(DisplayName = "Saturation"), /**< Saturation control \n Affected value should be between 0 and 8.*/
VS_SHARPNESS UMETA(DisplayName = "Sharpness"), /**< Digital sharpening control \n Affected value should be between 0 and 8.*/
VS_GAMMA UMETA(DisplayName = "Gamma"), /**< ISP gamma control \n Affected value should be between 1 and 9.*/
VS_GAIN UMETA(DisplayName = "Gain"), /**< Gain control \n Affected value should be between 0 and 100 for manual control. \note If EXPOSURE is set to -1 (automatic mode), then GAIN will be automatic as well.*/
VS_EXPOSURE UMETA(DisplayName = "Exposure"), /**< Exposure control \n Affected value should be between 0 and 100 for manual control.\n The exposition is mapped linearly in a percentage of the following max values.\n Special case for <code>EXPOSURE = 0</code> that corresponds to 0.17072ms.\n The conversion to milliseconds depends on the framerate: <ul><li>15fps & <code>EXPOSURE = 100</code> -> 19.97ms</li><li>30fps & <code>EXPOSURE = 100</code> -> 19.97ms</li><li>60fps & <code>EXPOSURE = 100</code> -> 10.84072ms</li><li>100fps & <code>EXPOSURE = 100</code> -> 10.106624ms</li></ul>*/
VS_AEC_AGC UMETA(DisplayName = "AEC AGC"), /**< Defines if the GAIN and EXPOSURE are in automatic mode or not.\n Setting GAIN or EXPOSURE values will automatically set this value to 0.*/
VS_AEC_AGC_ROI UMETA(DisplayName = "AEC AGC Roi"), /**< Defines the region of interest for automatic exposure/gain computation.\n To be used with overloaded \ref Camera.setCameraSettings(VIDEO_SETTINGS,Rect,sl::SIDE,bool) "setCameraSettings()" / \ref Camera.getCameraSettings(VIDEO_SETTINGS,Rect&,sl::SIDE) "getCameraSettings()" methods.*/
VS_WHITEBALANCE_TEMPERATURE UMETA(DisplayName = "White balance"), /**< Color temperature control \n Affected value should be between 2800 and 6500 with a step of 100. \note Setting a value will automatically set WHITEBALANCE_AUTO to 0.*/
VS_WHITEBALANCE_AUTO UMETA(DisplayName = "Auto White balance"), /**< Defines if the white balance is in automatic mode or not.*/
VS_LED_STATUS UMETA(DisplayName = "LED status"), /**< Status of the front LED of the camera.\n Set to 0 to disable the light, 1 to enable the light.\n Default value is on. \note Requires camera firmware 1523 at least.*/
VS_EXPOSURE_TIME UMETA(DisplayName = "Exposure time"), /**< Real exposure time control in microseconds. \note Only available for ZED X/X Mini cameras.\note Replace EXPOSURE setting.*/
VS_ANALOG_GAIN UMETA(DisplayName = "Analog gain"), /**< Real analog gain (sensor) control in mDB.\n The range is defined by Jetson DTS and by default [1000-16000]. \note Only available for ZED X/X Mini cameras.\note Replace GAIN settings.*/
VS_DIGITAL_GAIN UMETA(DisplayName = "Digital gain"), /**< Real digital gain (ISP) as a factor.\n The range is defined by Jetson DTS and by default [1-256]. \note Only available for ZED X/X Mini cameras.\note Replace GAIN settings.*/
VS_AUTO_EXPOSURE_TIME_RANGE UMETA(DisplayName = "Auto exposure time range"), /**< Range of exposure auto control in microseconds.\n Used with \ref Camera.setCameraSettings(VIDEO_SETTINGS,int,int) "setCameraSettings()".\n Min/max range between max range defined in DTS.\n By default: [28000 - <fps_time> or 19000] us. \note Only available for ZED X/X Mini cameras.*/
VS_AUTO_ANALOG_GAIN_RANGE UMETA(DisplayName = "Auto analog gain range"), /**< Range of sensor gain in automatic control.\n Used with \ref Camera.setCameraSettings(VIDEO_SETTINGS,int,int) "setCameraSettings()".\n Min/max range between max range defined in DTS.\n By default: [1000 - 16000] mdB. \note Only available for ZED X/X Mini cameras.*/
VS_AUTO_DIGITAL_GAIN_RANGE UMETA(DisplayName = "Auto digital gain range"), /**< Range of digital ISP gain in automatic control.\n Used with \ref Camera.setCameraSettings(VIDEO_SETTINGS,int,int) "setCameraSettings()".\n Min/max range between max range defined in DTS.\n By default: [1 - 256]. \note Only available for ZED X/X Mini cameras.*/
VS_EXPOSURE_COMPENSATION UMETA(DisplayName = "Exposure compensation"), /**< Exposure-target compensation made after auto exposure.\n Reduces the overall illumination target by factor of F-stops.\n Affected value should be between 0 and 100 (mapped between [-2.0,2.0]).\n Default value is 50, i.e. no compensation applied. \note Only available for ZED X/X Mini cameras.*/
VS_DENOISING UMETA(DisplayName = "Denoising"), /**< Level of denoising applied on both left and right images.\n Affected value should be between 0 and 100.\n Default value is 50. \note Only available for ZED X/X Mini cameras.*/
VS_LAST
};

/*
* SDK SVO compression modes
* see sl::SVO_COMPRESSION_MODE
Expand Down Expand Up @@ -511,6 +544,17 @@ enum class ESlPositionalTrackingMode : uint8
PTM_Quality UMETA(DisplayName = "Quality")
};

/**
\brief Lists the different states of region of interest auto detection.
*/
UENUM(BlueprintType, Category = "Stereolabs|Enum")
enum class ESlRegionOfInterestAutoDetectionState : uint8
{
ROI_RUNNING UMETA(DisplayName = "Running"), /**< The region of interest auto detection is initializing.*/
ROI_READY UMETA(DisplayName = "Ready"), /**< The region of interest mask is ready, if auto_apply was enabled, the region of interest mask is being used*/
ROI_NOT_ENABLED UMETA(DisplayName = "Not Enabled"), /**< The region of interest auto detection is not enabled*/
};

/*
* Lists available object tracking state.
*/
Expand Down Expand Up @@ -2238,6 +2282,40 @@ struct STEREOLABS_API FSlPose
bool bValid;
};

USTRUCT(BlueprintType, Category = "Stereolabs|Struct")
struct STEREOLABS_API FSlRegionOfInterestParameters
{
GENERATED_BODY()

FSlRegionOfInterestParameters()
:
depthFarThresholdMeters(2.5f),
imageHeightRatioCutoff(0.5f),
bAutoApply(false)
{}

/**
\brief Filtering how far object in the ROI should be considered, this is useful for a vehicle for instance
Default: 2.5 meters
*/
float depthFarThresholdMeters = 2.5;

/**
\brief By default consider only the lower half of the image, can be useful to filter out the sky
Default: 0.5, correspond to the lower half of the image
*/
float imageHeightRatioCutoff = 0.5;

/**
\brief Once computed the ROI computed will be automatically applied
Default: Enabled
*/
bool bAutoApply = true;
};

/*
* SDK IMU data
* see Sl::IMUData
Expand Down Expand Up @@ -2313,7 +2391,8 @@ struct STEREOLABS_API FSlInitParameters
bEnableImageEnhancement(true),
OpenTimeoutSec(5.0f),
VerboseFilePath(""),
GrabComputeCappingFPS(0.0f)
GrabComputeCappingFPS(0.0f),
bEnableImageValidityCheck(false)
{
}

Expand Down Expand Up @@ -2493,6 +2572,13 @@ struct STEREOLABS_API FSlInitParameters
GrabComputeCappingFPS,
*Path
);

GConfig->GetBool(
Section,
TEXT("bEnableImageValidityCheck"),
bEnableImageValidityCheck,
*Path
);
}

FORCEINLINE void Save(const FString& Path) const
Expand Down Expand Up @@ -2657,6 +2743,13 @@ struct STEREOLABS_API FSlInitParameters
GrabComputeCappingFPS,
*Path
);

GConfig->SetBool(
Section,
TEXT("bEnableImageValidityCheck"),
bEnableImageValidityCheck,
*Path
);
}

/** Input type used in the ZED SDK */
Expand Down Expand Up @@ -2785,6 +2878,15 @@ struct STEREOLABS_API FSlInitParameters
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float GrabComputeCappingFPS;
/**
Enable or disable the image validity verification.
This will perform additional verification on the image to identify corrupted data. This verification is done in the grab function and requires some computations.
If an issue is found, the grab function will output a warning as sl::ERROR_CODE::CORRUPTED_FRAME.
This version doesn't detect frame tearing currently.
\n default: disabled
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bEnableImageValidityCheck;
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ class STEREOLABS_API USlCameraProxy : public UObject
UFUNCTION(BlueprintPure, meta = (Keywords = "get zed camera settings"), Category = "Zed|Camera")
FSlVideoSettings GetCameraSettings();

UFUNCTION(BlueprintPure, meta = (Keywords = "get zed camera setting"), Category = "Zed|Camera")
bool GetCameraSetting(ESlVideoSettings CameraSetting, int& value);

UFUNCTION(BlueprintPure, meta = (Keywords = "is camera setting supported"), Category = "Zed|Camera")

bool IsCameraSettingSupported(ESlVideoSettings CameraSetting);

/*
* Set a camera setting
* @param NewCameraSettings The camera setting to set
*/
UFUNCTION(BlueprintPure, meta = (Keywords = "set zed camera setting"), Category = "Zed|Camera")
bool SetCameraSetting(ESlVideoSettings NewCameraSettings, int value);
/*
* Set the camera settings
* @param NewCameraSettings The camera settings to set
Expand Down Expand Up @@ -262,6 +275,17 @@ class STEREOLABS_API USlCameraProxy : public UObject
UFUNCTION(BlueprintPure, meta = (Keywords = "get zed pose"), Category = "Zed|Tracking")
ESlTrackingState GetPosition(FSlPose& Pose, ESlReferenceFrame ReferenceFrame);

UFUNCTION(BlueprintPure, meta = (Keywords = "Set Region Of Interest"), Category = "Zed|Tracking")
ESlErrorCode SetRegionOfInterest(FSlMat& Mat);

UFUNCTION(BlueprintPure, meta = (Keywords = "Get Region Of Interest"), Category = "Zed|Tracking")
ESlErrorCode GetRegionOfInterest(FSlMat& Mat, FIntPoint& resolution);

UFUNCTION(BlueprintPure, meta = (Keywords = "start region of interest auto detection"), Category = "Zed|Tracking")
ESlErrorCode StartRegionOfInterestAutoDetection(FSlRegionOfInterestParameters& roiParams);

UFUNCTION(BlueprintPure, meta = (Keywords = "get region of interest auto detection status"), Category = "Zed|Tracking")
ESlRegionOfInterestAutoDetectionState GetRegionOfInterestAutoDetectionStatus();
/*
* Get the current IMU data
* @param IMUData The current IMU data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ namespace sl
{
switch (SlType)
{
case sl::ERROR_CODE::CORRUPTED_FRAME: /**< The image could be corrupted, Enabled with the parameter InitParameters::enable_image_validity_check.*/
return ESlErrorCode::EC_CorruptedFrame;
case sl::ERROR_CODE::CAMERA_REBOOTING: /**< The camera is currently rebooting.*/
return ESlErrorCode::EC_CameraRebooting;
case sl::ERROR_CODE::SUCCESS: /**< Standard code for successful behavior.*/
return ESlErrorCode::EC_Success;
case sl::ERROR_CODE::FAILURE: /**< Standard code for unsuccessful behavior.*/
Expand Down Expand Up @@ -312,7 +316,9 @@ namespace sl
{
switch (SlType)
{
case -1:
case SL_ERROR_CODE_CORRUPTED_FRAME:
return ESlErrorCode::EC_CorruptedFrame;
case SL_ERROR_CODE_CAMERA_REBOOTING:
return ESlErrorCode::EC_CameraRebooting;
case SL_ERROR_CODE_SUCCESS: /**< Standard code for successful behavior.*/
return ESlErrorCode::EC_Success;
Expand Down Expand Up @@ -2109,38 +2115,6 @@ namespace sl
return TrackingParameters;
}

/*
* Covnert from FSlInitParameters to sl::InitParameters
*/
FORCEINLINE sl::InitParameters ToSlType(const FSlInitParameters& UnrealData)
{
sl::InitParameters InitParameters;

InitParameters.camera_disable_self_calib = UnrealData.bDisableSelfCalibration;
InitParameters.camera_fps = UnrealData.FPS;
InitParameters.camera_image_flip = (int)UnrealData.VerticalFlipImage;
InitParameters.camera_resolution = sl::unreal::ToSlType(UnrealData.Resolution);
InitParameters.coordinate_system = sl::unreal::ToSlType(UnrealData.CoordinateSystem);
InitParameters.coordinate_units = sl::unreal::ToSlType(UnrealData.Unit);
InitParameters.depth_minimum_distance = UnrealData.DepthMinimumDistance;
InitParameters.depth_mode = sl::unreal::ToSlType(UnrealData.DepthMode);
InitParameters.enable_right_side_measure = UnrealData.bEnableRightSideMeasure;
InitParameters.sdk_gpu_id = FMath::FloorToInt(UnrealData.GPUID);
InitParameters.sdk_verbose = UnrealData.Verbose;
InitParameters.sdk_verbose_log_file = TCHAR_TO_UTF8(*UnrealData.VerboseFilePath);
InitParameters.grab_compute_capping_fps = UnrealData.GrabComputeCappingFPS;
if (UnrealData.InputType == ESlInputType::IT_SVO)
{
InitParameters.input.setFromSVOFile(TCHAR_TO_UTF8(*UnrealData.SvoPath));
InitParameters.svo_real_time_mode = UnrealData.bRealTime;
}
else if (UnrealData.InputType == ESlInputType::IT_STREAM) {
InitParameters.input.setFromStream(TCHAR_TO_UTF8(*UnrealData.StreamIP), UnrealData.StreamPort);
}
InitParameters.depth_stabilization = UnrealData.DepthStabilization;

return InitParameters;
}

FORCEINLINE SL_ObjectDetectionParameters ToSlType(const FSlObjectDetectionParameters& UnrealData)
{
Expand Down
Binary file not shown.
Loading

0 comments on commit a3ba789

Please sign in to comment.