diff --git a/CMakeLists.txt b/CMakeLists.txt index ee53db7..8a889fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,17 @@ endif() add_subdirectory(external/KPN) # OpenCV (video decode, image ops, DNN inference, face detection) -find_package(OpenCV 4 REQUIRED COMPONENTS +# Accept 4 or 5: the APIs used here are stable across both, and distros have +# begun shipping 5.x as the default (Arch/CachyOS). find_package's version +# argument is a minimum, but OpenCV's config rejects a 5.x install when 4 is +# requested, so probe for 5 first and fall back to 4. +find_package(OpenCV 5 QUIET COMPONENTS core imgproc imgcodecs videoio dnn objdetect highgui) +if(NOT OpenCV_FOUND) + find_package(OpenCV 4 REQUIRED COMPONENTS + core imgproc imgcodecs videoio dnn objdetect highgui) +endif() +message(STATUS "OpenCV: ${OpenCV_VERSION}") # ── Model paths ─────────────────────────────────────────────────────────────── # Defined early so the backend object libraries below can embed it. diff --git a/src/backends/trt_backend.cpp b/src/backends/trt_backend.cpp index b6e8459..4850ad0 100644 --- a/src/backends/trt_backend.cpp +++ b/src/backends/trt_backend.cpp @@ -511,8 +511,17 @@ public: } std::lock_guard lk(mu_); - context_->setInputShape(input_name_.c_str(), - nvinfer1::Dims5{1, kWindow, kFrameH, kFrameW, 3}); + // TensorRT 10 removed the fixed-rank Dims5 helper (Dims2..Dims4 remain + // in NvInferLegacyDims.h). Build the rank-5 shape via the generic Dims, + // which works on both 8.x and 10.x. + nvinfer1::Dims shape{}; + shape.nbDims = 5; + shape.d[0] = 1; + shape.d[1] = kWindow; + shape.d[2] = kFrameH; + shape.d[3] = kFrameW; + shape.d[4] = 3; + context_->setInputShape(input_name_.c_str(), shape); check_cuda(cudaMemcpyAsync(d_input_, buf.data(), buf.size() * 4, cudaMemcpyHostToDevice, stream_), "H2D input");