diff --git a/CMakeLists.txt b/CMakeLists.txt index a8bac6a..c97f3b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,10 +36,15 @@ set(RESNET_SOURCES cimp/resnet/resnet.cpp ) +set(DIMP_TRACKER_SOURCES + cimp/dimp_tracker.cpp +) + # Create static libraries add_library(bb_regressor STATIC ${BB_REGRESSOR_SOURCES}) add_library(classifier STATIC ${CLASSIFIER_SOURCES}) add_library(resnet STATIC ${RESNET_SOURCES}) +add_library(dimp_tracker STATIC ${DIMP_TRACKER_SOURCES}) # Set include directories target_include_directories(bb_regressor PUBLIC @@ -49,23 +54,25 @@ target_include_directories(bb_regressor PUBLIC ) target_include_directories(classifier PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/cimp) target_include_directories(resnet PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/cimp) +target_include_directories(dimp_tracker PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/cimp) # Link with LibTorch target_link_libraries(bb_regressor PRIVATE ${TORCH_LIBRARIES}) target_link_libraries(classifier PRIVATE ${TORCH_LIBRARIES}) target_link_libraries(resnet PRIVATE ${TORCH_LIBRARIES}) +target_link_libraries(dimp_tracker PRIVATE ${TORCH_LIBRARIES}) # Create the demo executable add_executable(tracking_demo cimp/demo.cpp) # Link the demo with the libraries -target_link_libraries(tracking_demo PRIVATE bb_regressor classifier resnet ${TORCH_LIBRARIES}) +target_link_libraries(tracking_demo PRIVATE bb_regressor classifier resnet dimp_tracker ${TORCH_LIBRARIES}) # Create the test models executable add_executable(test_models test/test_models.cpp) # Link the test_models with the libraries -target_link_libraries(test_models PRIVATE bb_regressor classifier resnet ${TORCH_LIBRARIES}) +target_link_libraries(test_models PRIVATE bb_regressor classifier resnet dimp_tracker ${TORCH_LIBRARIES}) # Create the test sample generator executable (without dependencies on our libraries) # add_executable(generate_test_samples ${CMAKE_CURRENT_SOURCE_DIR}/test/generate_test_samples.cpp) # COMMENTED OUT @@ -90,7 +97,7 @@ install(TARGETS test_models # generate_test_samples # COMMENTED OUT ARCHIVE DESTINATION lib ) -install(TARGETS resnet classifier bb_regressor +install(TARGETS resnet classifier bb_regressor dimp_tracker LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) diff --git a/build/CMakeCache.txt b/build/CMakeCache.txt index 406c555..0422112 100644 --- a/build/CMakeCache.txt +++ b/build/CMakeCache.txt @@ -201,8 +201,8 @@ CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING= //Path to a program. CMAKE_STRIP:FILEPATH=/usr/bin/strip -//The CMake toolchain file -CMAKE_TOOLCHAIN_FILE:FILEPATH=/media/mht/ADATA/repos/cpp_tracker/vcpkg/scripts/buildsystems/vcpkg.cmake +//No help, variable specified on the command line. +CMAKE_TOOLCHAIN_FILE:UNINITIALIZED=../vcpkg/scripts/buildsystems/vcpkg.cmake //If this value is on, makefiles will be generated without the // .SILENT directive, and all commands will be echoed to the console diff --git a/build/CMakeFiles/Makefile.cmake b/build/CMakeFiles/Makefile.cmake index c73d85b..e801f2c 100644 --- a/build/CMakeFiles/Makefile.cmake +++ b/build/CMakeFiles/Makefile.cmake @@ -75,6 +75,7 @@ set(CMAKE_DEPEND_INFO_FILES "CMakeFiles/bb_regressor.dir/DependInfo.cmake" "CMakeFiles/classifier.dir/DependInfo.cmake" "CMakeFiles/resnet.dir/DependInfo.cmake" + "CMakeFiles/dimp_tracker.dir/DependInfo.cmake" "CMakeFiles/tracking_demo.dir/DependInfo.cmake" "CMakeFiles/test_models.dir/DependInfo.cmake" ) diff --git a/build/CMakeFiles/Makefile2 b/build/CMakeFiles/Makefile2 index 651bdcf..d8d1ab1 100644 --- a/build/CMakeFiles/Makefile2 +++ b/build/CMakeFiles/Makefile2 @@ -66,6 +66,7 @@ CMAKE_BINARY_DIR = /media/mht/ADATA/repos/cpp_tracker/build all: CMakeFiles/bb_regressor.dir/all all: CMakeFiles/classifier.dir/all all: CMakeFiles/resnet.dir/all +all: CMakeFiles/dimp_tracker.dir/all all: CMakeFiles/tracking_demo.dir/all all: CMakeFiles/test_models.dir/all .PHONY : all @@ -78,6 +79,7 @@ preinstall: clean: CMakeFiles/bb_regressor.dir/clean clean: CMakeFiles/classifier.dir/clean clean: CMakeFiles/resnet.dir/clean +clean: CMakeFiles/dimp_tracker.dir/clean clean: CMakeFiles/tracking_demo.dir/clean clean: CMakeFiles/test_models.dir/clean .PHONY : clean @@ -141,7 +143,7 @@ CMakeFiles/classifier.dir/clean: CMakeFiles/resnet.dir/all: $(MAKE) $(MAKESILENT) -f CMakeFiles/resnet.dir/build.make CMakeFiles/resnet.dir/depend $(MAKE) $(MAKESILENT) -f CMakeFiles/resnet.dir/build.make CMakeFiles/resnet.dir/build - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles --progress-num=6,7 "Built target resnet" + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles --progress-num=8,9 "Built target resnet" .PHONY : CMakeFiles/resnet.dir/all # Build rule for subdir invocation for target. @@ -160,21 +162,48 @@ CMakeFiles/resnet.dir/clean: $(MAKE) $(MAKESILENT) -f CMakeFiles/resnet.dir/build.make CMakeFiles/resnet.dir/clean .PHONY : CMakeFiles/resnet.dir/clean +#============================================================================= +# Target rules for target CMakeFiles/dimp_tracker.dir + +# All Build rule for target. +CMakeFiles/dimp_tracker.dir/all: + $(MAKE) $(MAKESILENT) -f CMakeFiles/dimp_tracker.dir/build.make CMakeFiles/dimp_tracker.dir/depend + $(MAKE) $(MAKESILENT) -f CMakeFiles/dimp_tracker.dir/build.make CMakeFiles/dimp_tracker.dir/build + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles --progress-num=6,7 "Built target dimp_tracker" +.PHONY : CMakeFiles/dimp_tracker.dir/all + +# Build rule for subdir invocation for target. +CMakeFiles/dimp_tracker.dir/rule: cmake_check_build_system + $(CMAKE_COMMAND) -E cmake_progress_start /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles 2 + $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 CMakeFiles/dimp_tracker.dir/all + $(CMAKE_COMMAND) -E cmake_progress_start /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles 0 +.PHONY : CMakeFiles/dimp_tracker.dir/rule + +# Convenience name for target. +dimp_tracker: CMakeFiles/dimp_tracker.dir/rule +.PHONY : dimp_tracker + +# clean rule for target. +CMakeFiles/dimp_tracker.dir/clean: + $(MAKE) $(MAKESILENT) -f CMakeFiles/dimp_tracker.dir/build.make CMakeFiles/dimp_tracker.dir/clean +.PHONY : CMakeFiles/dimp_tracker.dir/clean + #============================================================================= # Target rules for target CMakeFiles/tracking_demo.dir # All Build rule for target. CMakeFiles/tracking_demo.dir/all: CMakeFiles/resnet.dir/all -CMakeFiles/tracking_demo.dir/all: CMakeFiles/bb_regressor.dir/all CMakeFiles/tracking_demo.dir/all: CMakeFiles/classifier.dir/all +CMakeFiles/tracking_demo.dir/all: CMakeFiles/dimp_tracker.dir/all +CMakeFiles/tracking_demo.dir/all: CMakeFiles/bb_regressor.dir/all $(MAKE) $(MAKESILENT) -f CMakeFiles/tracking_demo.dir/build.make CMakeFiles/tracking_demo.dir/depend $(MAKE) $(MAKESILENT) -f CMakeFiles/tracking_demo.dir/build.make CMakeFiles/tracking_demo.dir/build - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles --progress-num=10,11 "Built target tracking_demo" + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles --progress-num=12,13 "Built target tracking_demo" .PHONY : CMakeFiles/tracking_demo.dir/all # Build rule for subdir invocation for target. CMakeFiles/tracking_demo.dir/rule: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles 9 + $(CMAKE_COMMAND) -E cmake_progress_start /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles 11 $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 CMakeFiles/tracking_demo.dir/all $(CMAKE_COMMAND) -E cmake_progress_start /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles 0 .PHONY : CMakeFiles/tracking_demo.dir/rule @@ -193,16 +222,17 @@ CMakeFiles/tracking_demo.dir/clean: # All Build rule for target. CMakeFiles/test_models.dir/all: CMakeFiles/resnet.dir/all -CMakeFiles/test_models.dir/all: CMakeFiles/bb_regressor.dir/all CMakeFiles/test_models.dir/all: CMakeFiles/classifier.dir/all +CMakeFiles/test_models.dir/all: CMakeFiles/dimp_tracker.dir/all +CMakeFiles/test_models.dir/all: CMakeFiles/bb_regressor.dir/all $(MAKE) $(MAKESILENT) -f CMakeFiles/test_models.dir/build.make CMakeFiles/test_models.dir/depend $(MAKE) $(MAKESILENT) -f CMakeFiles/test_models.dir/build.make CMakeFiles/test_models.dir/build - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles --progress-num=8,9 "Built target test_models" + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles --progress-num=10,11 "Built target test_models" .PHONY : CMakeFiles/test_models.dir/all # Build rule for subdir invocation for target. CMakeFiles/test_models.dir/rule: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles 9 + $(CMAKE_COMMAND) -E cmake_progress_start /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles 11 $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 CMakeFiles/test_models.dir/all $(CMAKE_COMMAND) -E cmake_progress_start /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles 0 .PHONY : CMakeFiles/test_models.dir/rule diff --git a/build/CMakeFiles/TargetDirectories.txt b/build/CMakeFiles/TargetDirectories.txt index 96ccc6a..eb8a3fb 100644 --- a/build/CMakeFiles/TargetDirectories.txt +++ b/build/CMakeFiles/TargetDirectories.txt @@ -1,6 +1,7 @@ /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/bb_regressor.dir /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/classifier.dir /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/resnet.dir +/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/dimp_tracker.dir /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/tracking_demo.dir /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/test_models.dir /media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/test.dir diff --git a/build/CMakeFiles/bb_regressor.dir/cimp/bb_regressor/bb_regressor.cpp.o b/build/CMakeFiles/bb_regressor.dir/cimp/bb_regressor/bb_regressor.cpp.o index 3fe0b60..bf6d2e2 100644 Binary files a/build/CMakeFiles/bb_regressor.dir/cimp/bb_regressor/bb_regressor.cpp.o and b/build/CMakeFiles/bb_regressor.dir/cimp/bb_regressor/bb_regressor.cpp.o differ diff --git a/build/CMakeFiles/progress.marks b/build/CMakeFiles/progress.marks index b4de394..b1bd38b 100644 --- a/build/CMakeFiles/progress.marks +++ b/build/CMakeFiles/progress.marks @@ -1 +1 @@ -11 +13 diff --git a/build/CMakeFiles/tracking_demo.dir/DependInfo.cmake b/build/CMakeFiles/tracking_demo.dir/DependInfo.cmake index 5cf7a78..2e978d8 100644 --- a/build/CMakeFiles/tracking_demo.dir/DependInfo.cmake +++ b/build/CMakeFiles/tracking_demo.dir/DependInfo.cmake @@ -16,6 +16,7 @@ set(CMAKE_TARGET_LINKED_INFO_FILES "/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/bb_regressor.dir/DependInfo.cmake" "/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/classifier.dir/DependInfo.cmake" "/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/resnet.dir/DependInfo.cmake" + "/media/mht/ADATA/repos/cpp_tracker/build/CMakeFiles/dimp_tracker.dir/DependInfo.cmake" ) # Fortran module output directory. diff --git a/build/CMakeFiles/tracking_demo.dir/build.make b/build/CMakeFiles/tracking_demo.dir/build.make index 8d34dcd..88a9f4d 100644 --- a/build/CMakeFiles/tracking_demo.dir/build.make +++ b/build/CMakeFiles/tracking_demo.dir/build.make @@ -95,6 +95,7 @@ tracking_demo: CMakeFiles/tracking_demo.dir/build.make tracking_demo: libbb_regressor.a tracking_demo: libclassifier.a tracking_demo: libresnet.a +tracking_demo: libdimp_tracker.a tracking_demo: /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch.so tracking_demo: /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libc10.so tracking_demo: /usr/local/cuda-11.8/lib64/stubs/libcuda.so diff --git a/build/CMakeFiles/tracking_demo.dir/link.txt b/build/CMakeFiles/tracking_demo.dir/link.txt index 22f7d93..e757dd8 100644 --- a/build/CMakeFiles/tracking_demo.dir/link.txt +++ b/build/CMakeFiles/tracking_demo.dir/link.txt @@ -1 +1 @@ -/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/tracking_demo.dir/cimp/demo.cpp.o -o tracking_demo -L/usr/local/cuda-11.8/targets/x86_64-linux/lib/stubs -L/usr/local/cuda-11.8/targets/x86_64-linux/lib -Wl,-rpath,/home/mht/libtorch_1.8.0_cu111/libtorch/lib:/usr/local/cuda-11.8/lib64/stubs:/usr/local/cuda-11.8/lib64: libbb_regressor.a libclassifier.a libresnet.a /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch.so /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libc10.so /usr/local/cuda-11.8/lib64/stubs/libcuda.so /usr/local/cuda-11.8/lib64/libnvrtc.so /usr/local/cuda-11.8/lib64/libnvToolsExt.so /usr/local/cuda-11.8/lib64/libcudart.so /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libc10_cuda.so -Wl,--no-as-needed,"/home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch_cuda.so" -Wl,--as-needed -Wl,--no-as-needed,"/home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch_cuda_cu.so" -Wl,--as-needed -Wl,--no-as-needed,"/home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch_cpu.so" -Wl,--as-needed /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libc10_cuda.so /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libc10.so /usr/local/cuda-11.8/lib64/libcufft.so /usr/local/cuda-11.8/lib64/libcurand.so /usr/local/cuda-11.8/lib64/libcublas.so /usr/lib/x86_64-linux-gnu/libcudnn.so -Wl,--no-as-needed,"/home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch_cuda_cpp.so" -Wl,--as-needed -Wl,--no-as-needed,"/home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch.so" -Wl,--as-needed /usr/local/cuda-11.8/lib64/libnvToolsExt.so /usr/local/cuda-11.8/lib64/libcudart.so -lcudadevrt -lcudart_static -lrt -lpthread -ldl +/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/tracking_demo.dir/cimp/demo.cpp.o -o tracking_demo -L/usr/local/cuda-11.8/targets/x86_64-linux/lib/stubs -L/usr/local/cuda-11.8/targets/x86_64-linux/lib -Wl,-rpath,/home/mht/libtorch_1.8.0_cu111/libtorch/lib:/usr/local/cuda-11.8/lib64/stubs:/usr/local/cuda-11.8/lib64: libbb_regressor.a libclassifier.a libresnet.a libdimp_tracker.a /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch.so /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libc10.so /usr/local/cuda-11.8/lib64/stubs/libcuda.so /usr/local/cuda-11.8/lib64/libnvrtc.so /usr/local/cuda-11.8/lib64/libnvToolsExt.so /usr/local/cuda-11.8/lib64/libcudart.so /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libc10_cuda.so -Wl,--no-as-needed,"/home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch_cuda.so" -Wl,--as-needed -Wl,--no-as-needed,"/home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch_cuda_cu.so" -Wl,--as-needed -Wl,--no-as-needed,"/home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch_cpu.so" -Wl,--as-needed /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libc10_cuda.so /home/mht/libtorch_1.8.0_cu111/libtorch/lib/libc10.so /usr/local/cuda-11.8/lib64/libcufft.so /usr/local/cuda-11.8/lib64/libcurand.so /usr/local/cuda-11.8/lib64/libcublas.so /usr/lib/x86_64-linux-gnu/libcudnn.so -Wl,--no-as-needed,"/home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch_cuda_cpp.so" -Wl,--as-needed -Wl,--no-as-needed,"/home/mht/libtorch_1.8.0_cu111/libtorch/lib/libtorch.so" -Wl,--as-needed /usr/local/cuda-11.8/lib64/libnvToolsExt.so /usr/local/cuda-11.8/lib64/libcudart.so -lcudadevrt -lcudart_static -lrt -lpthread -ldl diff --git a/build/CMakeFiles/tracking_demo.dir/progress.make b/build/CMakeFiles/tracking_demo.dir/progress.make index 17875e3..7df1340 100644 --- a/build/CMakeFiles/tracking_demo.dir/progress.make +++ b/build/CMakeFiles/tracking_demo.dir/progress.make @@ -1,3 +1,3 @@ -CMAKE_PROGRESS_1 = 10 -CMAKE_PROGRESS_2 = 11 +CMAKE_PROGRESS_1 = 12 +CMAKE_PROGRESS_2 = 13 diff --git a/build/Makefile b/build/Makefile index 5f52c19..e19f2e6 100644 --- a/build/Makefile +++ b/build/Makefile @@ -210,6 +210,19 @@ resnet/fast: $(MAKE) $(MAKESILENT) -f CMakeFiles/resnet.dir/build.make CMakeFiles/resnet.dir/build .PHONY : resnet/fast +#============================================================================= +# Target rules for targets named dimp_tracker + +# Build rule for target. +dimp_tracker: cmake_check_build_system + $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 dimp_tracker +.PHONY : dimp_tracker + +# fast build rule for target. +dimp_tracker/fast: + $(MAKE) $(MAKESILENT) -f CMakeFiles/dimp_tracker.dir/build.make CMakeFiles/dimp_tracker.dir/build +.PHONY : dimp_tracker/fast + #============================================================================= # Target rules for targets named tracking_demo @@ -332,6 +345,30 @@ cimp/demo.cpp.s: $(MAKE) $(MAKESILENT) -f CMakeFiles/tracking_demo.dir/build.make CMakeFiles/tracking_demo.dir/cimp/demo.cpp.s .PHONY : cimp/demo.cpp.s +cimp/dimp_tracker.o: cimp/dimp_tracker.cpp.o +.PHONY : cimp/dimp_tracker.o + +# target to build an object file +cimp/dimp_tracker.cpp.o: + $(MAKE) $(MAKESILENT) -f CMakeFiles/dimp_tracker.dir/build.make CMakeFiles/dimp_tracker.dir/cimp/dimp_tracker.cpp.o +.PHONY : cimp/dimp_tracker.cpp.o + +cimp/dimp_tracker.i: cimp/dimp_tracker.cpp.i +.PHONY : cimp/dimp_tracker.i + +# target to preprocess a source file +cimp/dimp_tracker.cpp.i: + $(MAKE) $(MAKESILENT) -f CMakeFiles/dimp_tracker.dir/build.make CMakeFiles/dimp_tracker.dir/cimp/dimp_tracker.cpp.i +.PHONY : cimp/dimp_tracker.cpp.i + +cimp/dimp_tracker.s: cimp/dimp_tracker.cpp.s +.PHONY : cimp/dimp_tracker.s + +# target to generate assembly for a file +cimp/dimp_tracker.cpp.s: + $(MAKE) $(MAKESILENT) -f CMakeFiles/dimp_tracker.dir/build.make CMakeFiles/dimp_tracker.dir/cimp/dimp_tracker.cpp.s +.PHONY : cimp/dimp_tracker.cpp.s + cimp/resnet/resnet.o: cimp/resnet/resnet.cpp.o .PHONY : cimp/resnet/resnet.o @@ -395,6 +432,7 @@ help: @echo "... test" @echo "... bb_regressor" @echo "... classifier" + @echo "... dimp_tracker" @echo "... resnet" @echo "... test_models" @echo "... tracking_demo" @@ -410,6 +448,9 @@ help: @echo "... cimp/demo.o" @echo "... cimp/demo.i" @echo "... cimp/demo.s" + @echo "... cimp/dimp_tracker.o" + @echo "... cimp/dimp_tracker.i" + @echo "... cimp/dimp_tracker.s" @echo "... cimp/resnet/resnet.o" @echo "... cimp/resnet/resnet.i" @echo "... cimp/resnet/resnet.s" diff --git a/build/cmake_install.cmake b/build/cmake_install.cmake index 328cbf4..39ae9a4 100644 --- a/build/cmake_install.cmake +++ b/build/cmake_install.cmake @@ -114,6 +114,10 @@ if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "/media/mht/ADATA/repos/cpp_tracker/build/libbb_regressor.a") endif() +if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT) + file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "/media/mht/ADATA/repos/cpp_tracker/build/libdimp_tracker.a") +endif() + if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT) file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE DIRECTORY OPTIONAL FILES "/home/mht/libtorch_1.8.0_cu111/libtorch/share/cmake/Torch/../lib/" USE_SOURCE_PERMISSIONS FILES_MATCHING REGEX "/[^/]*\\.so[^/]*$" REGEX "/[^/]*\\.dylib[^/]*$" REGEX "/[^/]*\\.dll$" REGEX "/c10[^/]*\\.dll$" REGEX "/torch\\_cpu[^/]*\\.dll$" REGEX "/torch\\_cuda[^/]*\\.dll$" REGEX "/torch\\.dll$" REGEX "/cudnn[^/]*\\.dll$") endif() diff --git a/build/libbb_regressor.a b/build/libbb_regressor.a index f2adc9d..c2b843b 100644 Binary files a/build/libbb_regressor.a and b/build/libbb_regressor.a differ diff --git a/build/tracking_demo b/build/tracking_demo index 2ed6e80..6a748dc 100644 Binary files a/build/tracking_demo and b/build/tracking_demo differ diff --git a/cimp/dimp_tracker.cpp b/cimp/dimp_tracker.cpp new file mode 100644 index 0000000..c477ca5 --- /dev/null +++ b/cimp/dimp_tracker.cpp @@ -0,0 +1,97 @@ +#include "dimp_tracker.h" +#include // For debugging output + +namespace cimp { + +DiMPTracker::DiMPTracker(const DiMPTrackerParams& params, + const std::string& resnet_weights_dir, + const std::string& classifier_weights_dir, + const std::string& bbregressor_weights_dir, + torch::Device device) + : params_(params), + device_(device), + resnet_model_(cimp::resnet::resnet50(resnet_weights_dir, {"layer2", "layer3", "layer4"}, device)), + classifier_model_(classifier_weights_dir, device), + bbregressor_model_(bbregressor_weights_dir, device) +{ + // Move models to the specified device (should be handled by individual model constructors or their to() methods if they have one) + // However, explicit to() calls ensure they are on the correct device if constructors don't guarantee it. + this->resnet_model_->to(this->device_); + // this->classifier_model_.to(this->device_); // Classifier constructor handles device + // this->bbregressor_model_.to(this->device_); // BBRegressor constructor handles device + + // Set models to evaluation mode + this->resnet_model_->eval(); + // this->classifier_model_.eval(); // Classifier does not have an explicit eval() method + this->bbregressor_model_.eval(); + + // Initialize some state variables from params + this->img_sample_sz_ = torch::tensor(params_.image_sample_size.vec(), torch::kInt64).to(torch::kFloat32); // Convert to float tensor for calculations + this->img_support_sz_ = this->img_sample_sz_.clone(); + + std::cout << "DiMPTracker initialized." << std::endl; + std::cout << " Device: " << (this->device_.is_cuda() ? "CUDA" : "CPU") << std::endl; + if (this->device_.is_cuda()) { + std::cout << " CUDA Device Index: " << this->device_.index() << std::endl; + } + std::cout << " ResNet, Classifier, and BBRegressor models constructed and set to eval mode." << std::endl; +} + +// --- Placeholder for initialize() --- +void DiMPTracker::initialize(const torch::Tensor& image_tensor_hwc_uchar, const torch::Tensor& initial_bbox_xywh) { + std::cout << "DiMPTracker::initialize() called (placeholder)." << std::endl; + // TODO: Implement full initialization logic + // 1. Convert image_tensor_hwc_uchar to CHW float tensor, normalize + // 2. Set initial pos_, target_sz_, image_sz_, target_scale_, base_target_sz_ + // 3. Call generate_init_samples + // 4. Call init_classifier_internal + // 5. Call init_iou_net_internal + + // Example: Convert image (assuming HWC uchar input) + auto image_chw_float = convert_image_to_tensor_chw_float(image_tensor_hwc_uchar); + this->image_sz_ = torch::tensor({image_chw_float.size(1), image_chw_float.size(2)}, torch::kFloat32).to(device_); // H, W + + // Example: Set initial state (ensure tensors are on device_) + this->pos_ = torch::tensor({initial_bbox_xywh[1].item() + (initial_bbox_xywh[3].item() - 1.0f) / 2.0f, + initial_bbox_xywh[0].item() + (initial_bbox_xywh[2].item() - 1.0f) / 2.0f}, + torch::kFloat32).to(device_); // y_center, x_center + this->target_sz_ = torch::tensor({initial_bbox_xywh[3].item(), initial_bbox_xywh[2].item()}, + torch::kFloat32).to(device_); // height, width + + double search_area = torch::prod(this->target_sz_ * params_.search_area_scale).item(); + this->target_scale_ = std::sqrt(search_area) / torch::prod(this->img_sample_sz_).sqrt().item(); + this->base_target_sz_ = this->target_sz_ / this->target_scale_; + + this->init_sample_pos_ = this->pos_.round(); + this->init_sample_scale_ = this->target_scale_; + + // TODO: Call generate_init_samples, init_classifier_internal, init_iou_net_internal +} + +// --- Placeholder for track() --- +torch::Tensor DiMPTracker::track(const torch::Tensor& image_tensor_hwc_uchar) { + std::cout << "DiMPTracker::track() called (placeholder)." << std::endl; + // TODO: Implement full tracking logic + // Return a dummy bounding box for now [x,y,w,h] + return torch::tensor({0.0, 0.0, 0.0, 0.0}, torch::kFloat32); +} + +// --- Helper Method Implementations (Placeholders or Basic Forms) --- +torch::Tensor DiMPTracker::convert_image_to_tensor_chw_float(const torch::Tensor& image_hwc_uchar) { + // Assuming image_hwc_uchar is HWC uint8 on CPU or CUDA + auto img_float = image_hwc_uchar.to(torch::kFloat32); + img_float = img_float.permute({2, 0, 1}); // HWC to CHW + + // Normalize: (img / 255.0 - mean) / std + // These are standard ImageNet mean/std + torch::Tensor mean = torch::tensor({0.485, 0.456, 0.406}, device_).reshape({3, 1, 1}); + torch::Tensor std_dev = torch::tensor({0.229, 0.224, 0.225}, device_).reshape({3, 1, 1}); + + img_float = img_float.div(255.0); + img_float = img_float.sub_(mean).div_(std_dev); + return img_float.contiguous(); +} + +// ... Other private method placeholders would go here ... + +} // namespace cimp \ No newline at end of file diff --git a/cimp/dimp_tracker.h b/cimp/dimp_tracker.h new file mode 100644 index 0000000..a7a87c1 --- /dev/null +++ b/cimp/dimp_tracker.h @@ -0,0 +1,197 @@ +#pragma once + +#include +#include +#include +#include +#include + +// Forward declare model classes if headers are not included yet to avoid circular dependencies +// Or include them if they are fundamental. For now, let's assume they will be included. +#include "resnet/resnet.h" +#include "classifier/classifier.h" +#include "bb_regressor/bb_regressor.h" + +namespace cimp { + +struct DiMPTrackerParams { + // --- Device --- + // torch::Device device = torch::kCUDA; // Will be set by DiMPTracker constructor + + // --- Input / Preprocessing --- + torch::IntArrayRef image_sample_size = {288, 288}; // Target size of the cropped image sample + std::string border_mode = "replicate"; // Border mode for patch extraction + double patch_max_scale_change = 1.5; // Max scale change for multiscale sampling + + // --- Target Model --- + double search_area_scale = 5.0; // Scale factor for the search area relative to the target size + double target_inside_ratio = 0.2; // Ratio for keeping target inside image boundaries + + // --- Classifier --- + // Augmentation parameters (can be a sub-struct if complex) + struct AugmentationParams { + double augmentation_expansion_factor = 2.0; + double random_shift_factor = 0.0; // Typically 0 for DiMP, but can be non-zero + std::vector relativeshift = {0.0, 0.0}; // Example, usually more shifts + std::vector blur = {}; // Sigmas for Gaussian blur + std::vector rotate = {}; // Angles for rotation + struct DropoutAug { + int num = 0; // Number of dropout samples + float prob = 0.0f; // Dropout probability + } dropout; + } augmentation; + + bool use_augmentation = true; + int sample_memory_size = 50; // For classifier's target_boxes memory + int net_opt_iter = 10; // Optimizer iterations for filter learning + + // --- IoU Net (BB Regressor) --- + bool use_iou_net = true; + double box_jitter_pos = 0.1; // Jitter for proposal generation (relative to square_box_sz) + double box_jitter_sz = 0.1; // Jitter for proposal generation + int box_refinement_iter = 5; // Iterations for box optimization + double box_refinement_step_length = 1.0; + double box_refinement_step_decay = 1.0; + double maximal_aspect_ratio = 5.0; + int iounet_k = 5; // Number of top proposals to average for final box + + // --- Localization --- + double target_not_found_threshold = 0.25; // Threshold to consider target lost + double target_neighborhood_scale = 2.2; // Scale for masking neighborhood around max score + bool update_scale_when_uncertain = true; + + // TODO: Add other parameters from DiMP Python code as needed + // e.g. feature_stride, kernel_size (these might be derived from network) +}; + +class DiMPTracker { +public: + DiMPTracker(const DiMPTrackerParams& params, + const std::string& resnet_weights_dir, + const std::string& classifier_weights_dir, + const std::string& bbregressor_weights_dir, + torch::Device device); + + // Initialize the tracker with the first frame and bounding box + // image: HWC, uint8 tensor or cv::Mat (needs conversion) + // initial_bbox_xywh: [x, y, w, h] tensor for the target in the first frame + void initialize(const torch::Tensor& image_tensor_hwc_uchar, const torch::Tensor& initial_bbox_xywh); + + // Track the target in subsequent frames + // image: HWC, uint8 tensor or cv::Mat + // Returns: [x, y, w, h] tensor for the predicted bounding box + torch::Tensor track(const torch::Tensor& image_tensor_hwc_uchar); + +private: + // --- Core Models --- + cimp::resnet::ResNet resnet_model_; + Classifier classifier_model_; // Classifier is in global namespace + BBRegressor bbregressor_model_; // BBRegressor is in global namespace + + // --- Parameters & Device --- + DiMPTrackerParams params_; + torch::Device device_; + + // --- Tracker State --- + torch::Tensor pos_; // Target position (y_center, x_center) in image coordinates + torch::Tensor target_sz_; // Target size (height, width) in image coordinates + torch::Tensor image_sz_; // Current image size (height, width) + double target_scale_; // Current scale factor of the target + torch::Tensor base_target_sz_; // Target size at scale 1.0 + torch::Tensor img_sample_sz_; // Size of the image sample patch (e.g., {288, 288}) + torch::Tensor img_support_sz_; // Usually same as img_sample_sz_ + + torch::Tensor init_sample_pos_; // Position used for generating initial samples + double init_sample_scale_; // Scale used for generating initial samples + + // Learned components + torch::Tensor target_filter_; // Learned DiMP classification filter: [num_filters, C, H, W] + std::vector iou_modulation_; // Learned IoU modulation vectors: list of [1, C, 1, 1] + + // Feature/Kernel sizes (often derived during initialization) + torch::Tensor feature_sz_; // Size of the classification feature map (e.g., {18, 18}) + torch::Tensor kernel_size_; // Size of the classification filter (e.g., {4, 4}) + // torch::Tensor output_sz_; // output_sz = feature_sz + (kernel_size + 1)%2 + + // Augmentation transforms (might be more complex in C++) + // For now, logic will be in generate_init_samples + // std::vector> transforms_; + + // Stored target boxes for classifier training + torch::Tensor stored_target_boxes_; // [memory_size, 4] + + // --- Helper Methods (to be implemented in .cpp) --- + torch::Tensor convert_image_to_tensor_chw_float(const torch::Tensor& image_hwc_uchar); + + std::pair, torch::Tensor> generate_init_samples(const torch::Tensor& image_chw_float); + + void init_classifier_internal(const std::vector& init_backbone_feat_list, const torch::Tensor& init_target_boxes_aug); + void init_iou_net_internal(const std::vector& init_backbone_feat_list, const torch::Tensor& initial_bbox_for_iou); + + std::pair, torch::Tensor> extract_backbone_features( + const torch::Tensor& image_chw_float, + const torch::Tensor& pos, + const torch::Tensor& scales, // vector of scales + const torch::IntArrayRef& sample_sz); + + torch::Tensor get_classification_features(const std::map& backbone_feat); + std::vector get_iou_backbone_features(const std::map& backbone_feat); + std::vector get_iou_features(const std::map& backbone_feat); + + + std::pair get_sample_location(const torch::Tensor& sample_coords_xyxy); + torch::Tensor get_centered_sample_pos(); + + torch::Tensor classify_target(const torch::Tensor& test_x_clf_feat); + + struct LocalizationResult { + torch::Tensor translation_vec_yx; // y, x displacement + int64_t scale_idx; + torch::Tensor scores_peak_map; // The score map from the peak scale + std::string flag; // "normal", "not_found", "uncertain" + }; + LocalizationResult localize_target(const torch::Tensor& scores_raw, + const torch::Tensor& sample_pos_yx, + const torch::Tensor& sample_scales); + LocalizationResult localize_advanced(const torch::Tensor& scores_scaled, + const torch::Tensor& sample_pos_yx, + const torch::Tensor& sample_scales); + + + void update_state(const torch::Tensor& new_pos_yx); + torch::Tensor get_iounet_box(const torch::Tensor& pos_yx, const torch::Tensor& sz_hw, + const torch::Tensor& sample_pos_yx, double sample_scale); + + void refine_target_box(const std::map& backbone_feat, + const torch::Tensor& sample_pos_yx, + double sample_scale, + int64_t scale_idx, + bool update_scale_flag); + + std::pair optimize_boxes_default( + const std::vector& iou_features, + const torch::Tensor& init_boxes_xywh); // proposals_xywh + + // Image processing / patch sampling helpers + std::pair sample_patch_multiscale_affine( + const torch::Tensor& im_chw_float, + const torch::Tensor& pos_yx, + const torch::Tensor& scales, // 1D tensor of scales + const torch::IntArrayRef& output_sz_hw, + const std::string& border_mode = "replicate", + std::optional max_scale_change = std::nullopt); + + std::pair sample_patch_transformed_affine( + const torch::Tensor& im_chw_float, + const torch::Tensor& pos_yx, + double scale, + const torch::IntArrayRef&aug_expansion_sz_hw, // Size of patch to extract before transform + const std::vector& affine_matrices, // One 2x3 affine matrix per transform + const torch::IntArrayRef& out_sz_hw // Final output size after transform + ); + + // Augmentation helpers + // ... +}; + +} // namespace cimp \ No newline at end of file