Skip to content

Commit 5c7eafe

Browse files
author
Matevz Morato
committed
Fix examples on Windows
1 parent 8e535ed commit 5c7eafe

File tree

9 files changed

+27
-69
lines changed

9 files changed

+27
-69
lines changed

examples/cpp/CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ find_package(Sanitizers)
77

88
# Create utility library
99
add_library(utility utility/utility.cpp)
10+
target_compile_features(utility PUBLIC cxx_std_17)
1011
target_include_directories(utility PUBLIC "utility" "$<BUILD_INTERFACE:${FP16_INCLUDE_DIR}>")
1112
add_default_flags(utility LEAN)
1213
target_link_libraries(utility ${OpenCV_LIBS})
@@ -326,11 +327,14 @@ if(DEPTHAI_ENABLE_REMOTE_CONNECTION)
326327
dai_set_example_test_labels(visualizer_yolo ondevice rvc2_all rvc4)
327328
endif()
328329

329-
include(FetchContent)
330-
FetchContent_Declare(rerun_sdk URL https://github.com/rerun-io/rerun/releases/download/0.16.1/rerun_cpp_sdk.zip)
331-
FetchContent_MakeAvailable(rerun_sdk)
332-
dai_add_example(rgbd RGBD/rgbd.cpp ON OFF)
333-
target_link_libraries(rgbd PRIVATE rerun_sdk)
330+
# Skip compiling rerun examples on Windows, since the used version of rerun doesn't compile on Windows
331+
if(NOT WIN32)
332+
include(FetchContent)
333+
FetchContent_Declare(rerun_sdk URL https://github.com/rerun-io/rerun/releases/download/0.16.1/rerun_cpp_sdk.zip)
334+
FetchContent_MakeAvailable(rerun_sdk)
335+
dai_add_example(rgbd RGBD/rgbd.cpp ON OFF)
336+
target_link_libraries(rgbd PRIVATE rerun_sdk)
337+
endif()
334338

335339
if(DEPTHAI_ENABLE_REMOTE_CONNECTION)
336340
dai_add_example(visualizer_rgbd RGBD/visualizer_rgbd.cpp ON OFF)

examples/cpp/Record/holistic_record.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,11 @@
44
#include "depthai/depthai.hpp"
55
#include "depthai/pipeline/node/host/Display.hpp"
66
#include "depthai/utility/RecordReplay.hpp"
7-
7+
#include "utility.hpp"
88
#ifndef DEPTHAI_MERGED_TARGET
99
#error This example needs OpenCV support, which is not available on your system
1010
#endif
1111

12-
std::string getDefaultRecordingPath() {
13-
auto isTest = std::getenv("RUNNING_AS_TEST");
14-
if(isTest && std::string(isTest) == "1") {
15-
// If running as test save to temporary directory
16-
char tmpTemplate[] = "holistic_recording_XXXXXX";
17-
char* tmpName = mkdtemp(tmpTemplate);
18-
auto tmpDir = std::filesystem::temp_directory_path() / tmpName;
19-
std::filesystem::create_directory(tmpDir);
20-
return tmpDir.string();
21-
} else {
22-
return ".";
23-
}
24-
}
25-
2612
int main(int argc, char** argv) {
2713
dai::Pipeline pipeline;
2814
auto camA = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_A);

examples/cpp/Record/record_encoded.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,12 @@
33
#include "depthai/capabilities/ImgFrameCapability.hpp"
44
#include "depthai/common/CameraBoardSocket.hpp"
55
#include "depthai/pipeline/node/host/Record.hpp"
6+
#include "utility.hpp"
67

78
#ifndef DEPTHAI_HAVE_OPENCV_SUPPORT
89
#error This example needs OpenCV support, which is not available on your system
910
#endif
1011

11-
std::string getDefaultRecordingPath() {
12-
auto isTest = std::getenv("RUNNING_AS_TEST");
13-
if(isTest && std::string(isTest) == "1") {
14-
// If running as test save to temporary directory
15-
char tmpTemplate[] = "encoded_recording_XXXXXX";
16-
char* tmpName = mkdtemp(tmpTemplate);
17-
auto tmpDir = std::filesystem::temp_directory_path();
18-
return (tmpDir / tmpName).string();
19-
} else {
20-
return "encoded_recording";
21-
}
22-
}
23-
2412
int main(int argc, char** argv) {
2513
dai::Pipeline pipeline(true);
2614
auto cam = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_A);

examples/cpp/Record/record_imu.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@
88
// Includes common necessary includes for development using depthai library
99
#include "depthai/depthai.hpp"
1010

11-
std::string getDefaultRecordingPath() {
12-
auto isTest = std::getenv("RUNNING_AS_TEST");
13-
if(isTest && std::string(isTest) == "1") {
14-
// If running as test save to temporary directory
15-
char tmpTemplate[] = "imu_recording_XXXXXX";
16-
char* tmpName = mkdtemp(tmpTemplate);
17-
auto tmpDir = std::filesystem::temp_directory_path();
18-
return (tmpDir / tmpName).string();
19-
} else {
20-
return "imu_recording";
21-
}
22-
}
2311

2412
int main(int argc, char** argv) {
2513
// Create pipeline

examples/cpp/Record/record_raw.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,11 @@
33
#include "depthai/capabilities/ImgFrameCapability.hpp"
44
#include "depthai/common/CameraBoardSocket.hpp"
55
#include "depthai/pipeline/node/host/Record.hpp"
6-
6+
#include "utility.hpp"
77
#ifndef DEPTHAI_HAVE_OPENCV_SUPPORT
88
#error This example needs OpenCV support, which is not available on your system
99
#endif
1010

11-
std::string getDefaultRecordingPath() {
12-
auto isTest = std::getenv("RUNNING_AS_TEST");
13-
if(isTest && std::string(isTest) == "1") {
14-
// If running as test save to temporary directory
15-
char tmpTemplate[] = "raw_recording_XXXXXX";
16-
char* tmpName = mkdtemp(tmpTemplate);
17-
auto tmpDir = std::filesystem::temp_directory_path();
18-
return (tmpDir / tmpName).string();
19-
} else {
20-
return "raw_recording";
21-
}
22-
}
2311

2412
int main(int argc, char** argv) {
2513
dai::Pipeline pipeline(true);

examples/cpp/Replay/holistic_replay.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@
66
#error This example needs OpenCV support, which is not available on your system
77
#endif
88

9-
std::string getDefaultRecordingPath() {
10-
auto isTest = std::getenv("RUNNING_AS_TEST");
11-
if(isTest && std::string(isTest) == "1") {
12-
// If running as test record from dowloaded recording
13-
return RECORDING_PATH;
14-
} else {
15-
return "raw_recording";
16-
}
17-
}
18-
199
int main(int argc, char** argv) {
2010
dai::Pipeline pipeline;
2111
auto camA = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_A);

examples/cpp/utility/utility.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#else
1212
#include <sys/stat.h>
1313
#endif
14+
#include <filesystem>
1415

1516
int createDirectory(std::string directory)
1617
{
@@ -132,3 +133,15 @@ cv::Mat resizeKeepAspectRatio(const cv::Mat &input, const cv::Size &dstSize, con
132133
return output;
133134
}
134135

136+
std::string getDefaultRecordingPath() {
137+
auto* isTest = std::getenv("RUNNING_AS_TEST");
138+
if((isTest != nullptr) && std::string(isTest) == "1") {
139+
auto path = std::filesystem::temp_directory_path() / "depthai_recordings/";
140+
if(!std::filesystem::exists(path)) {
141+
std::filesystem::create_directories(path);
142+
}
143+
return path.string();
144+
}
145+
return ".";
146+
}
147+

examples/cpp/utility/utility.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ cv::Mat toMat(const std::vector<uint8_t>& data, int w, int h , int numPlanes, in
77
void toPlanar(cv::Mat& bgr, std::vector<std::uint8_t>& data);
88
cv::Mat resizeKeepAspectRatio(const cv::Mat &input, const cv::Size &dstSize, const cv::Scalar &bgcolor);
99
int createDirectory(std::string directory);
10+
std::string getDefaultRecordingPath();

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function(dai_add_test test_name test_src)
5454
if(NOT DEPTHAI_MERGED_TARGET)
5555
set(DEPTHAI_TARGET depthai::opencv)
5656
endif()
57-
target_link_libraries(${test_name} PRIVATE depthai::opencv ${OpenCV_LIBS} Catch2::Catch2WithMain Threads::Threads spdlog::spdlog)
57+
target_link_libraries(${test_name} PRIVATE ${DEPTHAI_TARGET} ${OpenCV_LIBS} Catch2::Catch2WithMain Threads::Threads spdlog::spdlog)
5858

5959
# Add sanitizers for tests as well
6060
if(COMMAND add_sanitizers)

0 commit comments

Comments
 (0)