From 3d95aa04c32cddbdb68d9fecb8afe314ba2d351f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 11 Dec 2025 07:58:03 +0000 Subject: [PATCH] Checkpoint before follow-up message Co-authored-by: xutsuzepeng --- build.sh | 24 ++++-------------------- demo/demo.cpp | 13 +++++++++++-- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/build.sh b/build.sh index d1294e6..e79378d 100755 --- a/build.sh +++ b/build.sh @@ -1,19 +1,5 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Release build script -BUILD_DIR="build" -JOBS="${1:-$(nproc)}" - -echo "[build.sh] Configuring Release build in ${BUILD_DIR}" -mkdir -p "${BUILD_DIR}" -cmake -S . -B "${BUILD_DIR}" -DCMAKE_BUILD_TYPE=Release - -echo "[build.sh] Building (jobs=${JOBS})" -cmake --build "${BUILD_DIR}" --parallel "${JOBS}" - -echo "[build.sh] Done. Executable (if any) is in ${BUILD_DIR}" #!/bin/bash +set -e # 清理旧的构建文件(如果存在) if [ -d "build" ]; then @@ -26,17 +12,15 @@ mkdir -p build cd build # 运行 CMake 配置 -cmake .. +cmake -DCMAKE_BUILD_TYPE=Release .. # 编译项目 make -j$(nproc) # 创建 compile_commands.json 的符号链接到根目录(用于IDE) -if [ -f "compile_commands.json" ]; then - cd .. +cd .. +if [ -f "build/compile_commands.json" ]; then ln -sf build/compile_commands.json compile_commands.json 2>/dev/null || true - cd build fi echo "构建完成!可执行文件位于: build/demo" - diff --git a/demo/demo.cpp b/demo/demo.cpp index 2dc8c75..2906f45 100644 --- a/demo/demo.cpp +++ b/demo/demo.cpp @@ -125,10 +125,19 @@ int demo_opencl(const Mat& imgSrc) int main() { - Mat imgSrc = imread("/home/domian/cuda/data/blob.jpg", IMREAD_GRAYSCALE); + // 尝试读取当前目录下的data目录,或者上级目录的data目录 + string imgPath = "./data/blob.jpg"; + Mat imgSrc = imread(imgPath, IMREAD_GRAYSCALE); if (imgSrc.empty()) { - cout << "无法读取图像文件" << endl; + // 尝试上级目录 + imgPath = "../data/blob.jpg"; + imgSrc = imread(imgPath, IMREAD_GRAYSCALE); + } + + if (imgSrc.empty()) + { + cout << "无法读取图像文件: " << imgPath << endl; return -1; }