change structure of folder samples and move demo_project

This commit is contained in:
Messier 2019-08-23 15:28:56 +08:00
parent 803d2e93b5
commit 1893ef382a
59 changed files with 246 additions and 270 deletions

View File

@ -59,28 +59,194 @@ endif()
#LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake) #LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake)
# targets # targets
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output") set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output")
include_directories(
${PRO_DIR}/src
)
set_outdir(
"${OUT_DIR}/lib"
"${OUT_DIR}/lib"
"${OUT_DIR}/bin"
)
if(OS_MAC) if(OS_MAC)
# samples above uvc layer # samples above uvc layer
add_subdirectory(uvc) make_executable(camera_u
SRCS uvc_camera.cc
LINK_LIBS mynteye ${OpenCV_LIBS}
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
)
else() else()
# samples above device layer # samples above device layer
add_subdirectory(device) make_executable(camera_use_device
SRCS device_camera.cc
# tutorials LINK_LIBS mynteye ${OpenCV_LIBS}
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
if(WITH_API) )
add_subdirectory(tutorials)
endif()
# samples above api layer # samples above api layer
if(WITH_API) if(WITH_API)
add_subdirectory(api) ## camera_a
make_executable(camera_use_api
SRCS api_camera.cc
LINK_LIBS mynteye ${OpenCV_LIBS}
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
)
## get_depth_with_region
make_executable(get_depth_with_region
SRCS api_get_depth_with_region.cc
LINK_LIBS mynteye ${OpenCV_LIBS}
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
)
endif() endif()
endif() endif()
# targets
include_directories(
${OpenCV_INCLUDE_DIRS}
)
# tutorials
if(WITH_API)
# make_executable2(NAME
# [SRCS src1 src2 ...]
# [WITH_OPENCV]
# [WITH_PCL])
macro(make_executable2 NAME)
set(options WITH_OPENCV WITH_PCL)
set(oneValueArgs)
set(multiValueArgs SRCS)
cmake_parse_arguments(THIS "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})
set(__link_libs mynteye)
set(__dll_search_paths ${PRO_DIR}/_install/bin)
if(THIS_WITH_OPENCV)
list(APPEND __link_libs ${OpenCV_LIBS})
list(APPEND __dll_search_paths ${OpenCV_LIB_SEARCH_PATH})
endif()
if(THIS_WITH_PCL)
list(APPEND __link_libs ${PCL_LIBRARIES})
#list(APPEND __link_libs pcl::pcl)
list(APPEND __dll_search_paths ${PCL_LIB_SEARCH_PATH})
endif()
add_executable(${NAME} ${THIS_SRCS})
target_link_libraries(${NAME} ${__link_libs})
target_create_scripts(${NAME} DLL_SEARCH_PATHS ${__dll_search_paths})
if(THIS_WITH_PCL)
target_include_directories(${NAME} PRIVATE ${PCL_INCLUDE_DIRS})
#target_compile_definitions(${NAME} PRIVATE ${PCL_DEFINITIONS})
#target_compile_options(${NAME} PRIVATE ${PCL_COMPILE_OPTIONS})
endif()
if(OS_WIN)
target_compile_definitions(${NAME}
PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES
)
endif()
endmacro()
# packages
# If you install PCL to different directory, please set CMAKE_PREFIX_PATH to find it.
#LIST(APPEND CMAKE_PREFIX_PATH /usr/local/share)
find_package(PCL)
if(PCL_FOUND)
message(STATUS "Found PCL: ${PCL_VERSION}")
#message(STATUS "PCL_LIBRARIES: ${PCL_LIBRARIES}")
#message(STATUS "PCL_INCLUDE_DIRS: ${PCL_INCLUDE_DIRS}")
#message(STATUS "PCL_LIBRARY_DIRS: ${PCL_LIBRARY_DIRS}")
#message(STATUS "PCL_DEFINITIONS: ${PCL_DEFINITIONS}")
#message(STATUS "PCL_COMPILE_OPTIONS: ${PCL_COMPILE_OPTIONS}")
if(OS_WIN)
get_filename_component(PCL_LIB_SEARCH_PATH "${PCL_LIBRARY_DIRS}/../bin" ABSOLUTE)
else()
set(PCL_LIB_SEARCH_PATH "${PCL_LIBRARY_DIRS}")
endif()
else()
message(WARNING "PCL not found :(")
endif()
# beginner level
## data
make_executable2(get_device_info SRCS data_get_device_info.cc WITH_OPENCV)
make_executable2(get_img_params SRCS data_get_img_params.cc WITH_OPENCV)
make_executable2(get_imu_params SRCS data_get_imu_params.cc WITH_OPENCV)
make_executable2(get_stereo SRCS data_get_stereo.cc WITH_OPENCV)
make_executable2(get_stereo_rectified SRCS data_get_stereo_rectified.cc WITH_OPENCV)
make_executable2(get_disparity SRCS data_get_disparity.cc WITH_OPENCV)
make_executable2(get_depth SRCS data_get_depth.cc WITH_OPENCV)
make_executable2(get_data_without_select SRCS data_get_data_without_select.cc WITH_OPENCV)
if(PCL_FOUND)
make_executable2(get_points
SRCS data_get_points.cc util_pc_viewer.cc
WITH_OPENCV WITH_PCL
)
endif()
make_executable2(get_imu_correspondence
SRCS data_get_imu_correspondence.cc util_cv_painter.cc
WITH_OPENCV
)
make_executable2(get_imu SRCS data_get_imu.cc util_cv_painter.cc WITH_OPENCV)
make_executable2(save_single_image SRCS data_save_single_image.cc WITH_OPENCV)
make_executable2(get_from_callbacks
SRCS data_get_from_callbacks.cc util_cv_painter.cc
WITH_OPENCV
)
make_executable2(get_with_plugin SRCS data_get_with_plugin.cc WITH_OPENCV)
## control
make_executable2(ctrl_framerate SRCS control_framerate.cc WITH_OPENCV)
make_executable2(ctrl_imu_low_pass_filter SRCS control_imu_low_pass_filter.cc WITH_OPENCV)
make_executable2(ctrl_imu_range SRCS control_imu_range.cc WITH_OPENCV)
make_executable2(ctrl_infrared SRCS control_infrared.cc WITH_OPENCV)
make_executable2(ctrl_iic_adress SRCS control_iic_address.cc WITH_OPENCV)
make_executable2(ctrl_sync_timestamp SRCS control_sync_timestamp.cc WITH_OPENCV)
make_executable2(ctrl_auto_exposure
SRCS control_auto_exposure.cc util_cv_painter.cc
WITH_OPENCV
)
make_executable2(ctrl_manual_exposure
SRCS control_manual_exposure.cc util_cv_painter.cc
WITH_OPENCV
)
if(PCL_FOUND)
make_executable2(get_depth_and_points
SRCS intermediate_get_depth_and_points.cc util_cv_painter.cc util_pc_viewer.cc
WITH_OPENCV WITH_PCL
)
endif()
endif()

View File

@ -1,37 +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.
get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
set_outdir(
"${OUT_DIR}/lib/${DIR_NAME}"
"${OUT_DIR}/lib/${DIR_NAME}"
"${OUT_DIR}/bin/${DIR_NAME}"
)
## camera_a
make_executable(camera_a
SRCS camera.cc
LINK_LIBS mynteye ${OpenCV_LIBS}
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
)
## get_depth_with_region
make_executable(get_depth_with_region
SRCS get_depth_with_region.cc
LINK_LIBS mynteye ${OpenCV_LIBS}
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
)

View File

@ -16,7 +16,7 @@
#include "mynteye/logger.h" #include "mynteye/logger.h"
#include "mynteye/api/api.h" #include "mynteye/api/api.h"
#include "util/cv_painter.h" #include "util_cv_painter.h"
MYNTEYE_USE_NAMESPACE MYNTEYE_USE_NAMESPACE

View File

@ -16,7 +16,7 @@
#include "mynteye/logger.h" #include "mynteye/logger.h"
#include "mynteye/api/api.h" #include "mynteye/api/api.h"
#include "util/cv_painter.h" #include "util_cv_painter.h"
MYNTEYE_USE_NAMESPACE MYNTEYE_USE_NAMESPACE

View File

@ -21,7 +21,7 @@
#include "mynteye/logger.h" #include "mynteye/logger.h"
#include "mynteye/api/api.h" #include "mynteye/api/api.h"
#include "util/cv_painter.h" #include "util_cv_painter.h"
MYNTEYE_USE_NAMESPACE MYNTEYE_USE_NAMESPACE

View File

@ -16,7 +16,7 @@
#include "mynteye/logger.h" #include "mynteye/logger.h"
#include "mynteye/api/api.h" #include "mynteye/api/api.h"
#include "util/cv_painter.h" #include "util_cv_painter.h"
MYNTEYE_USE_NAMESPACE MYNTEYE_USE_NAMESPACE

View File

@ -16,7 +16,7 @@
#include "mynteye/logger.h" #include "mynteye/logger.h"
#include "mynteye/api/api.h" #include "mynteye/api/api.h"
#include "util/cv_painter.h" #include "util_cv_painter.h"
// #define CHECK_ACCEL_THEN_GYRO // #define CHECK_ACCEL_THEN_GYRO
#define SEQ_FIRST 1 // accel #define SEQ_FIRST 1 // accel

View File

@ -16,7 +16,7 @@
#include "mynteye/api/api.h" #include "mynteye/api/api.h"
#include "util/pc_viewer.h" #include "util_pc_viewer.h"
MYNTEYE_USE_NAMESPACE MYNTEYE_USE_NAMESPACE

View File

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -1,33 +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.
get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
include_directories(
${PRO_DIR}/src
)
set_outdir(
"${OUT_DIR}/lib/${DIR_NAME}"
"${OUT_DIR}/lib/${DIR_NAME}"
"${OUT_DIR}/bin/${DIR_NAME}"
)
## camera_d
make_executable(camera_d
SRCS camera.cc
LINK_LIBS mynteye ${OpenCV_LIBS}
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
)

View File

@ -17,8 +17,8 @@
// #include "mynteye/logger.h" // #include "mynteye/logger.h"
#include "mynteye/api/api.h" #include "mynteye/api/api.h"
#include "util/cv_painter.h" #include "util_cv_painter.h"
#include "util/pc_viewer.h" #include "util_pc_viewer.h"
namespace { namespace {

61
samples/mynteye_demo.cc Normal file
View File

@ -0,0 +1,61 @@
// 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 <stdio.h>
#include <opencv2/highgui/highgui.hpp>
#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<char>(cv::waitKey(1));
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
break;
}
}
api->Stop(Source::VIDEO_STREAMING);
return 0;
}

View File

@ -1,148 +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.
get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${PRO_DIR}/src
)
set_outdir(
"${OUT_DIR}/lib/${DIR_NAME}"
"${OUT_DIR}/lib/${DIR_NAME}"
"${OUT_DIR}/bin/${DIR_NAME}"
)
# make_executable2(NAME
# [SRCS src1 src2 ...]
# [WITH_OPENCV]
# [WITH_PCL])
macro(make_executable2 NAME)
set(options WITH_OPENCV WITH_PCL)
set(oneValueArgs)
set(multiValueArgs SRCS)
cmake_parse_arguments(THIS "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})
set(__link_libs mynteye)
set(__dll_search_paths ${PRO_DIR}/_install/bin)
if(THIS_WITH_OPENCV)
list(APPEND __link_libs ${OpenCV_LIBS})
list(APPEND __dll_search_paths ${OpenCV_LIB_SEARCH_PATH})
endif()
if(THIS_WITH_PCL)
list(APPEND __link_libs ${PCL_LIBRARIES})
#list(APPEND __link_libs pcl::pcl)
list(APPEND __dll_search_paths ${PCL_LIB_SEARCH_PATH})
endif()
add_executable(${NAME} ${THIS_SRCS})
target_link_libraries(${NAME} ${__link_libs})
target_create_scripts(${NAME} DLL_SEARCH_PATHS ${__dll_search_paths})
if(THIS_WITH_PCL)
target_include_directories(${NAME} PRIVATE ${PCL_INCLUDE_DIRS})
#target_compile_definitions(${NAME} PRIVATE ${PCL_DEFINITIONS})
#target_compile_options(${NAME} PRIVATE ${PCL_COMPILE_OPTIONS})
endif()
if(OS_WIN)
target_compile_definitions(${NAME}
PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES
)
endif()
endmacro()
# packages
# If you install PCL to different directory, please set CMAKE_PREFIX_PATH to find it.
#LIST(APPEND CMAKE_PREFIX_PATH /usr/local/share)
find_package(PCL)
if(PCL_FOUND)
message(STATUS "Found PCL: ${PCL_VERSION}")
#message(STATUS "PCL_LIBRARIES: ${PCL_LIBRARIES}")
#message(STATUS "PCL_INCLUDE_DIRS: ${PCL_INCLUDE_DIRS}")
#message(STATUS "PCL_LIBRARY_DIRS: ${PCL_LIBRARY_DIRS}")
#message(STATUS "PCL_DEFINITIONS: ${PCL_DEFINITIONS}")
#message(STATUS "PCL_COMPILE_OPTIONS: ${PCL_COMPILE_OPTIONS}")
if(OS_WIN)
get_filename_component(PCL_LIB_SEARCH_PATH "${PCL_LIBRARY_DIRS}/../bin" ABSOLUTE)
else()
set(PCL_LIB_SEARCH_PATH "${PCL_LIBRARY_DIRS}")
endif()
else()
message(WARNING "PCL not found :(")
endif()
# beginner level
## data
make_executable2(get_device_info SRCS data/get_device_info.cc WITH_OPENCV)
make_executable2(get_img_params SRCS data/get_img_params.cc WITH_OPENCV)
make_executable2(get_imu_params SRCS data/get_imu_params.cc WITH_OPENCV)
make_executable2(get_stereo SRCS data/get_stereo.cc WITH_OPENCV)
make_executable2(get_stereo_rectified SRCS data/get_stereo_rectified.cc WITH_OPENCV)
make_executable2(get_disparity SRCS data/get_disparity.cc WITH_OPENCV)
make_executable2(get_depth SRCS data/get_depth.cc WITH_OPENCV)
make_executable2(get_data_without_select SRCS data/get_data_without_select.cc WITH_OPENCV)
if(PCL_FOUND)
make_executable2(get_points
SRCS data/get_points.cc util/pc_viewer.cc
WITH_OPENCV WITH_PCL
)
endif()
make_executable2(get_imu_correspondence
SRCS data/get_imu_correspondence.cc util/cv_painter.cc
WITH_OPENCV
)
make_executable2(get_imu SRCS data/get_imu.cc util/cv_painter.cc WITH_OPENCV)
make_executable2(save_single_image SRCS data/save_single_image.cc WITH_OPENCV)
make_executable2(get_from_callbacks
SRCS data/get_from_callbacks.cc util/cv_painter.cc
WITH_OPENCV
)
make_executable2(get_with_plugin SRCS data/get_with_plugin.cc WITH_OPENCV)
## control
make_executable2(ctrl_framerate SRCS control/framerate.cc WITH_OPENCV)
make_executable2(ctrl_imu_low_pass_filter SRCS control/imu_low_pass_filter.cc WITH_OPENCV)
make_executable2(ctrl_imu_range SRCS control/imu_range.cc WITH_OPENCV)
make_executable2(ctrl_infrared SRCS control/infrared.cc WITH_OPENCV)
make_executable2(ctrl_iic_adress SRCS control/iic_address.cc WITH_OPENCV)
make_executable2(ctrl_sync_timestamp SRCS control/sync_timestamp.cc WITH_OPENCV)
make_executable2(ctrl_auto_exposure
SRCS control/auto_exposure.cc util/cv_painter.cc
WITH_OPENCV
)
make_executable2(ctrl_manual_exposure
SRCS control/manual_exposure.cc util/cv_painter.cc
WITH_OPENCV
)
if(PCL_FOUND)
make_executable2(get_depth_and_points
SRCS intermediate/get_depth_and_points.cc util/cv_painter.cc util/pc_viewer.cc
WITH_OPENCV WITH_PCL
)
endif()
# advanced level

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "util/cv_painter.h" #include "util_cv_painter.h"
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "util/pc_viewer.h" #include "util_pc_viewer.h"
// #include <pcl/common/common_headers.h> // #include <pcl/common/common_headers.h>

View File

@ -1,33 +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.
get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
set_outdir(
"${OUT_DIR}/lib/${DIR_NAME}"
"${OUT_DIR}/lib/${DIR_NAME}"
"${OUT_DIR}/bin/${DIR_NAME}"
)
include_directories(
${PRO_DIR}/src
)
## camera_u
make_executable(camera_u
SRCS camera.cc
LINK_LIBS mynteye ${OpenCV_LIBS}
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
)