Skip to content

Commit 550ae66

Browse files
torch builded
1 parent 6d7263a commit 550ae66

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

CMakeLists.txt

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ add_compile_options(-std=c++11)
77
## Optional parts of library
88
set(opencv_contrib OFF)
99
set(zbar_lib OFF)
10-
set(TensorFlow OFF)
1110
set(DLib OFF)
1211
set(igraph OFF)
12+
set(torch ON)
1313

1414
## Find catkin macros and libraries
1515
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
@@ -39,6 +39,15 @@ if(DLib)
3939
add_subdirectory(/home/anton/Lib/dlib dlib_build)
4040
endif(DLib)
4141

42+
if(torch)
43+
#set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}/home/anton/Libs/libtorch")
44+
list(APPEND CMAKE_PREFIX_PATH "/home/anton/Libs/libtorch")
45+
message(${CMAKE_PREFIX_PATH})
46+
find_package(Torch REQUIRED)
47+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
48+
endif(torch)
49+
50+
4251

4352
################################################
4453
## Declare ROS messages, services and actions ##
@@ -121,6 +130,7 @@ set( EOD_SRC
121130
src/lib/detectors/ExtractedInfoStringChecker.cpp
122131
src/lib/detectors/UnitTranslationExtracter.cpp
123132
src/lib/detectors/SquareObjectDistanceDetector.cpp
133+
src/lib/detectors/TorchDetector.cpp
124134

125135
# lib relations
126136
src/lib/relations/ImageRangeRelation.cpp
@@ -146,9 +156,6 @@ add_executable(
146156
${EOD_SRC}
147157
)
148158

149-
if(TensorFlow)
150-
target_compile_definitions(extended_object_detection_node PUBLIC USE_TF)
151-
endif(TensorFlow)
152159

153160
if(opencv_contrib)
154161
target_compile_definitions(extended_object_detection_node PUBLIC USE_OPENCV_CONTRIB)
@@ -166,6 +173,10 @@ if(igraph)
166173
target_compile_definitions(extended_object_detection_node PUBLIC USE_IGRAPH)
167174
endif(igraph)
168175

176+
if(torch)
177+
target_compile_definitions(extended_object_detection_node PUBLIC USE_TORCH)
178+
endif(torch)
179+
169180
#collect hsv color c++ utility
170181
add_executable(
171182
hsv_color_params_collector_node
@@ -497,11 +508,30 @@ if(igraph)
497508
)
498509
endif(igraph)
499510

511+
if(torch)
512+
set_property(TARGET extended_object_detection_node PROPERTY CXX_STANDARD 14)
513+
set_property(TARGET offline_video PROPERTY CXX_STANDARD 14)
514+
set_property(TARGET offline_image PROPERTY CXX_STANDARD 14)
515+
516+
target_link_libraries(extended_object_detection_node
517+
${TORCH_LIBRARIES}
518+
)
519+
520+
target_link_libraries(offline_video
521+
${TORCH_LIBRARIES}
522+
)
523+
524+
target_link_libraries(offline_image
525+
${TORCH_LIBRARIES}
526+
)
527+
endif(torch)
528+
500529

501530
target_link_libraries(extended_object_detection_node
502531
${OpenCV_LIBRARIES}
503532
${TinyXML_LIBRARIES}
504533
${catkin_LIBRARIES}
534+
505535
)
506536

507537
target_link_libraries(hsv_color_params_collector_node

0 commit comments

Comments
 (0)