opnecv4.pc 丢失文件和 gocv

opnecv4.pc 丢失文件和 gocv

我正在尝试使此代码正常工作:

package main

import (
    "gocv.io/x/gocv"
)

func main() {
    webcam, _ := gocv.VideoCaptureDevice(0)
    window := gocv.NewWindow("Hello")
    img := gocv.NewMat()

    for {
        webcam.Read(&img)
        window.IMShow(img)
        window.WaitKey(1)
    }
}

它来自https://gocv.io/writing-code/hello-video/。我已经在 Ubuntu 18 电脑上安装了 opencv。当我运行代码时,我得到:

# pkg-config --cflags  -- opencv4
Package opencv4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv4' found
pkg-config: exit status 1

opencv 安装过程中未生成 opencv4.pc 文件。当我从 opencv.pc 创建 opencv4.pc 的符号链接时,出现错误:

# gocv.io/x/gocv
features2d.cpp: In function ‘cv::Ptr<cv::FastFeatureDetector>* FastFeatureDetector_CreateWithParams(int, bool, int)’:
features2d.cpp:219:146: error: ‘DetectorType’ in ‘class cv::FastFeatureDetector’ does not name a type
     return new cv::Ptr<cv::FastFeatureDetector>(cv::FastFeatureDetector::create(threshold,nonmaxSuppression,static_cast<cv::FastFeatureDetector::DetectorType>(type)));
                                                                                                                                                  ^~~~~~~~~~~~
features2d.cpp: In function ‘void DrawKeyPoints(Mat, KeyPoints, Mat, Scalar, int)’:
features2d.cpp:429:93: error: no matching function for call to ‘cv::DrawMatchesFlags::DrawMatchesFlags(int&)’
         cv::drawKeypoints(*src, keypts, *dst, color, static_cast<cv::DrawMatchesFlags>(flags));
                                                                                             ^
In file included from /usr/local/include/opencv2/calib3d.hpp:48:0,
                 from /usr/local/include/opencv2/opencv.hpp:56,
                 from features2d.h:5,
                 from features2d.cpp:1:
/usr/local/include/opencv2/features2d.hpp:1178:19: note: candidate: constexpr cv::DrawMatchesFlags::DrawMatchesFlags()
 struct CV_EXPORTS DrawMatchesFlags
                   ^~~~~~~~~~~~~~~~
/usr/local/include/opencv2/features2d.hpp:1178:19: note:   candidate expects 0 arguments, 1 provided
/usr/local/include/opencv2/features2d.hpp:1178:19: note: candidate: constexpr cv::DrawMatchesFlags::DrawMatchesFlags(const cv::DrawMatchesFlags&)
/usr/local/include/opencv2/features2d.hpp:1178:19: note:   no known conversion for argument 1 from ‘int’ to ‘const cv::DrawMatchesFlags&’
/usr/local/include/opencv2/features2d.hpp:1178:19: note: candidate: constexpr cv::DrawMatchesFlags::DrawMatchesFlags(cv::DrawMatchesFlags&&)
/usr/local/include/opencv2/features2d.hpp:1178:19: note:   no known conversion for argument 1 from ‘int’ to ‘cv::DrawMatchesFlags&&’

需要帮助吗?我该如何做才能成功...

相关内容