英文:
How we can open the webcam using OpenCv and Xcode?
问题
我在我的MacBook上安装了OpenCV 4.1.2和Xcode。我的目标是使用OpenCV打开网络摄像头。
我按照这个教程进行了以下步骤(我遵循的教程):
-
设置头文件搜索路径
-
设置库文件搜索路径
-
我将OpenCV框架添加到我的项目层次结构中
如您可以在以下图片中看到的:
之后,我编写了以下代码:
#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
-
不直接在项目中使用框架,只使用这行代码:
#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 :
After that I coded :
#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);
}
}
Moreover the hierarchy of my project is like that
So when I am running my project I have this kind of errors
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 <opencv2/opencv.hpp>
答案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).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论