diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 1ea4d0b..89b41e0 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -88,7 +88,7 @@ if(OS_MAC) else() # samples above device layer - make_executable(camera_use_device + make_executable(camera_with_junior_device_api SRCS device_camera.cc LINK_LIBS mynteye ${OpenCV_LIBS} DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH} @@ -99,7 +99,7 @@ else() if(WITH_API) ## camera_a - make_executable(camera_use_api + make_executable(camera_with_senior_api SRCS api_camera.cc LINK_LIBS mynteye ${OpenCV_LIBS} DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH} diff --git a/samples/data_get_points.cc b/samples/data_get_points.cc deleted file mode 100644 index 668ad40..0000000 --- a/samples/data_get_points.cc +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2018 Slightech 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 -#include - -#include "mynteye/api/api.h" - -#include "util_pc_viewer.h" - -MYNTEYE_USE_NAMESPACE - -int main(int argc, char *argv[]) { - auto &&api = API::Create(argc, argv); - if (!api) return 1; - - bool ok; - auto &&request = api->SelectStreamRequest(&ok); - if (!ok) return 1; - api->ConfigStreamRequest(request); - - api->EnableStreamData(Stream::POINTS); - - api->Start(Source::VIDEO_STREAMING); - - double fps; - double t = 0.01; - std::cout << "points cloud fps:" << std::endl; - - cv::namedWindow("frame"); - PCViewer pcviewer; - - while (true) { - api->WaitForStreams(); - - auto &&left_data = api->GetStreamData(Stream::LEFT); - auto &&right_data = api->GetStreamData(Stream::RIGHT); - if (!left_data.frame.empty() && !right_data.frame.empty()) { - cv::Mat img; - cv::hconcat(left_data.frame, right_data.frame, img); - cv::imshow("frame", img); - } - - auto &&points_data = api->GetStreamData(Stream::POINTS); - if (!points_data.frame.empty()) { - double t_c = cv::getTickCount() / cv::getTickFrequency(); - fps = 1.0/(t_c - t); - printf("\b\b\b\b\b\b\b\b\b%.2f", fps); - t = t_c; - pcviewer.Update(points_data.frame); - } - - char key = static_cast(cv::waitKey(1)); - if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q - break; - } - if (pcviewer.WasStopped()) { - break; - } - } - - api->Stop(Source::VIDEO_STREAMING); - return 0; -} diff --git a/samples/data_get_stereo.cc b/samples/data_get_stereo.cc deleted file mode 100644 index 7543282..0000000 --- a/samples/data_get_stereo.cc +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2018 Slightech 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 -#include - -#include "mynteye/api/api.h" - -MYNTEYE_USE_NAMESPACE - -int main(int argc, char *argv[]) { - auto &&api = API::Create(argc, argv); - if (!api) return 1; - - bool ok; - auto &&request = api->SelectStreamRequest(&ok); - if (!ok) return 1; - api->ConfigStreamRequest(request); - api->Start(Source::VIDEO_STREAMING); - - double fps; - double t = 0.01; - std::cout << "fps:" << std::endl; - - cv::namedWindow("frame"); - - while (true) { - api->WaitForStreams(); - - auto &&left_data = api->GetStreamData(Stream::LEFT); - auto &&right_data = api->GetStreamData(Stream::RIGHT); - - cv::Mat img; - if (!left_data.frame.empty() && !right_data.frame.empty()) { - double t_c = cv::getTickCount() / cv::getTickFrequency(); - fps = 1.0/(t_c - t); - printf("\b\b\b\b\b\b\b\b\b%.2f", fps); - t = t_c; - cv::hconcat(left_data.frame, right_data.frame, img); - cv::imshow("frame", img); - } - - char key = static_cast(cv::waitKey(1)); - if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q - break; - } - } - - api->Stop(Source::VIDEO_STREAMING); - return 0; -} diff --git a/samples/intermediate_get_depth_and_points.cc b/samples/intermediate_get_depth_and_points.cc deleted file mode 100644 index d13b3ed..0000000 --- a/samples/intermediate_get_depth_and_points.cc +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2018 Slightech 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 -#include - -// #include "mynteye/logger.h" -#include "mynteye/api/api.h" - -#include "util_cv_painter.h" -#include "util_pc_viewer.h" - -namespace { - -class DepthRegion { - public: - explicit DepthRegion(std::uint32_t n) - : n_(std::move(n)), show_(false), selected_(false), point_(0, 0) {} - - ~DepthRegion() = default; - - /** - * 鼠标事件:默认不选中区域,随鼠标移动而显示。单击后,则会选中区域来显示。你可以再单击已选中区域或双击未选中区域,取消选中。 - */ - void OnMouse(const int &event, const int &x, const int &y, const int &flags) { - MYNTEYE_UNUSED(flags) - if (event != cv::EVENT_MOUSEMOVE && event != cv::EVENT_LBUTTONDOWN) { - return; - } - show_ = true; - - if (event == cv::EVENT_MOUSEMOVE) { - if (!selected_) { - point_.x = x; - point_.y = y; - } - } else if (event == cv::EVENT_LBUTTONDOWN) { - if (selected_) { - if (x >= static_cast(point_.x - n_) && - x <= static_cast(point_.x + n_) && - y >= static_cast(point_.y - n_) && - y <= static_cast(point_.y + n_)) { - selected_ = false; - } - } else { - selected_ = true; - } - point_.x = x; - point_.y = y; - } - } - - template - void ShowElems( - const cv::Mat &depth, - std::function elem2string, - int elem_space = 40, - std::function - getinfo = nullptr) { - if (!show_) - return; - - int space = std::move(elem_space); - int n = 2 * n_ + 1; - cv::Mat im(space * n, space * n, CV_8UC3, cv::Scalar(255, 255, 255)); - - int x, y; - std::string str; - int baseline = 0; - for (int i = -n_; i <= n; ++i) { - x = point_.x + i; - if (x < 0 || x >= depth.cols) - continue; - for (int j = -n_; j <= n; ++j) { - y = point_.y + j; - if (y < 0 || y >= depth.rows) - continue; - - str = elem2string(depth.at(y, x)); - - cv::Scalar color(0, 0, 0); - if (i == 0 && j == 0) - color = cv::Scalar(0, 0, 255); - - cv::Size sz = - cv::getTextSize(str, cv::FONT_HERSHEY_PLAIN, 1, 1, &baseline); - - cv::putText( - im, str, cv::Point( - (i + n_) * space + (space - sz.width) / 2, - (j + n_) * space + (space + sz.height) / 2), - cv::FONT_HERSHEY_PLAIN, 1, color, 1); - } - } - - if (getinfo) { - std::string info = getinfo(depth, point_, n_); - if (!info.empty()) { - cv::Size sz = - cv::getTextSize(info, cv::FONT_HERSHEY_PLAIN, 1, 1, &baseline); - - cv::putText( - im, info, cv::Point(5, 5 + sz.height), cv::FONT_HERSHEY_PLAIN, 1, - cv::Scalar(255, 0, 255), 1); - } - } - - cv::imshow("region", im); - } - - void DrawRect(cv::Mat &image) { // NOLINT - if (!show_) - return; - std::uint32_t n = (n_ > 1) ? n_ : 1; - n += 1; // outside the region - cv::rectangle( - image, cv::Point(point_.x - n, point_.y - n), - cv::Point(point_.x + n, point_.y + n), - selected_ ? cv::Scalar(0, 255, 0) : cv::Scalar(0, 0, 255), 1); - } - - private: - std::uint32_t n_; - bool show_; - bool selected_; - cv::Point point_; -}; - -void OnDepthMouseCallback(int event, int x, int y, int flags, void *userdata) { - DepthRegion *region = reinterpret_cast(userdata); - region->OnMouse(event, x, y, flags); -} - -} // namespace - -MYNTEYE_USE_NAMESPACE - -int main(int argc, char *argv[]) { - auto &&api = API::Create(argc, argv); - if (!api) return 1; - - bool ok; - auto &&request = api->SelectStreamRequest(&ok); - if (!ok) return 1; - api->ConfigStreamRequest(request); - - api->SetOptionValue(Option::IR_CONTROL, 80); - api->SetDisparityComputingMethodType(DisparityComputingMethod::BM); - api->EnableStreamData(Stream::DISPARITY_NORMALIZED); - api->EnableStreamData(Stream::POINTS); - api->EnableStreamData(Stream::DEPTH); - - api->Start(Source::VIDEO_STREAMING); - - cv::namedWindow("frame"); - cv::namedWindow("depth"); - cv::namedWindow("region"); - - DepthRegion depth_region(3); - auto depth_info = []( - const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) { - MYNTEYE_UNUSED(depth) - std::ostringstream os; - os << "depth pos: [" << point.y << ", " << point.x << "]" - << "±" << n << ", unit: mm"; - return os.str(); - }; - - CVPainter painter; - PCViewer pcviewer; - - while (true) { - api->WaitForStreams(); - - auto &&left_data = api->GetStreamData(Stream::LEFT); - auto &&right_data = api->GetStreamData(Stream::RIGHT); - - cv::Mat img; - cv::hconcat(left_data.frame, right_data.frame, img); - - painter.DrawImgData(img, *left_data.img); - - cv::imshow("frame", img); - // LOG(INFO) << "left id: " << left_data.frame_id - // << ", right id: " << right_data.frame_id; - - auto &&disp_data = api->GetStreamData(Stream::DISPARITY_NORMALIZED); - auto &&depth_data = api->GetStreamData(Stream::DEPTH); - if (!disp_data.frame.empty() && !depth_data.frame.empty()) { - // Show disparity instead of depth, but show depth values in region. - auto &&depth_frame = disp_data.frame; - -#ifdef WITH_OPENCV3 - // ColormapTypes - // http://docs.opencv.org/master/d3/d50/group__imgproc__colormap.html#ga9a805d8262bcbe273f16be9ea2055a65 - cv::applyColorMap(depth_frame, depth_frame, cv::COLORMAP_JET); -#endif - - cv::setMouseCallback("depth", OnDepthMouseCallback, &depth_region); - // Note: DrawRect will change some depth values to show the rect. - depth_region.DrawRect(depth_frame); - - cv::imshow("depth", depth_frame); - // LOG(INFO) << "depth id: " << disp_data.frame_id; - - depth_region.ShowElems( - depth_data.frame, - [](const ushort &elem) { - if (elem >= 10000) { - // Filter errors, or limit to valid range. - // - // reprojectImageTo3D(), missing values will set to 10000 - // https://docs.opencv.org/master/d9/d0c/group__calib3d.html#ga1bc1152bd57d63bc524204f21fde6e02 - return std::string("invalid"); - } - return std::to_string(elem); - }, - 80, depth_info); - } - - auto &&points_data = api->GetStreamData(Stream::POINTS); - if (!points_data.frame.empty()) { - pcviewer.Update(points_data.frame); - // LOG(INFO) << "points id: " << points_data.frame_id; - } - - char key = static_cast(cv::waitKey(1)); - if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q - break; - } - if (pcviewer.WasStopped()) { - break; - } - } - - api->Stop(Source::VIDEO_STREAMING); - return 0; -} diff --git a/samples/mynteye_demo.cc b/samples/mynteye_demo.cc deleted file mode 100644 index ee06f33..0000000 --- a/samples/mynteye_demo.cc +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2018 Slightech 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 -#include - -#include "mynteye/api/api.h" - -MYNTEYE_USE_NAMESPACE - -int main(int argc, char const *argv[]) { - auto &&api = API::Create(0, nullptr); - if (!api) return 1; - - bool ok; - auto &&request = api->SelectStreamRequest(&ok); - if (!ok) return 1; - api->ConfigStreamRequest(request); - api->Start(Source::VIDEO_STREAMING); - - double fps; - double t = 0.01; - std::cout << "fps:" << std::endl; - - cv::namedWindow("frame"); - - while (true) { - api->WaitForStreams(); - - auto &&left_data = api->GetStreamData(Stream::LEFT); - auto &&right_data = api->GetStreamData(Stream::RIGHT); - - cv::Mat img; - if (!left_data.frame.empty() && !right_data.frame.empty()) { - double t_c = cv::getTickCount() / cv::getTickFrequency(); - fps = 1.0/(t_c - t); - printf("\b\b\b\b\b\b\b\b\b%.2f", fps); - t = t_c; - cv::hconcat(left_data.frame, right_data.frame, img); - cv::imshow("frame", img); - } - - char key = static_cast(cv::waitKey(1)); - if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q - break; - } - } - - api->Stop(Source::VIDEO_STREAMING); - return 0; -} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 18be45b..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright 2018 Slightech 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. - -cmake_minimum_required(VERSION 3.0) - -project(mynteye_test VERSION 2.0.0 LANGUAGES C CXX) - -get_filename_component(PRO_DIR ${PROJECT_SOURCE_DIR} DIRECTORY) - -include(${PRO_DIR}/cmake/Common.cmake) -include(${PRO_DIR}/cmake/Utils.cmake) - -# flags - -if(OS_WIN) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") -else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") -endif() - -include(${PRO_DIR}/cmake/DetectCXX11.cmake) - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") - -#if(OS_WIN AND NOT MINGW) -# set(CompilerFlags -# CMAKE_CXX_FLAGS -# CMAKE_CXX_FLAGS_DEBUG -# CMAKE_CXX_FLAGS_RELEASE -# CMAKE_C_FLAGS -# CMAKE_C_FLAGS_DEBUG -# CMAKE_C_FLAGS_RELEASE -# ) -# foreach(CompilerFlag ${CompilerFlags}) -# string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") -# endforeach() -#endif() - -string(STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS) -string(STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS) -message(STATUS "C_FLAGS: ${CMAKE_C_FLAGS}") -message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}") - -# packages - -LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/_install/lib/cmake) -find_package(mynteye REQUIRED) -message(STATUS "Found mynteye: ${mynteye_VERSION}") - -include(${PRO_DIR}/cmake/DetectOpenCV.cmake) - -if(mynteye_WITH_GLOG) - include(${PRO_DIR}/cmake/DetectGLog.cmake) -endif() - -#LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake) - -## gtest - -set(TEST_DIR ${PROJECT_SOURCE_DIR}) -set(GMOCK_DIR ${TEST_DIR}/gtest/googlemock) -set(GTEST_DIR ${TEST_DIR}/gtest/googletest) - -set(GMOCK_LIB_DIR ${TEST_DIR}/gtest/_build/googlemock) -set(GTEST_LIB_DIR ${GMOCK_LIB_DIR}/gtest) -if(OS_WIN AND NOT MINGW) - set(GTEST_LIB_DIR ${GTEST_LIB_DIR}/Release) -endif() - -set(GTEST_LIBS - ${GTEST_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} - #${GTEST_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} -) -message(STATUS "Found gtest libs: ${GTEST_LIBS}") - -# targets - -set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output") - -set_outdir( - "${OUT_DIR}/lib" - "${OUT_DIR}/lib" - "${OUT_DIR}/bin" -) - -include_directories( - ${GTEST_DIR}/include - ${PRO_DIR}/src -) - -file(GLOB TEST_INTERNAL_SRC "internal/*.cc") -file(GLOB TEST_PUBLIC_SRC "public/*.cc") - -make_executable(${PROJECT_NAME} - SRCS gtest_main.cc ${TEST_INTERNAL_SRC} ${TEST_PUBLIC_SRC} - LINK_LIBS mynteye ${GTEST_LIBS} ${OpenCV_LIBS} - DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH} -) diff --git a/test/device/types_test.cc b/test/device/types_test.cc deleted file mode 100644 index 083cf9b..0000000 --- a/test/device/types_test.cc +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2018 Slightech 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 "gtest/gtest.h" - -#include "mynteye/device/types.h" - -MYNTEYE_USE_NAMESPACE - -class VersionTest : public ::testing::Test { - protected: - VersionTest() - : ver_1_0(Version(1, 0)), - ver_1_2(Version(1, 2)), - ver_2_0(Version(2, 0)) {} - - virtual ~VersionTest() {} - - virtual void SetUp() {} - - virtual void TearDown() {} - - Version ver_1_0; - Version ver_1_2; - Version ver_2_0; -}; - -TEST_F(VersionTest, Properties) { - EXPECT_EQ(1, ver_1_0.major()); - EXPECT_EQ(0, ver_1_0.minor()); -} - -TEST_F(VersionTest, Operators) { - EXPECT_TRUE(ver_1_0 == ver_1_0); - EXPECT_TRUE(ver_1_0 <= ver_1_2); - EXPECT_TRUE(ver_1_0 != ver_1_2); - EXPECT_TRUE(ver_1_0 < ver_1_2); - EXPECT_TRUE(ver_1_2 > ver_1_0); - EXPECT_TRUE(ver_1_2 >= ver_1_0); - - EXPECT_TRUE(ver_1_0 <= ver_1_0); - EXPECT_TRUE(ver_1_2 >= ver_1_2); - - EXPECT_TRUE(ver_1_2 == ver_1_2); - EXPECT_TRUE(ver_1_2 <= ver_2_0); - EXPECT_TRUE(ver_1_2 != ver_2_0); - EXPECT_TRUE(ver_1_2 < ver_2_0); - EXPECT_TRUE(ver_2_0 > ver_1_2); - EXPECT_TRUE(ver_2_0 >= ver_1_2); - - EXPECT_TRUE(ver_1_2 <= ver_1_2); - EXPECT_TRUE(ver_2_0 >= ver_2_0); -} - -TEST_F(VersionTest, Between) { - EXPECT_TRUE(ver_1_0.is_between(ver_1_0, ver_2_0)); - EXPECT_TRUE(ver_1_2.is_between(ver_1_0, ver_2_0)); - EXPECT_TRUE(ver_2_0.is_between(ver_1_0, ver_2_0)); - - EXPECT_FALSE(ver_1_0.is_between(ver_1_2, ver_2_0)); - EXPECT_FALSE(ver_2_0.is_between(ver_1_0, ver_1_2)); -} - -TEST_F(VersionTest, Strings) { - EXPECT_EQ("1.0", ver_1_0.to_string()); - EXPECT_EQ("1.2", ver_1_2.to_string()); - EXPECT_EQ("2.0", ver_2_0.to_string()); - - EXPECT_EQ("1.0", Version("1.0").to_string()); - EXPECT_EQ("1.2", Version("1.2").to_string()); - EXPECT_EQ("2.0", Version("2.0").to_string()); -} - -class HardwareVersionTest : public ::testing::Test { - protected: - HardwareVersionTest() : ver_1_0(HardwareVersion(1, 0)) {} - - HardwareVersion ver_1_0; -}; - -TEST_F(HardwareVersionTest, Properties) { - EXPECT_EQ(1, ver_1_0.major()); - EXPECT_EQ(0, ver_1_0.minor()); -} - -TEST_F(HardwareVersionTest, Strings) { - EXPECT_EQ("1.0", ver_1_0.to_string()); - EXPECT_EQ("1.0", HardwareVersion("1.0").to_string()); -} - -TEST_F(HardwareVersionTest, Flags) { - auto flag = ver_1_0.flag(); - EXPECT_EQ("00000000", flag.to_string()); - - flag[0] = true; - flag[flag.size() - 1] = true; - EXPECT_EQ("10000001", flag.to_string()); -} - -class TypeTest : public ::testing::Test { - protected: - TypeTest() : type_1_2a(Type(1, 0x2A)) {} - - Type type_1_2a; -}; - -TEST_F(TypeTest, Properties) { - EXPECT_EQ(1, type_1_2a.vendor()); - EXPECT_EQ(0x2A, type_1_2a.product()); -} - -TEST_F(TypeTest, Strings) { - EXPECT_EQ("012A", type_1_2a.to_string()); - EXPECT_EQ("010A", Type("010A").to_string()); -} diff --git a/test/gtest b/test/gtest deleted file mode 160000 index 7888184..0000000 --- a/test/gtest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7888184f28509dba839e3683409443e0b5bb8948 diff --git a/test/gtest_main.cc b/test/gtest_main.cc deleted file mode 100644 index edca54b..0000000 --- a/test/gtest_main.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018 Slightech 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 - -#include "gtest/gtest.h" - -#include "mynteye/logger.h" - -int main(int argc, char **argv) { - glog_init _(argc, argv); - - printf("Running main() from gtest_main.cc\n"); - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/test/types_test.cc b/test/types_test.cc deleted file mode 100644 index bf822ed..0000000 --- a/test/types_test.cc +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2018 Slightech 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 "gtest/gtest.h" - -#include "mynteye/types.h" - -MYNTEYE_USE_NAMESPACE - -TEST(Model, VerifyToString) { - EXPECT_STREQ("Model::STANDARD", to_string(Model::STANDARD)); -} - -TEST(Stream, VerifyToString) { - EXPECT_STREQ("Stream::LEFT", to_string(Stream::LEFT)); - EXPECT_STREQ("Stream::RIGHT", to_string(Stream::RIGHT)); - EXPECT_STREQ("Stream::LEFT_RECTIFIED", to_string(Stream::LEFT_RECTIFIED)); - EXPECT_STREQ("Stream::RIGHT_RECTIFIED", to_string(Stream::RIGHT_RECTIFIED)); - EXPECT_STREQ("Stream::DISPARITY", to_string(Stream::DISPARITY)); - EXPECT_STREQ( - "Stream::DISPARITY_NORMALIZED", to_string(Stream::DISPARITY_NORMALIZED)); - EXPECT_STREQ("Stream::DEPTH", to_string(Stream::DEPTH)); - EXPECT_STREQ("Stream::POINTS", to_string(Stream::POINTS)); -} - -TEST(Capabilities, VerifyToString) { - EXPECT_STREQ("Capabilities::STEREO", to_string(Capabilities::STEREO)); - EXPECT_STREQ("Capabilities::COLOR", to_string(Capabilities::COLOR)); - EXPECT_STREQ("Capabilities::DEPTH", to_string(Capabilities::DEPTH)); - EXPECT_STREQ("Capabilities::POINTS", to_string(Capabilities::POINTS)); - EXPECT_STREQ("Capabilities::FISHEYE", to_string(Capabilities::FISHEYE)); - EXPECT_STREQ("Capabilities::INFRARED", to_string(Capabilities::INFRARED)); - EXPECT_STREQ("Capabilities::INFRARED2", to_string(Capabilities::INFRARED2)); - EXPECT_STREQ("Capabilities::IMU", to_string(Capabilities::IMU)); -} - -TEST(Info, VerifyToString) { - EXPECT_STREQ("Info::DEVICE_NAME", to_string(Info::DEVICE_NAME)); - EXPECT_STREQ("Info::SERIAL_NUMBER", to_string(Info::SERIAL_NUMBER)); - EXPECT_STREQ("Info::FIRMWARE_VERSION", to_string(Info::FIRMWARE_VERSION)); - EXPECT_STREQ("Info::HARDWARE_VERSION", to_string(Info::HARDWARE_VERSION)); - EXPECT_STREQ("Info::SPEC_VERSION", to_string(Info::SPEC_VERSION)); - EXPECT_STREQ("Info::LENS_TYPE", to_string(Info::LENS_TYPE)); - EXPECT_STREQ("Info::IMU_TYPE", to_string(Info::IMU_TYPE)); - EXPECT_STREQ("Info::NOMINAL_BASELINE", to_string(Info::NOMINAL_BASELINE)); - EXPECT_STREQ("Info::AUXILIARY_CHIP_VERSION", to_string(Info::AUXILIARY_CHIP_VERSION)); - EXPECT_STREQ("Info::ISP_VERSION", to_string(Info::ISP_VERSION)); -} - -TEST(Option, VerifyToString) { - EXPECT_STREQ("Option::GAIN", to_string(Option::GAIN)); - EXPECT_STREQ("Option::BRIGHTNESS", to_string(Option::BRIGHTNESS)); - EXPECT_STREQ("Option::CONTRAST", to_string(Option::CONTRAST)); - EXPECT_STREQ("Option::FRAME_RATE", to_string(Option::FRAME_RATE)); - EXPECT_STREQ("Option::IMU_FREQUENCY", to_string(Option::IMU_FREQUENCY)); - EXPECT_STREQ("Option::EXPOSURE_MODE", to_string(Option::EXPOSURE_MODE)); - EXPECT_STREQ("Option::MAX_GAIN", to_string(Option::MAX_GAIN)); - EXPECT_STREQ( - "Option::MAX_EXPOSURE_TIME", to_string(Option::MAX_EXPOSURE_TIME)); - EXPECT_STREQ( - "Option::DESIRED_BRIGHTNESS", to_string(Option::DESIRED_BRIGHTNESS)); - EXPECT_STREQ("Option::IR_CONTROL", to_string(Option::IR_CONTROL)); - EXPECT_STREQ("Option::HDR_MODE", to_string(Option::HDR_MODE)); - EXPECT_STREQ( - "Option::ZERO_DRIFT_CALIBRATION", - to_string(Option::ZERO_DRIFT_CALIBRATION)); - EXPECT_STREQ("Option::ERASE_CHIP", to_string(Option::ERASE_CHIP)); - EXPECT_STREQ("Option::SYNC_TIMESTAMP", to_string(Option::SYNC_TIMESTAMP)); -} - -TEST(Source, VerifyToString) { - EXPECT_STREQ("Source::VIDEO_STREAMING", to_string(Source::VIDEO_STREAMING)); - EXPECT_STREQ("Source::MOTION_TRACKING", to_string(Source::MOTION_TRACKING)); - EXPECT_STREQ("Source::ALL", to_string(Source::ALL)); -} - -TEST(AddOns, VerifyToString) { - EXPECT_STREQ("AddOns::INFRARED", to_string(AddOns::INFRARED)); - EXPECT_STREQ("AddOns::INFRARED2", to_string(AddOns::INFRARED2)); -} - -TEST(Format, VerifyToString) { - EXPECT_STREQ("Format::GREY", to_string(Format::GREY)); - EXPECT_STREQ("Format::YUYV", to_string(Format::YUYV)); -}