Apply da timestamp to mv_3d 56/289256/3 accepted/tizen/7.0/unified/20230307.080144
authorTae-Young Chung <ty83.chung@samsung.com>
Fri, 3 Mar 2023 08:29:21 +0000 (17:29 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Mon, 6 Mar 2023 02:29:57 +0000 (11:29 +0900)
[Version] 0.23.44
[Issue type] update

In case of da profile, mv_source_h can be filled by buffer with timestamp.
When the mv_source_h with the timestamp is given to mv_3d_run_async()
an user can get the timestamp from a mv_source_h which is given through
the mv_3d_depth_cb().

Change-Id: I7b9933144dded08d4163e09465d9d19423def8e5
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
mv_3d/3d/src/Mv3d.cpp
packaging/capi-media-vision.spec
test/testsuites/mv3d/depthstream_test_suite.cpp

index 50bc3403bb1ac9d5de2a9310742f02d0f0516f6b..fbf6b3f5696e17686a741675b0be1001109c541d 100644 (file)
@@ -21,7 +21,9 @@
 #include <opencv2/core.hpp>
 #include <opencv2/imgcodecs.hpp>
 #include <opencv2/imgproc.hpp>
-
+#ifdef WITH_DA_PROFILE
+#include <mv_common_internal.h>
+#endif
 #ifdef MV_3D_POINTCLOUD_IS_AVAILABLE
 #include <open3d/Open3D.h>
 using namespace open3d;
@@ -44,6 +46,9 @@ namespace mv3d
 
                delete[] static_cast<unsigned char *>(remained->data);
                delete[] static_cast<unsigned char *>(remained->extraData);
+#ifdef WITH_DA_PROFILE
+               delete static_cast<da_timestamp_s *>(remained->timestamp);
+#endif
 
                delete remained;
        }
@@ -253,7 +258,11 @@ namespace mv3d
                input.stride = stride;
                input.format = (mWidth == width && mHeight * 2 == height) ?
                        DFS_DATA_INPUT_FORMAT_COUPLED_TB : DFS_DATA_INPUT_FORMAT_COUPLED_SBS;
-
+#ifdef WITH_DA_PROFILE
+               da_timestamp_s *timestamp = new da_timestamp_s;
+               mv_source_get_timestamp(baseSource, timestamp);
+               input.timestamp = static_cast<void *>(timestamp);
+#endif
                if (extraSource)
                {
                        extraBuffer = nullptr;
@@ -435,6 +444,17 @@ namespace mv3d
 
                        auto depthData = handle->mDfsAdaptor->getOutputData();
                        auto leftData = handle->mDfsAdaptor->getLeftData();
+#ifdef WITH_DA_PROFILE
+                       int ret = mv_source_fill_by_buffer_da(handle->mInternalSource,
+                                                               static_cast<unsigned char*>(leftData.data),
+                                                               leftData.stride * leftData.height,
+                                                               leftData.width,
+                                                               leftData.height,
+                                                               leftData.stride,
+                                                               leftData.type == DFS_DATA_TYPE_UINT8C3 ? MEDIA_VISION_COLORSPACE_RGB888 :
+                                                                                                                                                MEDIA_VISION_COLORSPACE_Y800,
+                                                               static_cast<da_timestamp_s*>(pInput->timestamp));
+#else
                        int ret = mv_source_fill_by_buffer(handle->mInternalSource,
                                                                static_cast<unsigned char*>(leftData.data),
                                                                leftData.stride * leftData.height,
@@ -442,6 +462,7 @@ namespace mv3d
                                                                leftData.height,
                                                                leftData.type == DFS_DATA_TYPE_UINT8C3 ? MEDIA_VISION_COLORSPACE_RGB888 :
                                                                                                                                                 MEDIA_VISION_COLORSPACE_Y800);
+#endif
                        if (MEDIA_VISION_ERROR_NONE != ret) {
                                LOGW("Errors were occurred during source filling %i", ret);
                                continue;
@@ -462,6 +483,9 @@ namespace mv3d
 #endif
                        delete[] static_cast<unsigned char *>(pInput->data);
                        delete[] static_cast<unsigned char *>(pInput->extraData);
+#ifdef WITH_DA_PROFILE
+                       delete static_cast<da_timestamp_s *>(pInput->timestamp);
+#endif
                        mv_source_clear(handle->mInternalSource);
                }
 
index fd442b3ce4e7674d651f2b9c89305973cb0074cd..407383d32246b04299ec184c1c423bbf51c222ae 100644 (file)
@@ -1,6 +1,6 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.23.43
+Version:     0.23.44
 Release:     0
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-3-Clause
index 552493b36e98366763a6a931c01e88d939366089..b597f81900865702c8afff0beb6c2cf0f7f49e9b 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <math.h>
+#include <inttypes.h>
 #include <opencv2/core.hpp>
 #include <opencv2/imgcodecs.hpp>
 #include <opencv2/imgproc.hpp>
@@ -34,6 +35,9 @@
 #include "mv_3d.h"
 #include <mv_testsuite_common.h>
 #include <vision_source.h>
+#ifdef WITH_DA_PROFILE
+#include <mv_common_internal.h>
+#endif
 
 #include <glib-2.0/glib.h>
 #include <gst/gst.h>
@@ -183,6 +187,19 @@ static void _depth_stereo_cb(mv_source_h source, unsigned short *depth, unsigned
 {
        auto mv3d = static_cast<appdata *>(user_data);
 
+#ifdef WITH_DA_PROFILE
+       printf("_depth_stereo_cb: ");
+       da_timestamp_s timestamp;
+       mv_source_get_timestamp(source, &timestamp);
+       printf("timestamp [%"PRIu64"],\
+                       ts_sof[%"PRIu64"],\
+                       ts_aux[%"PRIu64"],\
+                       ts_eof[%"PRIu64"]\n",
+                       timestamp.timestamp,
+                       timestamp.ts_sof,
+                       timestamp.ts_aux,
+                       timestamp.ts_eof);
+#endif
        cv::Mat dump(cv::Size(width, height), CV_16U);
 
        for (int y = 0; y < height; y++) {
@@ -205,6 +222,17 @@ static int _vision_source_cb(vision_source_buffer_s *buffer, void *user_data)
 
        printf("_vision_source_cb: %lld ms\n", static_cast<long long int>(app->stopWatch.elapsedTime().count()));
 
+
+#ifdef WITH_DA_PROFILE
+       mv_source_fill_by_buffer_da(app->mv_source,
+                                                               buffer->planes[0].data,
+                                                               buffer->resolution.width * buffer->resolution.height,
+                                                               buffer->resolution.width,
+                                                               buffer->resolution.height,
+                                                               buffer->planes[0].align_width,
+                                                               MEDIA_VISION_COLORSPACE_Y800,
+                                                               static_cast<da_timestamp_s *>(buffer->priv));
+#else
        for (unsigned int h = 0; h < buffer->resolution.height; h++) {
                memcpy(app->buffer + buffer->resolution.width * h,
                                buffer->planes[0].data + (buffer->planes[0].align_width * h),
@@ -212,6 +240,7 @@ static int _vision_source_cb(vision_source_buffer_s *buffer, void *user_data)
        }
        mv_source_fill_by_buffer(app->mv_source, app->buffer, app->imgWidth * app->imgHeight,
                                                        app->imgWidth, app->imgHeight, MEDIA_VISION_COLORSPACE_Y800);
+#endif
 
        if (isAsync)
                mv_3d_run_async(app->mv3d_handle, app->mv_source, nullptr, nullptr);