option(BUILD_ML_ONLY "Build mv_machine_learning only" OFF)
option(BUILD_VISUALIZER "Build visualizer for testing 2D/3D output" OFF)
+option(BUILD_CAMERA_PACKET "Build camera packet output test" OFF)
if(BUILD_VISUALIZER)
add_compile_definitions(BUILD_VISUALIZER)
set(SRC_FILES ${SRC_FILES} testsuites/mv3d/test_3d.cpp)
endif()
+if (${BUILD_CAMERA_PACKET})
+set(SRC_FILES ${SRC_FILES} testsuites/common/test_camera_pkt.cpp)
+endif()
+
add_executable(${PROJECT_NAME} ${SRC_FILES})
target_link_libraries(${PROJECT_NAME}
gtest gtest_main mv_inference mv_image_helper
target_link_libraries(${PROJECT_NAME} mv_3d)
endif()
+if (${BUILD_CAMERA_PACKET})
+target_link_libraries(${PROJECT_NAME} capi-media-camera)
+endif()
+
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
\ No newline at end of file
--- /dev/null
+#include <gtest/gtest.h>
+#include <camera.h>
+#include <mv_common.h>
+
+/* This test needs camera privilege and to be owner user*/
+
+static void _camera_preview_cb(media_packet_h pkt, void *user_data)
+{
+ mv_source_h mv_source;
+ ASSERT_EQ(mv_create_source(&mv_source), MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(mv_source_fill_by_media_packet(mv_source, pkt), MEDIA_VISION_ERROR_NONE);
+ ASSERT_EQ(media_packet_unref(pkt), MEDIA_PACKET_ERROR_NONE);
+ ASSERT_EQ(mv_destroy_source(mv_source), MEDIA_VISION_ERROR_NONE);
+}
+
+TEST(Camera, MediaPacket)
+{
+ camera_h camera;
+ ASSERT_EQ(camera_create(CAMERA_DEVICE_CAMERA0, &camera), CAMERA_ERROR_NONE);
+ ASSERT_TRUE(camera_is_supported_media_packet_preview_cb(camera));
+ ASSERT_EQ(camera_set_media_packet_preview_cb(camera, _camera_preview_cb, NULL), CAMERA_ERROR_NONE);
+ ASSERT_EQ(camera_start_preview(camera), CAMERA_ERROR_NONE);
+ sleep(1);
+ ASSERT_EQ(camera_stop_preview(camera), CAMERA_ERROR_NONE);
+ ASSERT_EQ(camera_destroy(camera), CAMERA_ERROR_NONE);
+}
\ No newline at end of file