+++ /dev/null
-/**
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <memory>
-#include <open3d/Open3D.h>
-
-#include "mv_3d_internal.h"
-#include "mv_private.h"
-#include "mv_3d_private.h"
-#include "Mv3d.h"
-
-#define DISTANCE_THRESHOLD 0.01
-#define RANSAC_NUMBER 3
-#define NUM_ITERATIONS 1000
-
-using namespace open3d;
-using namespace mediavision::mv3d;
-
-int mv_3d_pointcloud_plane_model_create(mv_3d_pointcloud_plane_model_h *handle)
-{
- MEDIA_VISION_NULL_ARG_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- /* do nothing */
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_3d_pointcloud_plane_model_destroy(mv_3d_pointcloud_plane_model_h handle)
-{
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- Eigen::Vector4d *model = (Eigen::Vector4d *) handle;
- delete model;
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_3d_pointcloud_plane_inlier_create(mv_3d_pointcloud_plane_inlier_h *handle)
-{
- MEDIA_VISION_NULL_ARG_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- /* do nothing */
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv_3d_pointcloud_plane_inlier_destroy(mv_3d_pointcloud_plane_inlier_h handle)
-{
- MEDIA_VISION_INSTANCE_CHECK(handle);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- std::vector<size_t> *inlier = (std::vector<size_t> *) handle;
- delete inlier;
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-/**
- * @file mv_3d_internal.c
- * @brief This file contains Media Vision 3D internal module.
- */
-
-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);
- MEDIA_VISION_NULL_ARG_CHECK(inlier);
- MEDIA_VISION_FUNCTION_ENTER();
-
- mv_3d_pointcloud_s *s = (mv_3d_pointcloud_s*) pointcloud;
- Eigen::Vector4d *best_plane_model = new Eigen::Vector4d;
- std::vector<size_t> *plane_inlier = new std::vector<size_t>;
- auto pPcd = static_cast<std::shared_ptr<open3d::geometry::PointCloud>*>(s->pointcloud);
- open3d::geometry::PointCloud p;
- p += **pPcd;
-
- std::tie(*best_plane_model, *plane_inlier) = p.SegmentPlane(DISTANCE_THRESHOLD, RANSAC_NUMBER, NUM_ITERATIONS);
- *model = (mv_3d_pointcloud_plane_model_h) best_plane_model;
- *inlier = (mv_3d_pointcloud_plane_inlier_h) plane_inlier;
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-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)
-{
- MEDIA_VISION_NULL_ARG_CHECK(mv3d);
- MEDIA_VISION_NULL_ARG_CHECK(model);
- MEDIA_VISION_NULL_ARG_CHECK(inlier);
- MEDIA_VISION_FUNCTION_ENTER();
-
- mv_3d_pointcloud_s *s = (mv_3d_pointcloud_s*) pointcloud;
- Eigen::Vector4d *best_plane_model = (Eigen::Vector4d*) model;
- std::vector<size_t> *plane_inlier = (std::vector<size_t>*) inlier;
- auto pPcd = static_cast<std::shared_ptr<open3d::geometry::PointCloud>*>(s->pointcloud);
- open3d::geometry::PointCloud p;
- p += **pPcd;
-
- std::shared_ptr<geometry::PointCloud> plane = p.SelectByIndex(*plane_inlier);
- mv_3d_pointcloud_s _pcd = {.type = MV_3D_POINTCLOUD_TYPE_PCD_BIN, .pointcloud = NULL};
- _pcd.pointcloud = static_cast<void*>(
- new std::shared_ptr<open3d::geometry::PointCloud>(
- std::move(plane)));
- mv_3d_pointcloud_h pcd = &_pcd;
-
- auto pMv3d = static_cast<Mv3d *>(mv3d);
- int ret = pMv3d->WritePointcloudFile(pcd, type, filename);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to write pointcloud plane file");
- ret = MEDIA_VISION_ERROR_INTERNAL;
- }
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <memory>
+#include <open3d/Open3D.h>
+
+#include "mv_3d_internal.h"
+#include "mv_private.h"
+#include "mv_3d_private.h"
+#include "Mv3d.h"
+
+#define DISTANCE_THRESHOLD 0.01
+#define RANSAC_NUMBER 3
+#define NUM_ITERATIONS 1000
+
+using namespace open3d;
+using namespace mediavision::mv3d;
+
+int mv_3d_pointcloud_plane_model_create(mv_3d_pointcloud_plane_model_h *handle)
+{
+ MEDIA_VISION_NULL_ARG_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ /* do nothing */
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_3d_pointcloud_plane_model_destroy(mv_3d_pointcloud_plane_model_h handle)
+{
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ Eigen::Vector4d *model = (Eigen::Vector4d *) handle;
+ delete model;
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_3d_pointcloud_plane_inlier_create(mv_3d_pointcloud_plane_inlier_h *handle)
+{
+ MEDIA_VISION_NULL_ARG_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ /* do nothing */
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_3d_pointcloud_plane_inlier_destroy(mv_3d_pointcloud_plane_inlier_h handle)
+{
+ MEDIA_VISION_INSTANCE_CHECK(handle);
+
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ std::vector<size_t> *inlier = (std::vector<size_t> *) handle;
+ delete inlier;
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+/**
+ * @file mv_3d_internal.c
+ * @brief This file contains Media Vision 3D internal module.
+ */
+
+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);
+ MEDIA_VISION_NULL_ARG_CHECK(inlier);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ mv_3d_pointcloud_s *s = (mv_3d_pointcloud_s*) pointcloud;
+ Eigen::Vector4d *best_plane_model = new Eigen::Vector4d;
+ std::vector<size_t> *plane_inlier = new std::vector<size_t>;
+ auto pPcd = static_cast<std::shared_ptr<open3d::geometry::PointCloud>*>(s->pointcloud);
+ open3d::geometry::PointCloud p;
+ p += **pPcd;
+
+ std::tie(*best_plane_model, *plane_inlier) = p.SegmentPlane(DISTANCE_THRESHOLD, RANSAC_NUMBER, NUM_ITERATIONS);
+ *model = (mv_3d_pointcloud_plane_model_h) best_plane_model;
+ *inlier = (mv_3d_pointcloud_plane_inlier_h) plane_inlier;
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+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)
+{
+ MEDIA_VISION_NULL_ARG_CHECK(mv3d);
+ MEDIA_VISION_NULL_ARG_CHECK(model);
+ MEDIA_VISION_NULL_ARG_CHECK(inlier);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ mv_3d_pointcloud_s *s = (mv_3d_pointcloud_s*) pointcloud;
+ std::vector<size_t> *plane_inlier = (std::vector<size_t>*) inlier;
+ auto pPcd = static_cast<std::shared_ptr<open3d::geometry::PointCloud>*>(s->pointcloud);
+ open3d::geometry::PointCloud p;
+ p += **pPcd;
+
+ std::shared_ptr<geometry::PointCloud> plane = p.SelectByIndex(*plane_inlier);
+ mv_3d_pointcloud_s _pcd = {.type = MV_3D_POINTCLOUD_TYPE_PCD_BIN, .pointcloud = NULL};
+ _pcd.pointcloud = static_cast<void*>(
+ new std::shared_ptr<open3d::geometry::PointCloud>(
+ std::move(plane)));
+ mv_3d_pointcloud_h pcd = &_pcd;
+
+ auto pMv3d = static_cast<Mv3d *>(mv3d);
+ int ret = pMv3d->WritePointcloudFile(pcd, type, filename);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to write pointcloud plane file");
+ ret = MEDIA_VISION_ERROR_INTERNAL;
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+
+ return ret;
+}
\ No newline at end of file
boxes.push_back(box);
}
boxList.push_back(boxes);
- } else { // INFERENCE_BOX_DECODING_TYPE_YOLO_ANCHOR
- int cellIdx = idx * mBoxOffset;
}
}
const char* formats[] = {"pfm", "png"};
int sel_fmt = -1;
- while(sel_fmt <= 0 || sel_fmt > ARRAY_SIZE(formats)) {
+ while(sel_fmt <= 0 || sel_fmt > static_cast<int>(ARRAY_SIZE(formats))) {
sel_fmt = show_menu_linear("Select Action", formats, ARRAY_SIZE(formats));
}
FILE* fp = fopen(calibFilename, "r");
char line[MAX_STRING_LENGTH];
float fVal;
- float dmin, dmax;
+ float dmin = 0, dmax = 0;
int iVal;
- int width, height;
+ int width = 0, height = 0;
if (fp != NULL) {
while (fgets(line, MAX_STRING_LENGTH, fp) != NULL) {
if (sscanf(line, "vmin= %f", &fVal) == 1) dmin = fVal;
const char* names[] = {"Middlebury - TrainingQ(Imperf)"};
int sel_opt = show_menu_linear("Select Action", names, ARRAY_SIZE(names));
- if (sel_opt <= 0 || sel_opt > ARRAY_SIZE(names)) {
+ if (sel_opt <= 0 || sel_opt > static_cast<int>(ARRAY_SIZE(names))) {
printf("Invalid option");
return -1;
}
} appdata;
static float *vertex3d = NULL;
-static unsigned char *data_buffer_3d = NULL;
mv_source_h mv_source3d;
gulong handler;
static int maxDisp;
static int display_xpos;
static int display_ypos;
-static int fidx = 0;
void int_handler(int sig)
{
char c;
if (c == 'y' || c == 'Y') {
g_signal_handler_disconnect(fsink, handler);
printf("delete buffer, used by visualize 3d\n");
- //if (data_buffer_3d != NULL) {
- // delete [] data_buffer_3d;
- // data_buffer_3d = NULL;
- //}
gst_element_send_event(pipecam, gst_event_new_eos());
gst_element_send_event(pipedepth, gst_event_new_eos());
void _depth_stereo_cb(mv_source_h source, unsigned short *depth, unsigned int width,
unsigned int height, void *user_data)
{
-#if 0
- if (!user_data) {
- LOGW("user_data is null, Skip...");
- return;
- }
-
- GstMapInfo *buffer = static_cast<GstMapInfo *>(user_data);
-
-
- for (int j = 0; j < height; j++) {
- for (int i = 0; i < width; ++i) {
- buffer->data[j * width + i] =
- static_cast<unsigned short>(depth[j * width + i]);
- }
- }
-#endif
double maxDepth = 2000.0;
double minDepth = 175.0;
double depthDenom = static_cast<double>(maxDepth - minDepth);
false);
cv::Mat colorMap = cv::Mat(cv::Size(width,height), CV_8UC1);
- for (int j = 0; j < height; ++j) {
- for (int i = 0; i < width; ++i) {
+ for (unsigned int j = 0; j < height; ++j) {
+ for (unsigned int i = 0; i < width; ++i) {
int idx = j * width + i;
int idxInv = width * height - idx - 1;
auto depth_raw = pcd->points_.data()[idx][2] * 1000.0;