Skip to content

Commit

Permalink
merge v3.7 to main
Browse files Browse the repository at this point in the history
  • Loading branch information
Bvallon-sl committed Feb 25, 2022
2 parents b725e19 + 1eddb5b commit 67b2b96
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 14 deletions.
2 changes: 0 additions & 2 deletions BuildZEDLinux.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<Node Name="Compile UnrealHeaderTool Linux">
<Compile Target="UnrealHeaderTool" Platform="Linux" Configuration="Test"/>
</Node>

<Node Name="Compile ZEDLiveLink Linux" Requires="Compile UnrealHeaderTool Linux">
<Compile Target="ZEDLiveLink" Platform="Linux" Configuration="Test"/>
</Node>
Expand All @@ -14,6 +13,5 @@
<Copy From="$(LocalBinaryDir)/ZEDLiveLink-Linux-Test.debug" To="$(LocalBinaryDir)/ZEDLiveLink/ZEDLiveLink.debug" />
<Copy From="$(LocalBinaryDir)/ZEDLiveLink-Linux-Test.sym" To="$(LocalBinaryDir)/ZEDLiveLink/ZEDLiveLink.sym" />
</Node>

</Agent>
</BuildGraph>
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
23 changes: 23 additions & 0 deletions Source/Private/ZEDCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -217,6 +232,7 @@ bool ZEDCamera::LoadDll(FString DLLName)
ImportMethod_DisableOD();
ImportMethod_GetPosition();
ImportMethod_RetrieveObjects();
ImportMethod_SetSVOPosition();
return true;
}
}
Expand Down Expand Up @@ -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
12 changes: 9 additions & 3 deletions Source/Private/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
}

Expand Down
4 changes: 4 additions & 0 deletions Source/Public/ZEDCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -63,6 +65,7 @@ class ZEDCamera {
__Grab m_funcGrab;
__SN m_funcGetSN;
__CalibParams m_funcGetCalibParams;
__SetSVOPosition m_funcSetSVOPosition;

int camera_id;

Expand All @@ -78,6 +81,7 @@ class ZEDCamera {
bool ImportMethod_GetSerialNumber();
bool ImportMethod_RetrieveObjects();
bool ImportMethod_GetCalibParams();
bool ImportMethod_SetSVOPosition();

bool LoadDll(FString DLLName);
void UnloadDll();
Expand Down
7 changes: 5 additions & 2 deletions Source/Public/ZEDStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ 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;
reference_frame = sl::REFERENCE_FRAME::CAMERA;
enable_depth = true;
confidence_threshold = 100;
texture_confidence_threshold = 100;
remove_saturated_areas = false;
}
};

Expand All @@ -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;
Expand All @@ -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;
}
};

Expand Down
8 changes: 4 additions & 4 deletions Source/ZEDLiveLink.Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
9 changes: 9 additions & 0 deletions UnrealProject/Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

3 changes: 3 additions & 0 deletions UnrealProject/Config/DefaultGame.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ Description=Live link demo sample
bAddPacks=True
InsertPack=(PackSource="StarterContent.upack",PackName="StarterContent")

[/Script/LiveLink.LiveLinkSettings]
DefaultMessageBusSourceMode=EngineTime

Binary file modified UnrealProject/Content/Maps/LiveLinkMap.umap
Binary file not shown.
Binary file modified UnrealProject/Content/Maps/LiveLinkMap_BuiltData.uasset
Binary file not shown.
Binary file modified lib/linux/libsl_zed_c.so
Binary file not shown.
Binary file modified lib/win64/sl_zed_c.dll
Binary file not shown.

0 comments on commit 67b2b96

Please sign in to comment.