build: support OpenCV 5 and TensorRT 10
OpenCV: distros (Arch/CachyOS) now ship OpenCV 5 as default. The config package rejects a 5.x install when find_package requests 4, so probe for 5 first and fall back to 4. All components used here (core, imgproc, imgcodecs, videoio, dnn, objdetect, highgui) exist in both. TensorRT: nvinfer1::Dims5 was removed in TRT 10 (Dims2..Dims4 remain in NvInferLegacyDims.h). Build the TransNetV2 rank-5 input shape via the generic nvinfer1::Dims, which is valid on both 8.x and 10.x.
This commit is contained in:
@@ -18,8 +18,17 @@ endif()
|
|||||||
add_subdirectory(external/KPN)
|
add_subdirectory(external/KPN)
|
||||||
|
|
||||||
# OpenCV (video decode, image ops, DNN inference, face detection)
|
# OpenCV (video decode, image ops, DNN inference, face detection)
|
||||||
|
# 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
|
find_package(OpenCV 4 REQUIRED COMPONENTS
|
||||||
core imgproc imgcodecs videoio dnn objdetect highgui)
|
core imgproc imgcodecs videoio dnn objdetect highgui)
|
||||||
|
endif()
|
||||||
|
message(STATUS "OpenCV: ${OpenCV_VERSION}")
|
||||||
|
|
||||||
# ── Model paths ───────────────────────────────────────────────────────────────
|
# ── Model paths ───────────────────────────────────────────────────────────────
|
||||||
# Defined early so the backend object libraries below can embed it.
|
# Defined early so the backend object libraries below can embed it.
|
||||||
|
|||||||
@@ -511,8 +511,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(mu_);
|
std::lock_guard<std::mutex> lk(mu_);
|
||||||
context_->setInputShape(input_name_.c_str(),
|
// TensorRT 10 removed the fixed-rank Dims5 helper (Dims2..Dims4 remain
|
||||||
nvinfer1::Dims5{1, kWindow, kFrameH, kFrameW, 3});
|
// 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,
|
check_cuda(cudaMemcpyAsync(d_input_, buf.data(), buf.size() * 4,
|
||||||
cudaMemcpyHostToDevice, stream_), "H2D input");
|
cudaMemcpyHostToDevice, stream_), "H2D input");
|
||||||
|
|||||||
Reference in New Issue
Block a user