我们如何使用OpenCv和Xcode打开网络摄像头?

huangapple go评论67阅读模式
英文:

How we can open the webcam using OpenCv and Xcode?

问题

我在我的MacBook上安装了OpenCV 4.1.2和Xcode。我的目标是使用OpenCV打开网络摄像头。

我按照这个教程进行了以下步骤(我遵循的教程):

  • 设置头文件搜索路径

  • 设置库文件搜索路径

  • 我将OpenCV框架添加到我的项目层次结构中

如您可以在以下图片中看到的:

我们如何使用OpenCv和Xcode打开网络摄像头?

之后,我编写了以下代码:

#include "../opencv2.framework/Headers/opencv.hpp"
#include "../opencv2.framework/Headers/highgui.hpp"
#include "../opencv2.framework/Headers/core.hpp"
#include "../opencv2.framework/Headers/imgproc.hpp"
#include <stdio.h>

using namespace cv;

int main(){
    VideoCapture cap(0);
    while(true){
        Mat Webcam;
        cap.read(Webcam);
        imshow("video de ma webcam", Webcam);
    }
}

此外,我的项目层次结构如下所示:

我们如何使用OpenCv和Xcode打开网络摄像头?

所以当我运行我的项目时,我遇到了以下类型的错误:

我们如何使用OpenCv和Xcode打开网络摄像头?

您有任何关于这个问题可能来自何处的想法吗?

我尝试纠正这个问题的方法:

  • 我尝试更改库搜索路径和头文件搜索路径的层次结构

  • 卸载并重新安装OpenCV

  • 不直接在项目中使用框架,只使用这行代码:

#include <opencv2/opencv.hpp>
英文:

I installed OpenCV 4.1.2 and Xcode on my MacBook.
My goal is to open the webcam with OpenCV.

The steps I followed I used this tutorial (Tutorial I followed ) :

  • Set Head Search Paths

  • Set library search paths

  • I added the OpenCV framework in the hierarchy of my project

Like you can see on the following picture :
我们如何使用OpenCv和Xcode打开网络摄像头?

After that I coded :

#include &quot;../opencv2.framework/Headers/opencv.hpp&quot;
#include &quot;../opencv2.framework/Headers/highgui.hpp&quot;
#include &quot;../opencv2.framework/Headers/core.hpp&quot;
#include &quot;../opencv2.framework/Headers/imgproc.hpp&quot;
#include &lt;stdio.h&gt;
   
using namespace cv;

int main(){
    VideoCapture cap(0);
    while(true){
        Mat Webcam;
        cap.read(Webcam);
        imshow(&quot;video de ma webcam&quot;, Webcam);
    }

}

Moreover the hierarchy of my project is like that
我们如何使用OpenCv和Xcode打开网络摄像头?

So when I am running my project I have this kind of errors

我们如何使用OpenCv和Xcode打开网络摄像头?

Do you have any idea where this problem might be coming from?

What I tried to correct this problem :

  • I tried to change the hierarchy of the Library Search Paths and Header Search Paths

  • Uninstall and install again OpenCV

  • Don't use directly the framework in the projet, only use this code line :
    #include &lt;opencv2/opencv.hpp&gt;

答案1

得分: 0

请使用这篇文章作为指南;其中包含了pkg-config命令,显示需要添加的库文件(您不必全部添加,但更简单的方法是全部添加)。

英文:

Please use this article as a guideline; it includes the pkg-config command that shows you the library files to be added (you don't have to add all of them, but the easier way out is to add all).

huangapple
  • 本文由 发表于 2020年1月3日 21:39:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/59579605.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定