Skip to content

Commit

Permalink
created WITH_JS cmake option that disables dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Timotei Molcut <[email protected]>
  • Loading branch information
tmanalog committed Mar 22, 2022
1 parent 9054d22 commit 8eca33a
Show file tree
Hide file tree
Showing 64 changed files with 343 additions and 14 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ option(USE_FXTOF1 "Use FXTOF1 camera?" OFF)
option(USE_3D_SMART "Use 3D Smart camera?" OFF)
option(WITH_TOOLS "Build tools?" OFF)
option(IGNORE_TARGET_VERSION "Ignore sdk version on target?" OFF)
option(WITH_JS "Build JavaScript bindings?" OFF)

# Set camera flags
if (USE_FXTOF1)
Expand Down Expand Up @@ -78,6 +79,15 @@ if (ON_TARGET)
if(${SELECTED_CAMERAS} GREATER 1)
message(FATAL_ERROR "More than one camera was selected. \nPlease select a single camera. CMake will exit.")
endif()

if(WITH_JS)
message(FATAL_ERROR "Target does not support JavaScript bindings.")
endif()
endif()

if (WITH_JS)
set(WITH_NETWORK OFF)
add_definitions(-DJS_BINDINGS)
endif()

if (WITH_NETWORK)
Expand Down
4 changes: 4 additions & 0 deletions bindings/matlab/aditofimaq.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
#include <aditof/camera.h>
#include <aditof/frame.h>
#include <aditof/system.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif

#include <iostream>

Expand Down
6 changes: 6 additions & 0 deletions bindings/open3D/showPointCloud/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
#include <aditof/camera.h>
#include <aditof/frame.h>
#include <aditof/system.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif

#include "../aditof_open3d.h"

Expand All @@ -43,8 +47,10 @@ static const uint8_t colormap[3 * 256] = {
using namespace aditof;

int main(int argc, char *argv[]) {
#ifndef JS_BINDINGS
google::InitGoogleLogging(argv[0]);
FLAGS_alsologtostderr = 1;
#endif

Status status = Status::OK;

Expand Down
6 changes: 6 additions & 0 deletions bindings/opencv/dnn/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
#include <aditof/camera.h>
#include <aditof/frame.h>
#include <aditof/system.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif

#include <opencv2/dnn.hpp>
#include <opencv2/dnn/shape_utils.hpp>
Expand Down Expand Up @@ -66,8 +70,10 @@ int main(int argc, char *argv[]) {

cv::dnn::Net net = cv::dnn::readNetFromCaffe(PROTOTXT, MODEL);

#ifndef JS_BINDINGS
google::InitGoogleLogging(argv[0]);
FLAGS_alsologtostderr = 1;
#endif

Status status = Status::OK;

Expand Down
6 changes: 6 additions & 0 deletions bindings/opencv/imshow/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
#include <aditof/depth_sensor_interface.h>
#include <aditof/frame.h>
#include <aditof/system.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
Expand All @@ -46,8 +50,10 @@
using namespace aditof;

int main(int argc, char *argv[]) {
#ifndef JS_BINDINGS
google::InitGoogleLogging(argv[0]);
FLAGS_alsologtostderr = 1;
#endif

Status status = Status::OK;

Expand Down
4 changes: 4 additions & 0 deletions bindings/opencv/maskrcnn/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
#include <aditof/camera.h>
#include <aditof/frame.h>
#include <aditof/system.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif

#include <fstream>
#include <iostream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
#define ADITOF_UTILS_H

#include <aditof/camera.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif
#include <mutex>

std::string parseArgs(int argc, char **argv);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
#include <string>

#include <aditof/frame.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif

#include "aditof_sensor_msg.h"
#include "aditof_utils.h"
Expand Down
2 changes: 2 additions & 0 deletions bindings/ros/aditof_roscpp/src/aditof_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ std::mutex mtx_dynamic_rec;
using namespace aditof;

std::string parseArgs(int argc, char **argv) {
#ifndef JS_BINDINGS
google::InitGoogleLogging(argv[0]);
FLAGS_alsologtostderr = 1;
#endif

if (argc > 1) {
std::string ip = argv[1];
Expand Down
4 changes: 4 additions & 0 deletions examples/aditof-demo-imgui/aditofdemocontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@

#include <aditof/depth_sensor_interface.h>
#include <aditof/temperature_sensor_interface.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif
#include <iostream>

AdiTofDemoController::AdiTofDemoController()
Expand Down
6 changes: 6 additions & 0 deletions examples/aditof-demo-imgui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@
*/

#include "view.h"
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif

int main(int argc, char **argv) {

// Init google logging system
#ifndef JS_BINDINGS
google::InitGoogleLogging(argv[0]);
FLAGS_alsologtostderr = 1;
#endif

auto view =
std::make_shared<View>();
Expand Down
4 changes: 4 additions & 0 deletions examples/aditof-demo-imgui/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
#include "imgui_impl_opengl3.h"

#include <aditof/version.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif
#include <stdio.h>
#include <string>

Expand Down
4 changes: 4 additions & 0 deletions examples/aditof-demo/aditofdemocontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@

#include <aditof/depth_sensor_interface.h>
#include <aditof/temperature_sensor_interface.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif
#include <iostream>

AdiTofDemoController::AdiTofDemoController()
Expand Down
4 changes: 4 additions & 0 deletions examples/aditof-demo/aditofdemoview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
*/
#include "aditofdemoview.h"

#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif
#include <sstream>

#define CVUI_IMPLEMENTATION
Expand Down
6 changes: 6 additions & 0 deletions examples/aditof-demo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@
#include "aditofdemocontroller.h"
#include "aditofdemoview.h"
#include <aditof/version.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif
#include <iostream>

int main(int argc, char **argv) {

// Init google logging system
#ifndef JS_BINDINGS
google::InitGoogleLogging(argv[0]);
FLAGS_alsologtostderr = 1;
#endif

std::string version = aditof::getApiVersion();
auto controller = std::make_shared<AdiTofDemoController>();
Expand Down
6 changes: 6 additions & 0 deletions examples/first-frame-network/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@
#include <aditof/camera.h>
#include <aditof/frame.h>
#include <aditof/system.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif
#include <iostream>

using namespace aditof;

int main(int argc, char *argv[]) {

#ifndef JS_BINDINGS
google::InitGoogleLogging(argv[0]);
FLAGS_alsologtostderr = 1;
#endif

Status status = Status::OK;

Expand Down
6 changes: 6 additions & 0 deletions examples/first-frame/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@
#include <aditof/camera.h>
#include <aditof/frame.h>
#include <aditof/system.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif
#include <iostream>

using namespace aditof;

int main(int argc, char *argv[]) {

#ifndef JS_BINDINGS
google::InitGoogleLogging(argv[0]);
FLAGS_alsologtostderr = 1;
#endif

Status status = Status::OK;

Expand Down
6 changes: 6 additions & 0 deletions examples/imshow-xavier/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
#include <aditof/camera.h>
#include <aditof/frame.h>
#include <aditof/system.h>
#ifndef JS_BINDINGS
#include <glog/logging.h>
#else
#include <aditof/log_cout.h>
#endif

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
Expand Down Expand Up @@ -82,8 +86,10 @@ aditof::Status fromFrameToIrMat(aditof::Frame &frame, cv::Mat &mat) {
}

int main(int argc, char *argv[]) {
#ifndef JS_BINDINGS
google::InitGoogleLogging(argv[0]);
FLAGS_alsologtostderr = 1;
#endif

Status status = Status::OK;
System system;
Expand Down
32 changes: 18 additions & 14 deletions sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 2.8)
project(aditof)

add_definitions(-DSDK_EXPORTS)
find_package(glog 0.3.5 REQUIRED)
if (NOT WITH_JS)
find_package(glog 0.3.5 REQUIRED)
endif()

#Enables the use of assert() from <assert.h> only in Debug mode.
if ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
Expand Down Expand Up @@ -157,19 +159,21 @@ set_target_properties( ${PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
)

if ( WITH_NETWORK )
target_link_libraries( ${PROJECT_NAME}
PUBLIC
glog::glog
PRIVATE
${Protobuf_LIBRARIES}
${LIBWEBSOCKETS_LIBRARIES}
)
else()
target_link_libraries( ${PROJECT_NAME}
PUBLIC
glog::glog
)
if (NOT WITH_JS)
if ( WITH_NETWORK )
target_link_libraries( ${PROJECT_NAME}
PUBLIC
glog::glog
PRIVATE
${Protobuf_LIBRARIES}
${LIBWEBSOCKETS_LIBRARIES}
)
else()
target_link_libraries( ${PROJECT_NAME}
PUBLIC
glog::glog
)
endif()
endif()

if (CMAKE_COMPILER_IS_GNUCC)
Expand Down
38 changes: 38 additions & 0 deletions sdk/include/aditof/log_cout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* BSD 3-Clause License
*
* Copyright (c) 2019, Analog Devices, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <iostream>

#define INFO "INFO "
#define ERROR "ERROR "
#define WARNING "WARNING "
#define LOG(x) std::cout << x
#define DLOG(x) std::cout << x
Loading

0 comments on commit 8eca33a

Please sign in to comment.