"无法找到DLL"当使用opencv从相机捕获视频时

时间:2014-12-01 08:50:27

标签: c++ opencv dll

我在互联网上应用了安装opencv 2.9的教程,但我得到了

Unhandled exception at 0x00007FFC6470C0B4 (ntdll.dll) in Project11.exe: 
0xC0000135: Unable to Locate DLL.

我尝试了下面的代码,但一直无法解决。

#include "stdafx.h"
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <stdio.h>
#include "opencv.hpp"

int main(){
    CvCapture *camera=cvCaptureFromFile("rtsp://192.168.1.19:554/0/1:1/main");
    if (camera==NULL)
    printf("camera is null\n"); 
    else
    printf("camera is not null");

    cvNamedWindow("img");
    while (cvWaitKey(10)!=atoi("q")){
            IplImage *img=cvQueryFrame(camera);
            cvShowImage("img",img);
    }
    cvReleaseCapture(&camera);
}

2 个答案:

答案 0 :(得分:0)

如错误消息所述,Windows无法找到所需的DLL。 此错误很可能是由于缺少OpenCV DLL引起的; 必须放置

  • System32目录中(通常为C:\Windows\System 32
  • 与可执行文件相同的目录
  • 附加到您系统的PATH环境变量

有关正确安装OpenCV库的详细信息,请参阅OpenCV Installation on Windows页面。

您尝试使用OpenCV库源代码中的单个文件。虽然这可行,但这是不可取的。

TL:DR; 您必须找到opencv_core[version number here]并将其放在我上面提到的其中一个位置。

答案 1 :(得分:-2)

你应该复制dll文件(C:\ opencv \ build \ x64 \ vc11 \ bin)在你的System32目录中(通常是C:\ Windows \ System 32)