fix(*): change demo name.
This commit is contained in:
74
samples/simple_demo/project_cmake/CMakeLists.txt
Normal file
74
samples/simple_demo/project_cmake/CMakeLists.txt
Normal file
@@ -0,0 +1,74 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(mynteye_demo VERSION 1.0.0 LANGUAGES C CXX)
|
||||
|
||||
# flags
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -march=native")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -march=native")
|
||||
|
||||
# packages
|
||||
|
||||
if(MSVC)
|
||||
set(SDK_ROOT "$ENV{MYNTEYES_SDK_ROOT}")
|
||||
if(SDK_ROOT)
|
||||
message(STATUS "MYNTEYES_SDK_ROOT: ${SDK_ROOT}")
|
||||
list(APPEND CMAKE_PREFIX_PATH
|
||||
"${SDK_ROOT}/lib/cmake"
|
||||
"${SDK_ROOT}/3rdparty/opencv/build"
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "MYNTEYES_SDK_ROOT not found, please install SDK firstly")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
## mynteye
|
||||
|
||||
find_package(mynteye REQUIRED)
|
||||
message(STATUS "Found mynteye: ${mynteye_VERSION}")
|
||||
|
||||
# When SDK build with OpenCV, we can add WITH_OPENCV macro to enable some
|
||||
# features depending on OpenCV, such as ToMat().
|
||||
if(mynteye_WITH_OPENCV)
|
||||
add_definitions(-DWITH_OPENCV)
|
||||
endif()
|
||||
|
||||
## OpenCV
|
||||
|
||||
# Set where to find OpenCV
|
||||
#set(OpenCV_DIR "/usr/share/OpenCV")
|
||||
|
||||
# When SDK build with OpenCV, we must find the same version here.
|
||||
find_package(OpenCV REQUIRED)
|
||||
message(STATUS "Found OpenCV: ${OpenCV_VERSION}")
|
||||
|
||||
# targets
|
||||
|
||||
include_directories(
|
||||
${OpenCV_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
## mynteye_demo
|
||||
|
||||
add_executable(mynteye_demo mynteye_demo.cc)
|
||||
target_link_libraries(mynteye_demo mynteye ${OpenCV_LIBS})
|
||||
|
||||
|
||||
# Build
|
||||
# mkdir _build
|
||||
# cd _build
|
||||
#
|
||||
# # win
|
||||
# cmake -G "Visual Studio 15 2017 Win64" ..
|
||||
# msbuild.exe ALL_BUILD.vcxproj /property:Configuration=Release
|
||||
#
|
||||
# .\Release\mynteye_demo.exe
|
||||
#
|
||||
# # unix
|
||||
# cmake ..
|
||||
# make
|
||||
#
|
||||
# ./mynteye_demo
|
||||
61
samples/simple_demo/project_cmake/mynteye_demo.cc
Normal file
61
samples/simple_demo/project_cmake/mynteye_demo.cc
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user