diff --git a/BuildZEDLinux.xml b/BuildZEDLinux.xml index d7c6e1b..bb7f8c8 100644 --- a/BuildZEDLinux.xml +++ b/BuildZEDLinux.xml @@ -5,7 +5,6 @@ - @@ -14,6 +13,5 @@ - diff --git a/README.md b/README.md index a52e828..20d31c2 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The object detection module can be disabled in order to send only camera trackin ## Getting started - First, download the latest version of the ZED SDK on [stereolabs.com](https://www.stereolabs.com/developers/) -- For more information, read the ZED [Documentation](https://www.stereolabs.com/docs/app-development/python/install/) and [API documentation](https://www.stereolabs.com/docs/api/python/) +- For more information, read the ZED [Documentation](https://www.stereolabs.com/docs) and [API documentation](https://www.stereolabs.com/docs/api/) To compile the tool from source, you will require a source build of Unreal Engine. @@ -108,9 +108,14 @@ If the ZED Source is not yet detected in UnrealEngine, enable **Enable by defaul #### On Linux -If the plugin crashes at the start, try to run the ldd command onto the sl_wrapper.so library : +If the plugin crashes at the start, try to run the ldd command onto the sl_zed_c.so library : ```bash -$ ldd sl_wrapper.so +$ ldd libsl_zed_c.so ``` It will show all the dependencies required by the .so and allow you to install anything that might be missing (for example lib-usb). + + +Note that the c wrapper used for the Live link plugin is also available here : https://github.com/stereolabs/zed-c-api. + +If you encounter issues running the live link plugin, do not hesitate to build the wrapper yourself and place it in the lib/win64 or /linux folder. diff --git a/Source/Private/ZEDCamera.cpp b/Source/Private/ZEDCamera.cpp index bf5ea75..b46b583 100644 --- a/Source/Private/ZEDCamera.cpp +++ b/Source/Private/ZEDCamera.cpp @@ -198,6 +198,21 @@ bool ZEDCamera::ImportMethod_RetrieveObjects() return false;// Return an error. } +bool ZEDCamera::ImportMethod_SetSVOPosition() +{ + if (v_dllHandle != NULL) + { + m_funcSetSVOPosition = NULL; + FString procName = "sl_set_svo_position";// Needs to be the exact name of the DLL method. + m_funcSetSVOPosition = (__SetSVOPosition)FPlatformProcess::GetDllExport(v_dllHandle, *procName); + if (m_funcSetSVOPosition != NULL) + { + return true; + } + } + return false;// Return an error. +} + bool ZEDCamera::LoadDll(FString DLLName) { if (FPaths::FileExists(DLLName)) @@ -217,6 +232,7 @@ bool ZEDCamera::LoadDll(FString DLLName) ImportMethod_DisableOD(); ImportMethod_GetPosition(); ImportMethod_RetrieveObjects(); + ImportMethod_SetSVOPosition(); return true; } } @@ -346,6 +362,13 @@ sl::ERROR_CODE ZEDCamera::RetrieveObjects(SL_ObjectDetectionRuntimeParameters& o return e; } +void ZEDCamera::setSVOPosition(int frame_number) { + if (m_funcSetSVOPosition == NULL) + { + return ; + } + m_funcSetSVOPosition(camera_id, frame_number); +} #endif \ No newline at end of file diff --git a/Source/Private/main.cpp b/Source/Private/main.cpp index cc2c245..d9815a2 100644 --- a/Source/Private/main.cpp +++ b/Source/Private/main.cpp @@ -115,7 +115,8 @@ int main(int argc, char **argv) ///// Update Streamed data SL_RuntimeParameters rt_params; rt_params.reference_frame = sl::REFERENCE_FRAME::WORLD; - if (StreamedCamera.Cam->Grab(rt_params) == sl::ERROR_CODE::SUCCESS) { + sl::ERROR_CODE err = StreamedCamera.Cam->Grab(rt_params); + if (err == sl::ERROR_CODE::SUCCESS) { UpdateCameraFrameData(StreamedCamera.SubjectName, *StreamedCamera.Cam); #if ENABLE_OBJECT_DETECTION @@ -129,6 +130,10 @@ int main(int argc, char **argv) } #endif } + else if (err == sl::ERROR_CODE::END_OF_SVOFILE_REACHED) { + std::cout << "End of SVO reached " << std::endl; + StreamedCamera.Cam->setSVOPosition(0); + } else { std::cout << "Grab Failed " << std::endl; } @@ -202,6 +207,7 @@ ERROR_CODE InitCamera(int argc, char **argv) SL_PositionalTrackingParameters tracking_param; tracking_param.set_floor_as_origin = true; + tracking_param.enable_pose_smoothing = true; err = zed->EnableTracking(tracking_param); if (err != ERROR_CODE::SUCCESS) @@ -333,8 +339,8 @@ void UpdateCameraFrameData(FName SubjectName, ZEDCamera& zed) //CameraData.FieldOfView = zed.getCameraInformation().camera_configuration.calibration_parameters.left_cam.h_fov; CameraData.ProjectionMode = ELiveLinkCameraProjectionMode::Perspective; CameraData.Transform = Pose; - double timestamp = (pose.timestamp / 1000000000.0f);// ns to seconds - CameraData.WorldTime = timestamp; + double StreamTime = FPlatformTime::Seconds(); + CameraData.WorldTime = StreamTime; LiveLinkProvider->UpdateSubjectFrameData(SubjectName, MoveTemp(FrameData)); } diff --git a/Source/Public/ZEDCamera.h b/Source/Public/ZEDCamera.h index dd6811e..b249e32 100644 --- a/Source/Public/ZEDCamera.h +++ b/Source/Public/ZEDCamera.h @@ -28,6 +28,7 @@ typedef bool(*__CreateCamera)(int id, bool verbose); typedef int(*__SN)(int sn); typedef int(*__Grab)(int id, SL_RuntimeParameters& rt_params); typedef SL_CalibrationParameters*(*__CalibParams)(int id, bool raw_params); +typedef void(*__SetSVOPosition)(int id, int frame_nb); class ZEDCamera { @@ -48,6 +49,7 @@ class ZEDCamera { int GetSerialNumber(); sl::ERROR_CODE RetrieveObjects(SL_ObjectDetectionRuntimeParameters& od_params, SL_Objects& objs); SL_CalibrationParameters* GetCalibrationParameters(bool raw_params = false); + void setSVOPosition(int frame_number); private: void *v_dllHandle; @@ -63,6 +65,7 @@ class ZEDCamera { __Grab m_funcGrab; __SN m_funcGetSN; __CalibParams m_funcGetCalibParams; + __SetSVOPosition m_funcSetSVOPosition; int camera_id; @@ -78,6 +81,7 @@ class ZEDCamera { bool ImportMethod_GetSerialNumber(); bool ImportMethod_RetrieveObjects(); bool ImportMethod_GetCalibParams(); + bool ImportMethod_SetSVOPosition(); bool LoadDll(FString DLLName); void UnloadDll(); diff --git a/Source/Public/ZEDStructs.h b/Source/Public/ZEDStructs.h index 01ffe74..6875499 100644 --- a/Source/Public/ZEDStructs.h +++ b/Source/Public/ZEDStructs.h @@ -151,6 +151,7 @@ struct SL_RuntimeParameters bool enable_depth; int confidence_threshold; int texture_confidence_threshold; + bool remove_saturated_areas; SL_RuntimeParameters() { sensing_mode = sl::SENSING_MODE::STANDARD; @@ -158,6 +159,7 @@ struct SL_RuntimeParameters enable_depth = true; confidence_threshold = 100; texture_confidence_threshold = 100; + remove_saturated_areas = false; } }; @@ -175,10 +177,10 @@ struct SL_ObjectDetectionParameters bool enable_mask_output; sl::DETECTION_MODEL model; bool enable_body_fitting; - sl::BODY_FORMAT body_format; float max_range; - SL_BatchParameters batch_parameters; + sl::BODY_FORMAT body_format; + sl::OBJECT_FILTERING_MODE filtering_mode; SL_ObjectDetectionParameters() { image_sync = false; @@ -188,6 +190,7 @@ struct SL_ObjectDetectionParameters model = sl::DETECTION_MODEL::HUMAN_BODY_ACCURATE; max_range = -1; body_format = sl::BODY_FORMAT::POSE_34; + filtering_mode = sl::OBJECT_FILTERING_MODE::NMS3D; } }; diff --git a/Source/ZEDLiveLink.Target.cs b/Source/ZEDLiveLink.Target.cs index d3b184a..f810c87 100644 --- a/Source/ZEDLiveLink.Target.cs +++ b/Source/ZEDLiveLink.Target.cs @@ -15,15 +15,15 @@ public ZEDLiveLinkTarget(TargetInfo Target) : base(Target) SolutionDirectory = "Programs/LiveLink"; // We only need minimal use of the engine for this plugin - bBuildDeveloperTools = false; + bBuildDeveloperTools = false; bUseMallocProfiler = false; bBuildWithEditorOnlyData = true; - bCompileAgainstEngine = false; + bCompileAgainstEngine = false; bCompileAgainstCoreUObject = true; bCompileICU = false; - bIsBuildingConsoleApplication = true; + bIsBuildingConsoleApplication = true; - if (Target.Platform == UnrealTargetPlatform.Win64) + if (Target.Platform == UnrealTargetPlatform.Win64) ExeBinariesSubFolder = "ZEDLiveLink/"; this.LaunchModuleName = "ZEDLiveLink"; diff --git a/UnrealProject/Config/DefaultEngine.ini b/UnrealProject/Config/DefaultEngine.ini index f44b6c4..2348dad 100644 --- a/UnrealProject/Config/DefaultEngine.ini +++ b/UnrealProject/Config/DefaultEngine.ini @@ -25,3 +25,12 @@ AppliedDefaultGraphicsPerformance=Maximum +ActiveGameNameRedirects=(OldGameName="/Script/TP_ThirdPersonBP",NewGameName="/Script/ZEDUnrealLiveLink") +ActiveGameNameRedirects=(OldGameName="/Script/MyProject", NewGameName="/Script/ZEDUnrealLiveLink") +[/Script/OmniverseRuntime.OmniverseSettings] +bUserWantsToConnect=False +bLiveEdit=False +RenderContext=ERC_MDL +bOpenDeveloperLog=False +bTextureCompression=True +bEnableQueryCollision=False +bEnablePlayInEditorChanges=False + diff --git a/UnrealProject/Config/DefaultGame.ini b/UnrealProject/Config/DefaultGame.ini index a9c824d..5ed4c12 100644 --- a/UnrealProject/Config/DefaultGame.ini +++ b/UnrealProject/Config/DefaultGame.ini @@ -7,3 +7,6 @@ Description=Live link demo sample bAddPacks=True InsertPack=(PackSource="StarterContent.upack",PackName="StarterContent") +[/Script/LiveLink.LiveLinkSettings] +DefaultMessageBusSourceMode=EngineTime + diff --git a/UnrealProject/Content/Maps/LiveLinkMap.umap b/UnrealProject/Content/Maps/LiveLinkMap.umap index 98cf240..6644bf4 100644 Binary files a/UnrealProject/Content/Maps/LiveLinkMap.umap and b/UnrealProject/Content/Maps/LiveLinkMap.umap differ diff --git a/UnrealProject/Content/Maps/LiveLinkMap_BuiltData.uasset b/UnrealProject/Content/Maps/LiveLinkMap_BuiltData.uasset index 9cb13bd..1091867 100644 Binary files a/UnrealProject/Content/Maps/LiveLinkMap_BuiltData.uasset and b/UnrealProject/Content/Maps/LiveLinkMap_BuiltData.uasset differ diff --git a/lib/linux/libsl_zed_c.so b/lib/linux/libsl_zed_c.so index d7c1333..5d87b6c 100755 Binary files a/lib/linux/libsl_zed_c.so and b/lib/linux/libsl_zed_c.so differ diff --git a/lib/win64/sl_zed_c.dll b/lib/win64/sl_zed_c.dll index c9514f0..2ffdbdd 100644 Binary files a/lib/win64/sl_zed_c.dll and b/lib/win64/sl_zed_c.dll differ