gpt4 book ai didi

c++ - libopencv_gpu.so.2.4 : cannot open shared object file: No such file or directory

转载 作者:太空宇宙 更新时间:2023-11-04 04:12:14 24 4
gpt4 key购买 nike

我正在尝试编译该代码(来自 gpu 示例的 houghlines.cpp):

#include <cmath>
#include <iostream>

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/gpu/gpu.hpp"
#include <stdlib.h>
#include <stdio.h>

using namespace std;
using namespace cv;
using namespace cv::gpu;

static void help()
{
cout << "This program demonstrates line finding with the Hough transform." << endl;
cout << "Usage:" << endl;
cout << "./gpu-example-houghlines <image_name>, Default is pic1.png\n" << endl;
}

int main(int argc, const char* argv[])
{

const string filename = argc >= 2 ? argv[1] : "~/Images/skorn00.png";

Mat src = imread(filename, IMREAD_GRAYSCALE);
if (src.empty())
{
help();
cout << "can not open " << filename << endl;
return -1;
}

Mat mask;
Canny(src, mask, 100, 200, 3);

Mat dst_cpu;
cvtColor(mask, dst_cpu, CV_GRAY2BGR);
Mat dst_gpu = dst_cpu.clone();

vector<Vec4i> lines_cpu;
{
const int64 start = getTickCount();

HoughLinesP(mask, lines_cpu, 1, CV_PI / 180, 50, 60, 5);

const double timeSec = (getTickCount() - start) / getTickFrequency();
cout << "CPU Time : " << timeSec * 1000 << " ms" << endl;
cout << "CPU Found : " << lines_cpu.size() << endl;
}

for (size_t i = 0; i < lines_cpu.size(); ++i)
{
Vec4i l = lines_cpu[i];
line(dst_cpu, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 3, CV_AA);
}

GpuMat d_src(mask);
GpuMat d_lines;
HoughLinesBuf d_buf;
{
const int64 start = getTickCount();

gpu::HoughLinesP(d_src, d_lines, d_buf, 1.0f, (float) (CV_PI / 180.0f), 50, 5);

const double timeSec = (getTickCount() - start) / getTickFrequency();
cout << "GPU Time : " << timeSec * 1000 << " ms" << endl;
cout << "GPU Found : " << d_lines.cols << endl;
}
vector<Vec4i> lines_gpu;
if (!d_lines.empty())
{
lines_gpu.resize(d_lines.cols);
Mat h_lines(1, d_lines.cols, CV_32SC4, &lines_gpu[0]);
d_lines.download(h_lines);
}

for (size_t i = 0; i < lines_gpu.size(); ++i)
{
Vec4i l = lines_gpu[i];
line(dst_gpu, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 3, CV_AA);
}

imshow("source", src);
imshow("detected lines [CPU]", dst_cpu);
imshow("detected lines [GPU]", dst_gpu);
waitKey();

return 0;
}

但是运行后我收到此消息(执行):/workspace/test_opencv/test_opencv/bin/Release/test_opencv:加载共享库时出错:libopencv_gpu.so.2.4:无法打开共享对象文件:没有这样的文件或目录

这是构建:-------------- 构建:在 test_gpu 中发布(编译器:GNU GCC 编译器)------------------------

g++ -Wall -fexceptions -O2 -I/usr/local/include -I/usr/local/include/opencv -c/home/thomas/workspace/test_opencv/test_gpu/main.cpp -o obj/Release/main.og++ -L/usr/local/include -L/usr/local/include/opencv -o bin/Release/test_gpu obj/Release/main.o -s/usr/local/lib/libopencv_calib3d.so/usr/local/lib/libopencv_contrib.so/usr/local/lib/libopencv_core.so/usr/local/lib/libopencv_features2d.so/usr/local/lib/libopen cv_flann.so/usr/local/lib/libopencv_gpu.so/usr/local/lib/libopencv_highgui.so/usr/local/lib/libopencv_imgproc.so/usr/local/lib/libopencv_legacy.so/usr/local/lib/libopencv_ml.so/usr/local/lib/libopencv_nonfree.so/usr/local/lib/libopencv_objdetect.so/usr/local/lib/libopencv_photo.so/usr/local/lib/libopencv_stitching.so/usr/local/lib/libopencv_superres.so/usr/local/lib/libopencv_ts.so/usr/local/lib/libopencv_video.so/usr/local/lib/libopencv_videostab.so输出大小为 14,44 KB进程终止,状态为 0(0 分钟,1 秒)0 个错误,0 个警告(0 分钟,1 秒)

CPU 示例中的 houghines.cpp 运行良好。看来它来自 libopen_gpu 库编译。当我使用 CUDA 编译 opencv 时,CMAKE 不会返回错误。怎么了?

最佳答案

关于c++ - libopencv_gpu.so.2.4 : cannot open shared object file: No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18573084/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com