中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

注冊登錄汕頭搜索引擎優(yōu)化服務(wù)

注冊登錄,汕頭搜索引擎優(yōu)化服務(wù),網(wǎng)站建實例,新手做網(wǎng)站用什么軟件目錄 opencv gpu版本編譯,實現(xiàn)硬解碼,加速rtsp視頻流讀取1、準備文件2、復(fù)制 NVCUVID 頭文件到 cuda 安裝目錄 include3、安裝相關(guān)依賴4、 執(zhí)行cmake5、編譯安裝6、測試 opencv gpu版本編譯,實現(xiàn)硬解碼,加速rtsp視頻流讀取 前置條…

目錄

  • opencv gpu版本編譯,實現(xiàn)硬解碼,加速rtsp視頻流讀取
      • 1、準備文件
      • 2、復(fù)制 NVCUVID 頭文件到 cuda 安裝目錄 include
      • 3、安裝相關(guān)依賴
      • 4、 執(zhí)行cmake
      • 5、編譯安裝
      • 6、測試

opencv gpu版本編譯,實現(xiàn)硬解碼,加速rtsp視頻流讀取

前置條件,顯卡驅(qū)動,cuda 已安裝

這里cuda安裝路徑為 /usr/local/cuda-11.2

1、準備文件

  • opencv-4.5.5

  • opencv_contrib-4.5.5
    在這里插入圖片描述

  • nucuvid:官網(wǎng)下載
    在這里插入圖片描述

2、復(fù)制 NVCUVID 頭文件到 cuda 安裝目錄 include

sudo cp cuviddec.h nvcuid.h nvEncodeAPI. /usr/local/cuda-11.2/include

3、安裝相關(guān)依賴

  • 執(zhí)行01_install_dependence.sh
#!/bin/bashsudo apt update
sudo apt upgrade#sudo apt install -y gcc-10 g++-10
sudo apt install -y build-essential cmake pkg-config yasm git checkinstall
sudo apt install -y pkg-config yasm checkinstall
sudo apt install -y libjpeg-dev libpng-dev libtiff-dev
sudo apt install -y libavcodec-dev libavformat-dev libswscale-dev 
sudo apt install -y libxvidcore-dev x264 libx264-dev libfaac-dev libmp3lame-dev libtheora-dev 
sudo apt install -y libfaac-dev libmp3lame-dev libvorbis-dev
sudo apt install -y libgtkglext1 libgtkglext1-dev
sudo apt-get install -y libavresample-dev libdc1394-22 libdc1394-22-dev libxine2-dev libv4l-dev v4l-utils

4、 執(zhí)行cmake

  • 執(zhí)行02_install_opencv.sh
cd opencv_build
#unzip opencv.zip
#unzip opencv_contrib.zipecho "Moving onto the build portion of things"
cd opencv-4.5.5
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \-D CMAKE_C_COMPILER=/usr/bin/gcc-9 \-D CMAKE_INSTALL_PREFIX=../install_dir \-D OPENCV_GENERATE_PKGCONFIG=ON \-D BUILD_opencv_python3=ON \-D CUDA_ARCH_BIN=8.6\-D WITH_CUDA=ON \-D WITH_CUDNN=ON \-D OPENCV_DNN_CUDA=ON \-D ENABLE_FAST_MATH=1 \-D CUDA_FAST_MATH=1 \-D OPENCV_ENABLE_NONFREE=ON \-D WTIH_CUBLAS=1 \-D WITH_V4L=ON \-D WITH_NVCUVID=ON \-D WITH_OPENGL=ON \-D WITH_FFMPEG=ON \-D BUILD_opencv_java=ON \-D OPENCV_EXTRA_MODULES_PATH=~/opencv_project/opencv_build/opencv_contrib-4.5.5/modules ..echo "Configuring build & making OpenCV"
echo 'finished all the shit'

需要注意的地方

  • -D CMAKE_INSTALL_PREFIX=../install_dir:安裝路徑

  • -D CUDA_ARCH_BIN=8.6 : 顯卡算力

  • -D WITH_CUDA=ON:啟用CUDA支持

  • -D WITH_CUDNN=ON:啟用CUDNN支持

  • -D OPENCV_DNN_CUDA=ON:啟用CUDA加速的深度學習模塊

  • -D WITH_NVCUVID=ON:啟用NVCUVID支持,允許OpenCV在NVIDIA GPU上解碼視頻。

  • -D BUILD_opencv_java=ON : 啟用 java 支持,需要先配置好java環(huán)境變量(jdk,ant),可選項

cmake 執(zhí)行完成

-- 
--   OpenCV modules:
--     To be built:                 alphamat aruco barcode bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform java line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 cvv hdf julia matlab ovis python2 python3 sfm viz
--     Applications:                tests perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         YES
-- 
--   GUI:                           GTK2
--     GTK+:                        YES (ver 2.24.32)
--       GThread :                  YES (ver 2.64.6)
--       GtkGlExt:                  YES (ver 1.2.0)
--     OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so)
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
--     JPEG 2000:                   build (ver 2.4.0)
--     OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2_3)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      YES (2.2.5)
--     FFMPEG:                      YES
--       avcodec:                   YES (58.54.100)
--       avformat:                  YES (58.29.100)
--       avutil:                    YES (56.31.100)
--       swscale:                   YES (5.5.100)
--       avresample:                YES (4.0.0)
--     GStreamer:                   YES (1.16.3)
--     v4l/v4l2:                    YES (linux/videodev2.h)
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2020.0.0 Gold [2020.0.0]
--            at:                   /home/dell/ljn/opencv_project/opencv_build/opencv-4.5.5/build/3rdparty/ippicv/ippicv_lnx/icv
--     Intel IPP IW:                sources (2020.0.0)
--               at:                /home/dell/ljn/opencv_project/opencv_build/opencv-4.5.5/build/3rdparty/ippicv/ippicv_lnx/iw
--     VA:                          NO
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.3.9)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.19.1)
-- 
--   NVIDIA CUDA:                   YES (ver 11.2, CUFFT CUBLAS NVCUVID FAST_MATH)
--     NVIDIA GPU arch:             86
--     NVIDIA PTX archs:
-- 
--   cuDNN:                         YES (ver 8.6.0)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/dell/ljn/opencv_project/opencv_build/opencv-4.5.5/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.8.10)
--     Libraries:                   NO
--     numpy:                       NO (Python3 wrappers can not be generated)
--     install path:                -
-- 
--   Python (for build):            /usr/bin/python3
-- 
--   Java:                          
--     ant:                         /usr/local/apache-ant-1.10.13/bin/ant (ver 1.10.13)
--     JNI:                         /usr/lib/jvm/jdk1.8.0_361/include /usr/lib/jvm/jdk1.8.0_361/include/linux /usr/lib/jvm/jdk1.8.0_361/include
--     Java wrappers:               YES
--     Java tests:                  YES
-- 
--   Install to:                    /home/dell/ljn/opencv_project/opencv_build/opencv-4.5.5/install_dir
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dell/ljn/opencv_project/opencv_build/opencv-4.5.5/build
Configuring build & making OpenCV
finished all the shit
  • gpu 加速開啟成功
    在這里插入圖片描述
  • java 支持開啟成功
    在這里插入圖片描述

5、編譯安裝

  • 進入cmake創(chuàng)建的build目錄

    cd opencv_build/opencv-4.5.5/build#編譯,根據(jù)電腦核心數(shù)選擇合適線程
    make -j30  
    
  • 安裝

    make install
    

6、測試

  • 進入目錄opencv_gpu_test,編譯執(zhí)行程序,在CMakeLIsts.txt中修改opencv的安裝路徑

    cd build
    make 
    ./opencv_test
    
  • CMakeLIsts.txt

    cmake_minimum_required(VERSION 3.0.2)
    project(opencv_test)
    SET(CMAKE_BUILD_TYPE "Release")# 安裝路徑
    find_package(OpenCV 4.5.5 REQUIRED PATHS /home/lenovo/opencv_project/opencv_build/opencv-4.5.5/install_dir)include_directories(${OpenCV_INCLUDE_DIRS})add_executable(opencv_test test.cc )
    #add_executable( opencv_test gpu_mat.cpp )
    target_link_libraries( opencv_test${OpenCV_LIBRARIES}/usr/lib/x86_64-linux-gnu)
    
  • test.cc

    #include <iostream>
    #include <string>
    #include <vector>
    #include <algorithm>
    #include <numeric>
    #include "opencv2/opencv_modules.hpp"
    #include <opencv2/core/utility.hpp>
    #include <opencv2/core.hpp>
    #include <opencv2/core/opengl.hpp>
    #include <opencv2/cudacodec.hpp>
    #include <opencv2/highgui.hpp>int main(int argc, const char* argv[])
    {//std::cout<<cv::getBuildInformation()<<std::endl;//將這個流改成你自己的const std::string fname = "rtsp://admin:abcd1234@192.168.1.110:554/smart264/ch1/main/av_stream";const std::string gfname = "rtsp://admin:abcd1234@192.168.1.110:554/Streaming/Channels/2";std::cout<<"Set device...."<<std::endl;int numDevice = cv::cuda::getCudaEnabledDeviceCount();std::cout<<"device count: "<<numDevice<<std::endl;int cudaDevice = 0;cv::cuda::setDevice(cudaDevice);//cv::cuda::setGlDevice(cudaDevice);//cv::cuda::setGlDevice(1);std::cout<<"read rtsp through cpu..."<<std::endl;cv::Mat frame;cv::VideoCapture reader(fname);cv::cuda::GpuMat d_frame;std::cout<<"read rtsp through cuda..."<<std::endl;cv::Ptr<cv::cudacodec::VideoReader> d_reader = cv::cudacodec::createVideoReader(fname);cv::TickMeter tm;std::vector<double> cpu_times;std::vector<double> gpu_times;std::cout<<"test"<<std::endl;for (int i = 0;i<500;i++){tm.reset(); tm.start();if (!reader.read(frame))break;tm.stop();cpu_times.push_back(tm.getTimeMilli());tm.reset(); tm.start();if (!d_reader->nextFrame(d_frame))break;tm.stop();gpu_times.push_back(tm.getTimeMilli());}if (!cpu_times.empty() || !gpu_times.empty()){std::cout << std::endl << "Results:" << std::endl;//std::sort(cpu_times.begin(), cpu_times.end());std::sort(gpu_times.begin(), gpu_times.end());//double cpu_avg = std::accumulate(cpu_times.begin(), cpu_times.end(), 0.0) / cpu_times.size();double gpu_avg = std::accumulate(gpu_times.begin(), gpu_times.end(), 0.0) / gpu_times.size();//std::cout << "CPU : Avg : " << cpu_avg << " ms FPS : " << 1000.0 / cpu_avg << std::endl;std::cout << "GPU : Avg : " << gpu_avg << " ms FPS : " << 1000.0 / gpu_avg << std::endl;}return 0;
    }
    // #endif
    
  • 結(jié)果如下安裝成功

在這里插入圖片描述

http://www.risenshineclean.com/news/11481.html

相關(guān)文章:

  • 找人做彩票網(wǎng)站多少錢seo推廣論壇
  • 騰網(wǎng)站建設(shè)谷歌google下載安卓版 app
  • 中國網(wǎng)站的特點seo數(shù)據(jù)統(tǒng)計分析工具有哪些
  • 免費軟件下載網(wǎng)站app南京百度網(wǎng)站推廣
  • 做網(wǎng)站時分類標題和分類描述搜索詞和關(guān)鍵詞
  • 鮮花加盟網(wǎng)站建設(shè)網(wǎng)站優(yōu)化與seo
  • 商城網(wǎng)站建設(shè)浩森宇特好看的網(wǎng)站ui
  • 成都網(wǎng)站建設(shè)公司電話seo網(wǎng)絡(luò)推廣公司
  • 香港網(wǎng)站不備案淘寶站外引流推廣方法
  • 建設(shè)網(wǎng)站6980塊錢貴嗎山西seo
  • 聊城網(wǎng)站建設(shè)方案網(wǎng)站推廣的基本方法有
  • 常州模板建站哪家好四年級寫一小段新聞
  • 浪琴手表網(wǎng)站建設(shè)圖公眾號引流推廣平臺
  • 禁止拿我們的網(wǎng)站做宣傳市場調(diào)研報告3000字范文
  • 國外 網(wǎng)站頁面跨境電商關(guān)鍵詞工具
  • 免費圖片素材網(wǎng)南京怎樣優(yōu)化關(guān)鍵詞排名
  • 東營建設(shè)信息網(wǎng)站百度手機導(dǎo)航官方新版
  • 門戶網(wǎng)站案例發(fā)稿推廣
  • 單位網(wǎng)站平臺建設(shè)匯報sem搜索
  • 創(chuàng)建學校網(wǎng)站今天的重要新聞
  • 竹子建站下載哈爾濱最新消息
  • 怎么做自己的推廣網(wǎng)站google seo 優(yōu)化
  • 手機網(wǎng)站永久免費制作seo如何優(yōu)化排名
  • 企業(yè)專業(yè)網(wǎng)站建設(shè)搜索引擎推廣簡稱
  • 建站快車打電話百度云鏈接
  • 湖南微信網(wǎng)站建設(shè)百度地圖推廣電話
  • 網(wǎng)站開發(fā)環(huán)境有什么網(wǎng)店營銷
  • 網(wǎng)站制作協(xié)議書阿里數(shù)據(jù)
  • 哈爾濱網(wǎng)站建設(shè)價格市場營銷方案范文5篇
  • 前端學習手機網(wǎng)站開發(fā)嗎網(wǎng)絡(luò)營銷的企業(yè)有哪些