0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VisualStudio2019 + OpenCV4.1.1 + CUDA10.1 のサンプルコード確認

Last updated at Posted at 2021-12-30

サンプル

  • サンプルデータ
    • E:/Program/OpenCV/opencv/sources/samples/data
      • 以下にコピー
        • E:/Program/OpenCV/build/modules
        • E:/Program/OpenCV/build/samples

サンプルコード E:/Program/OpenCV/opencv/sources/samples/gpu

alpha_comp.cpp

  • 画像のアルファ合成
    • #include "opencv2/cudaimgproc.hpp"
      • cv::cuda::alphaComp

bgfg_segm.cpp

  • 動画の読み込み
    • #include "opencv2/video.hpp"
      • cv::VideoCapture cap
  • 背景差分
    • #include "opencv2/cudabgsegm.hpp"
      • cv::cuda::createBackgroundSubtractorMOG
      • cv::cuda::createBackgroundSubtractorMOG2
    • mog->apply(d_frame, d_fgmask, 0.01)
      • 動画から黒背景、白動体を出力する
    • mog->getBackgroundImage(d_bgimg)
      • 動画から動体を除く背景を出力する
    • d_frame.copyTo(d_fgimg, d_fgmask)
      • 動画から動体を切り出し出力する

cascadeclassifier.cpp

  • コマンドライン引数に追加
    • --cascade E:/Program/OpenCV/opencv/sources/data/haarcascades_cuda/haarcascade_frontalface_alt.xml
    • E:/Program/OpenCV/opencv/sources/samples/winrt/FaceDetection/FaceDetection/Assets/group1.jpg
  • 顔認識

farneback_optical_flow.cpp

  • フレーム間の動体移動量
    • #include "opencv2/cudaoptflow.hpp"
      • cv::cuda::FarnebackOpticalFlow
  • GpuMatの配列(InputOutputArray)を分割
    • #include "opencv2/cudaarithm.hpp"
      • cv::cuda::split

generalized_hough.cpp

  • コマンドライン引数に追加
    • --gpu=1
    • --votesThreshold=200
  • 汎用化ハフ変換を使用して任意のオブジェクトを検索する
    • #include "opencv2/cudaimgproc.hpp"
      • cv::cuda::createGeneralizedHoughBallard
      • cv::cuda::createGeneralizedHoughGuil
    • E:/Program/OpenCV/build/samples/data/templ.png
      • 以下にコピー
        • E:/Program/OpenCV/build/samples/gpu

hog.cpp

  • コマンドライン引数に追加
    • --video ../data/vtest.avi
  • 動体検知
    • #include "opencv2/cudaobjdetect.hpp"
      • cv::cuda::HOG

houghlines.cpp

  • エッジ検出
    • #include "opencv2/imgproc.hpp"
      • cv::Canny
  • ハフ変換を使用したライン検出
    • #include "opencv2/cudaimgproc.hpp"
      • cv::cuda::createHoughSegmentDetector

morphology.cpp

  • 画像の膨張・収縮によるノイズ除去
    • #include "opencv2/cudafilters.hpp"
      • cv::cuda::createMorphologyFilter

multi.cpp

  • マルチCUDAデバイス
    • 環境なし

pyrlk_optical_flow.cpp

  • コマンドライン引数に追加
    • --left=../data/basketball1.png
    • --right=../data/basketball2.png
  • 特徴点検出
    • #include
      • cv::cuda::createGoodFeaturesToTrackDetector
  • Lucas-Kanade法を用いたフレーム間の動体移動量
    • #include
      • cv::cuda::SparsePyrLKOpticalFlow
      • cv::cuda::DensePyrLKOpticalFlow

stereo_match.cpp

  • コマンドライン引数に追加
    • --left ../data/aloeL.jpg
    • --right ../data/aloeR.jpg
    • --ndisp 120
  • 視差画像を用いた奥行き推定
    • #include "opencv2/cudastereo.hpp"
      • cv::cuda::StereoBM
      • cv::cuda::StereoBeliefPropagation
      • cv::cuda::StereoConstantSpaceBP

stereo_multi.cpp

  • コマンドライン引数に追加
    • ../data/aloeL.jpg ../data/aloeR.jpg
  • マルチCUDAデバイス
    • 環境なし

super_resolution.cpp

  • コマンドライン引数に追加
    • --video=../data/vtest.avi
    • --output=../data/vout.avi
    • --gpu=cuda
  • 入力信号の解像度を高めて出力信号を作る
    • #include "opencv2/superres/optical_flow.hpp"
      • cv::superres::createOptFlow_Farneback_CUDA
      • cv::superres::createOptFlow_DualTVL1_CUDA
      • cv::superres::createOptFlow_Brox_CUDA
      • cv::superres::createOptFlow_PyrLK_CUDA
    • #include "opencv2/superres.hpp"
      • cv::superres::createSuperResolution_BTVL1_CUDA
      • cv::superres::createFrameSource_Video_CUDA
  • WITH_NVCUVIDで再生成が必要?
    • #ifndef HAVE_NVCUVID

      OpenCV(4.1.1) Error: The function/feature is not implemented (The called functionality is disabled for current build or platform) in throw_no_cuda, file E:/Program/OpenCV/opencv/sources/modules/core/include/opencv2/core/private.cuda.hpp, line 113
      

surf_keypoint_matcher.cpp

  • コマンドライン引数に追加
    • --left ../data/left.jpg
    • --right ../data/right.jpg
  • 二枚の画像の特徴点のマッチング
    • #include "opencv2/cudafeatures2d.hpp"
      • cv::cuda::DescriptorMatcher
  • OPENCV_ENABLE_NONFREEで再生成が必要?
    • #ifndef OPENCV_ENABLE_NONFREE

      OpenCV(4.1.1) Error: The function/feature is not implemented (This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library) in cv::cuda::SURF_CUDA::SURF_CUDA, file E:/Program/OpenCV/opencv_contrib-4.1.1/modules/xfeatures2d/src/surf.cuda.cpp, line 55
      

video_reader.cpp

  • コマンドライン引数に追加
    • ../data/vtest.avi
  • 動画の読み込み
    • #include
      • cv::cudacodec::createVideoReader
  • WITH_NVCUVIDで再生成が必要?
    • #ifndef HAVE_NVCUVID

      OpenCV(4.1.1) Error: The function/feature is not implemented (The called functionality is disabled for current build or platform) in throw_no_cuda, file E:/Program/OpenCV/opencv/sources/modules/core/include/opencv2/core/private.cuda.hpp, line 113
      

video_writer.cpp

  • コマンドライン引数に追加
    • ../data/vtest.avi
  • WITH_NVCUVIDで再生成が必要?
    • #if !defined(HAVE_NVCUVENC) || !defined(_WIN32)

      OpenCV(4.1.1) Error: The function/feature is not implemented (The called functionality is disabled for current build or platform) in throw_no_cuda, file E:/Program/OpenCV/opencv/sources/modules/core/include/opencv2/core/private.cuda.hpp, line 113
      

TODO

  • OPENCV_ENABLE_NONFREE, WITH_NVCUVID を追加して再構築
  • OpenCV4.4.0で再構築
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?