Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"

13 changes: 11 additions & 2 deletions demo/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down