<bdo id='0dBAx'></bdo><ul id='0dBAx'></ul>

    <small id='0dBAx'></small><noframes id='0dBAx'>

    1. <tfoot id='0dBAx'></tfoot>
        <i id='0dBAx'><tr id='0dBAx'><dt id='0dBAx'><q id='0dBAx'><span id='0dBAx'><b id='0dBAx'><form id='0dBAx'><ins id='0dBAx'></ins><ul id='0dBAx'></ul><sub id='0dBAx'></sub></form><legend id='0dBAx'></legend><bdo id='0dBAx'><pre id='0dBAx'><center id='0dBAx'></center></pre></bdo></b><th id='0dBAx'></th></span></q></dt></tr></i><div id='0dBAx'><tfoot id='0dBAx'></tfoot><dl id='0dBAx'><fieldset id='0dBAx'></fieldset></dl></div>

        <legend id='0dBAx'><style id='0dBAx'><dir id='0dBAx'><q id='0dBAx'></q></dir></style></legend>
      1. 使用 OpenCV (C++) 在 Xcode 中访问网络摄像头

        时间:2023-10-17

        <tfoot id='3lwP1'></tfoot>
        <legend id='3lwP1'><style id='3lwP1'><dir id='3lwP1'><q id='3lwP1'></q></dir></style></legend>

          1. <i id='3lwP1'><tr id='3lwP1'><dt id='3lwP1'><q id='3lwP1'><span id='3lwP1'><b id='3lwP1'><form id='3lwP1'><ins id='3lwP1'></ins><ul id='3lwP1'></ul><sub id='3lwP1'></sub></form><legend id='3lwP1'></legend><bdo id='3lwP1'><pre id='3lwP1'><center id='3lwP1'></center></pre></bdo></b><th id='3lwP1'></th></span></q></dt></tr></i><div id='3lwP1'><tfoot id='3lwP1'></tfoot><dl id='3lwP1'><fieldset id='3lwP1'></fieldset></dl></div>
              • <bdo id='3lwP1'></bdo><ul id='3lwP1'></ul>

                <small id='3lwP1'></small><noframes id='3lwP1'>

                    <tbody id='3lwP1'></tbody>

                  本文介绍了使用 OpenCV (C++) 在 Xcode 中访问网络摄像头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试打开网络摄像头并使用 OpenCV 显示一个简短的捕获.我目前正在 Xcode 上工作,使用 C++ 语言.

                  I am trying to open the webcam and display a short capture with OpenCV. I am currently working on Xcode, with C++ language.

                  代码非常简单:

                  #include <iostream>
                  #include <opencv2/opencv.hpp>
                  
                  using namespace std;
                  using namespace cv;
                  
                  int main(int argc, const char * argv[]) {
                  
                      // variable initialization
                      Mat frame;
                      VideoCapture cap;            // 0 is the webcam
                  
                      // try to open camera
                      cap.open(0);
                      if (!cap.isOpened()) return -1;  // check if there is no video or no way to display it
                  
                      // create a window and display the video capture
                      namedWindow("Video Capture", CV_WINDOW_AUTOSIZE);
                      for (int i=0; i<100; i++) {
                          cap >> frame;
                          imshow("Video Capture", frame);
                          waitKey(1);
                      }
                  
                      return 0;
                  }
                  

                  当我运行代码时,返回以下错误:

                  As I run the code the following error is returned:

                  [access] This app has crashed because it attempted to access privacy-sensitive 
                  data without a usage description.  The app's Info.plist must contain an 
                  NSCameraUsageDescription key with a string value explaining to the 
                  user how the app uses this data.
                  

                  因此,我在项目中添加了一个 Info.plist 文件(当前在 main.cpp 所在的目录中)并添加了编译器建议的描述:

                  Thus, I added an Info.plist file to the project (currently in the same directory where the main.cpp is) and added the description the compiler suggested:

                  Key: Privacy - Camera Usage Description
                  Value: $(PRODUCT_NAME) camera use
                  

                  然后,在项目的构建设置中,我使用完整路径引用了我刚刚编写的文件,如下图所示:

                  Then, in the project's Build Settings I referenced the file I had just written, by using the full path, as you can see in the following image:

                  我确定路径是正确的,因为我拖放了文件本身,但编译器一直显示相同的错误并退出执行.

                  I am sure that the path is correct, as I drag and dropped the file itself, but the compiler keeps on showing the same error and quits the execution.

                  推荐答案

                  我最后找到了解决方案;这些是我遵循的步骤:

                  I found a solution in the end; these are the steps that I followed:

                  • 在项目导航器(Xcode IDE 的左侧)中右键单击项目 -> 新建文件 -> 属性文件
                  • 调用文件Info.plist"并将其保存在 main.cpp 所在的目录中(它也应该在上层目录中工作,但这对我有用)如图所示以下:
                  • 选择 Info.plist 文件并根据上述问题中的说明进行编辑.
                  • 现在我们需要将 Info.plist 链接到项目,因此在 Project Navigator 中左键单击该项目,选择选项卡 General,然后在左侧窗格(项目和目标列表")上单击目标"部分.您应该能够看到一个按钮,上面写着选择 Info.plist 文件",见下图:

                  因为我注意到该程序尚未直接从 Xcode IDE 启动,但我能够(在 Finder 中)导航到可执行文件所在的目录并使用终端运行该程序,所以我复制粘贴了按照此处的建议将Info.plist 放入该文件夹中

                  As I noticed that the program did not start yet from the Xcode IDE directly, but I was able to navigate (in Finder) to the directory where the executable was and run the program by using the Terminal, I copy-pasted the Info.plist into that folder, as suggested here

                  这篇关于使用 OpenCV (C++) 在 Xcode 中访问网络摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Windows 上删除 C++ 中的权限 下一篇:C++ 如何通过 win32 api 检索文件权限和所有权

                  相关文章

                  <tfoot id='HuaRX'></tfoot>
                  • <bdo id='HuaRX'></bdo><ul id='HuaRX'></ul>
                  <i id='HuaRX'><tr id='HuaRX'><dt id='HuaRX'><q id='HuaRX'><span id='HuaRX'><b id='HuaRX'><form id='HuaRX'><ins id='HuaRX'></ins><ul id='HuaRX'></ul><sub id='HuaRX'></sub></form><legend id='HuaRX'></legend><bdo id='HuaRX'><pre id='HuaRX'><center id='HuaRX'></center></pre></bdo></b><th id='HuaRX'></th></span></q></dt></tr></i><div id='HuaRX'><tfoot id='HuaRX'></tfoot><dl id='HuaRX'><fieldset id='HuaRX'></fieldset></dl></div>
                  <legend id='HuaRX'><style id='HuaRX'><dir id='HuaRX'><q id='HuaRX'></q></dir></style></legend>

                      <small id='HuaRX'></small><noframes id='HuaRX'>