return()
endif()
-find_package(Open3D REQUIRED NO_POLICY_SCOPE)
-if(NOT Open3D_FOUND)
- message(SEND_ERROR "Open3D NOT FOUND")
- return()
-else()
- include_directories(${Open3D_INCLUDE_DIRS})
+if(MV_3D_POINTCLOUD_IS_AVAILABLE)
+ find_package(Open3D REQUIRED NO_POLICY_SCOPE)
+ if(NOT Open3D_FOUND)
+ message(SEND_ERROR "Open3D NOT FOUND")
+ return()
+ else()
+ include_directories(${Open3D_INCLUDE_DIRS})
+ endif()
endif()
if(FORCED_STATIC_BUILD)
add_library(${PROJECT_NAME} SHARED ${MV_DFS_SOURCE_LIST})
endif()
-target_link_libraries(${PROJECT_NAME} ${MV_COMMON_LIB_NAME} ${OpenCV_LIBS} ${Open3D_LIBRARIES} ${${PROJECT_NAME}_DEP_LIBRARIES})
+target_link_libraries(${PROJECT_NAME} ${MV_COMMON_LIB_NAME} ${OpenCV_LIBS} ${${PROJECT_NAME}_DEP_LIBRARIES})
+
+if(MV_3D_POINTCLOUD_IS_AVAILABLE)
+ target_link_libraries(${PROJECT_NAME} ${Open3D_LIBRARIES})
+endif()
target_include_directories(${PROJECT_NAME} PRIVATE include)
install(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
static gpointer DfsThreadLoop(gpointer data);
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
void GetPointcloudFromSource(DfsInputData &intput,
DfsOutputData &depthData,
mv_3d_pointcloud_s &pointcloud);
+#endif
public:
Mv3d();
~Mv3d();
void SetDepthCallback(mv_3d_depth_cb depthCallback, void *depthUserData);
- void SetPointcloudCallback(mv_3d_pointcloud_cb pointcloudCallback, void *pointcloudUserData);
+ int SetPointcloudCallback(mv_3d_pointcloud_cb pointcloudCallback, void *pointcloudUserData);
int WritePointcloudFile(mv_3d_pointcloud_h pointcloud, mv_3d_pointcloud_type_e type, char *fileName);
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
+
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
#include <open3d/Open3D.h>
+using namespace open3d;
+#endif
#include "Mv3d.h"
-using namespace open3d;
-
namespace mediavision
{
namespace mv3d
mDfsAsyncQueue(nullptr)
{
LOGI("ENTER");
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
utility::SetVerbosityLevel(utility::VerbosityLevel::Debug);
+#endif
LOGI("LEAVE");
}
mDepthUserData = depthUserData;
}
- void Mv3d::SetPointcloudCallback(mv_3d_pointcloud_cb pointcloudCallback, void *pointcloudUserData)
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
+ int Mv3d::SetPointcloudCallback(mv_3d_pointcloud_cb pointcloudCallback, void *pointcloudUserData)
{
+ if (pointcloudCallback == NULL || pointcloudUserData == NULL)
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+
mPointcloudCallback = pointcloudCallback;
mPointcloudUserData = pointcloudUserData;
+
+ return MEDIA_VISION_ERROR_NONE;
}
+#else
+ int Mv3d::SetPointcloudCallback(mv_3d_pointcloud_cb pointcloudCallback, void *pointcloudUserData)
+ {
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED;
+ }
+#endif
int Mv3d::Prepare()
{
}
}
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
void Mv3d::GetPointcloudFromSource(DfsInputData &input,
DfsOutputData &depthData,
mv_3d_pointcloud_s &pointcloud)
pointcloud.pointcloud = static_cast<void*>(
new std::shared_ptr<open3d::geometry::PointCloud>(
std::move(pcd)));
-
}
+#endif
int Mv3d::Run(mv_source_h baseSource, mv_source_h extraSource)
{
static_cast<DepthTypePtr>(depthData.data),
depthData.width, depthData.height,
mDepthUserData);
-
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
if (mPointcloudCallback) {
mv_3d_pointcloud_s p = {.type = MV_3D_POINTCLOUD_TYPE_PCD_BIN, .pointcloud = NULL};
GetPointcloudFromSource(input, depthData, p);
auto _pcd = std::move(pPcd);
delete _pcd;
}
+#endif
delete [] static_cast<unsigned char*>(input.data);
delete [] static_cast<unsigned char*>(input.extraData);
} catch (const std::exception &e) {
static_cast<DepthTypePtr>(depthData.data),
depthData.width, depthData.height,
handle->mDepthUserData);
-
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
if (handle->mPointcloudCallback) {
mv_3d_pointcloud_s p = {.type = MV_3D_POINTCLOUD_TYPE_PCD_BIN, .pointcloud = NULL};
//mPointcloudThread = g_thread_new("pointcloud_thread",
auto _pcd = std::move(pPcd);
delete _pcd;
}
-
+#endif
delete [] static_cast<unsigned char*>(input->data);
delete [] static_cast<unsigned char*>(input->extraData);
input.reset();
int Mv3d::WritePointcloudFile(mv_3d_pointcloud_h pointcloud, mv_3d_pointcloud_type_e type, char *fileName)
{
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
mv_3d_pointcloud_s *s = (mv_3d_pointcloud_s*) pointcloud;
if (s == NULL) {
LOGE("Pointcloud data is NULL");
utility::LogError("Failed to write {}", fullPath.c_str());
return MEDIA_VISION_ERROR_INTERNAL;
}
-
+#else
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED;
+#endif
return MEDIA_VISION_ERROR_NONE;
}
}
*/
#include <memory>
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
#include <open3d/Open3D.h>
+#endif
#include "mv_3d_internal.h"
#include "mv_private.h"
#define RANSAC_NUMBER 3
#define NUM_ITERATIONS 1000
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
using namespace open3d;
using namespace mediavision::mv3d;
+#endif
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
int mv_3d_pointcloud_plane_model_create(mv_3d_pointcloud_plane_model_h *handle)
{
MEDIA_VISION_NULL_ARG_CHECK(handle);
return MEDIA_VISION_ERROR_NONE;
}
+#else
+int mv_3d_pointcloud_plane_model_create(mv_3d_pointcloud_plane_model_h *handle)
+{
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED;
+}
+#endif
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
int mv_3d_pointcloud_plane_model_destroy(mv_3d_pointcloud_plane_model_h handle)
{
MEDIA_VISION_INSTANCE_CHECK(handle);
return MEDIA_VISION_ERROR_NONE;
}
+#else
+int mv_3d_pointcloud_plane_model_destroy(mv_3d_pointcloud_plane_model_h handle)
+{
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED;
+}
+#endif
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
int mv_3d_pointcloud_plane_inlier_create(mv_3d_pointcloud_plane_inlier_h *handle)
{
MEDIA_VISION_NULL_ARG_CHECK(handle);
return MEDIA_VISION_ERROR_NONE;
}
+#else
+int mv_3d_pointcloud_plane_inlier_create(mv_3d_pointcloud_plane_inlier_h *handle)
+{
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED;
+}
+#endif
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
int mv_3d_pointcloud_plane_inlier_destroy(mv_3d_pointcloud_plane_inlier_h handle)
{
MEDIA_VISION_INSTANCE_CHECK(handle);
return MEDIA_VISION_ERROR_NONE;
}
+#else
+int mv_3d_pointcloud_plane_inlier_destroy(mv_3d_pointcloud_plane_inlier_h handle)
+{
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED;
+}
+#endif
-/**
- * @file mv_3d_internal.c
- * @brief This file contains Media Vision 3D internal module.
- */
-
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
int mv_3d_pointcloud_segment_plane(mv_3d_h mv3d,
mv_3d_pointcloud_h pointcloud,
mv_3d_pointcloud_plane_model_h *model,
mv_3d_pointcloud_plane_inlier_h *inlier)
{
+
MEDIA_VISION_NULL_ARG_CHECK(mv3d);
MEDIA_VISION_NULL_ARG_CHECK(pointcloud);
MEDIA_VISION_NULL_ARG_CHECK(model);
return MEDIA_VISION_ERROR_NONE;
}
+#else
+int mv_3d_pointcloud_segment_plane(mv_3d_h mv3d,
+ mv_3d_pointcloud_h pointcloud,
+ mv_3d_pointcloud_plane_model_h *model,
+ mv_3d_pointcloud_plane_inlier_h *inlier)
+{
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED;
+}
+#endif
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
int mv_3d_pointcloud_plane_write_file(mv_3d_h mv3d,
mv_3d_pointcloud_plane_model_h model,
mv_3d_pointcloud_plane_inlier_h inlier,
MEDIA_VISION_FUNCTION_LEAVE();
return ret;
-}
\ No newline at end of file
+}
+#else
+int mv_3d_pointcloud_plane_write_file(mv_3d_h mv3d,
+ mv_3d_pointcloud_plane_model_h model,
+ mv_3d_pointcloud_plane_inlier_h inlier,
+ mv_3d_pointcloud_h pointcloud,
+ mv_3d_pointcloud_type_e type,
+ char *filename)
+{
+ return MEDIA_VISION_ERROR_NOT_SUPPORTED;
+}
+#endif
}
auto pMv3d = static_cast<Mv3d *>(mv3d);
- pMv3d->SetPointcloudCallback(pointcloud_cb, user_data);
+ int ret = pMv3d->SetPointcloudCallback(pointcloud_cb, user_data);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to run depth");
+ return ret;
+ }
LOGI("LEAVE");
return MEDIA_VISION_ERROR_NONE;
BuildRequires: pkgconfig(glesv2)
BuildRequires: gtest-devel
BuildRequires: pkgconfig(dfs-adaptation)
+%ifarch aarch64
BuildRequires: Open3D-devel
+%endif
%if 0%{?visualizer:1}
BuildRequires: pkgconfig(protobuf)
BuildRequires: pkgconfig(grpc++)
%endif
%cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo %{build_options} \
+%ifarch aarch64
+-DMMV_3D_POINTCLOUD_IS_AVAILABLE=TRUE \
+%endif
%if 0%{?ml_only:1}
-DBUILD_ML_ONLY=ON \
%endif
find_package(OpenCV REQUIRED core videoio imgcodecs)
if(NOT OpenCV_FOUND)
- message(SEND_ERROR "OpenCV NOT FOUND")
- return()
+ message(SEND_ERROR "OpenCV NOT FOUND")
+ return()
endif()
-find_package(Open3D REQUIRED NO_POLICY_SCOPE)
-if(NOT Open3D_FOUND)
- message(SEND_ERROR "Open3D NOT FOUND")
- return()
-else()
- include_directories(${Open3D_INCLUDE_DIRS})
+if(MV_3D_POINTCLOUD_IS_AVAILABLE)
+ find_package(Open3D REQUIRED NO_POLICY_SCOPE)
+ if(NOT Open3D_FOUND)
+ message(SEND_ERROR "Open3D NOT FOUND")
+ return()
+ else()
+ include_directories(${Open3D_INCLUDE_DIRS})
+ endif()
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format-truncation")
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
#include <open3d/Open3D.h>
+#endif
#include <mv_log_cfg.h>
#include <mv_common.h>
#define MAX_FRAMES 1800 // 30 fps * 60s
#define INTRINSIC_FILE_PATH "/usr/share/capi-media-vision/stereoCalibZedVGA.json"
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
using namespace open3d;
+#endif
class StopWatch
{
return TRUE;
}
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
void WritePointCloud(const char* data_path,
const char* color_filename,
const char* depth_filename,
utility::LogError("Failed to write {}", filename_ply);
}
}
+#endif
void _depth_stereo_cb(mv_source_h source, unsigned short *depth, unsigned int width,
unsigned int height, void *user_data)
{
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
double maxDepth = 2000.0;
double minDepth = 175.0;
double depthDenom = static_cast<double>(maxDepth - minDepth);
delete [] vertex3d;
vertex3d = NULL;
__signal();
+#endif
}
static void stereo_handoff(GstElement *object, GstBuffer *buffer, GstPad *pad,
display_xpos = atoi(argv[7]);
display_ypos = atoi(argv[8]);
}
-
+#ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
utility::SetVerbosityLevel(utility::VerbosityLevel::Debug);
+#endif
SrcData srcData;
int ret = MEDIA_VISION_ERROR_NONE;