活了这么大也没中过奖,也没中过超过20块钱的彩票,居然在这个地方中奖了,很犀利!! 最终换成4.5.5版本的成功了: cmake的内容:
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_C_COMPILER=/usr/bin/gcc \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ \
-D CUDA_CUDA_LIBRARY=/usr/lib/x86_64-linux-gnu/libcuda.so \
-D CUDA_ARCH_BIN=7.5 \
-D CUDA_ARCH_PTX="" \
-D WITH_CUDA=ON \
-D WITH_TBB=ON \
-D WITH_FFMPEG=ON \
-D BUILD_PYTHON_SUPPORT=ON \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D BUILD_OPENCV_PYTHON3=ON \
-D PYTHON_INCLUDE_DIR=(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON_PACKAGES_PATH=(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D WITH_V4L=ON \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D WITH_QT=ON \
-D WITH_GSTREAMER=ON \
-D WITH_OPENGL=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_PC_FILE_NAME=opencv.pc \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-D CMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
-D WITH_CUBLAS=ON \
-D WITH_NVCUVID=ON \
-D BUILD_opencv_cudacodec=ON \
-D OPENCV_DNN_CUDA=ON \
-D WITH_CUDNN=ON \
-D OPENCV_ENABLE_NONFREE=ON\
-D WITH_GSTREAMER=ON \
-D BUILD_EXAMPLES=ON ..
兄弟们,发福利了啊,踩坑无数总结的.cache文件: 链接: https://pan.baidu.com/s/1Eq2U6WD3AL6lAaHLMqed9w 提取码: 6avj –来自百度网盘超级会员v5的分享 永久有效! 哭泣,纪念我逝去的脑细胞!
测试编译的对不对: 代码:
#include <iostream>
#include<opencv2/opencv.hpp>
int main(int argc, char* argv[])
{
cv::cuda::GpuMat img(400, 600, CV_8UC3, cv::Scalar(255, 0, 0));
cv::Mat cpuImg;
img.download(cpuImg);
cv::imshow("test", cpuImg);
cv::waitKey(0);
return 0;
}
不放心又搞了个匹配的试试 下班,下班!!
昨天临走的时候g++编译成功,但是vscode调用不成功,主要是cv::cuda:cvtColor函数,今天可以了 在task.json中加上lib库,现在的task.json长这样
{
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "g++",
"args": [
"-g",
"-std=c++11",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.out",
"`pkg-config", "--cflags", "--libs", "opencv`",
"-I", "/usr/local/include/opencv4",
"-I", "/usr/local/include/opencv4/opencv2",
"-I", "/usr/local/include",
"-L", "/usr/local/lib",
"-l", "opencv_core",
"-l", "opencv_imgproc",
"-l", "opencv_imgcodecs",
"-l", "opencv_video",
"-l", "opencv_ml",
"-l", "opencv_highgui",
"-l", "opencv_objdetect",
"-l", "opencv_flann",
"-l", "opencv_imgcodecs",
"-l", "opencv_photo",
"-l", "opencv_videoio"
],
"options": {
"cwd": "/usr/bin"
},
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
参考链接: 实践出真知——Ubuntu 18.04 VSCODE配置OpenCV4.5运行YOLO4模型
|