visual studio中配置opencv


第1步附加包含目錄:H:\software\programming\opencv\opencv\build\include

第2步附加庫目錄:H:\software\programming\opencv\opencv\build\x64\vc15\lib

第3步附加依賴項:opencv_world410.lib  release模式 。其中opencv_world410d.lib是debug模式

報錯找不到opencv_world410.dll 添加環境變量H:\software\programming\opencv\opencv\build\x64\vc15\bin

還報錯重啟visual studio。成功顯示ly.jpg

代碼如下:

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
String filename = "ly.jpg";
Mat image;
image = imread(filename, IMREAD_COLOR); // Read the file
if (image.empty()) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}
namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}

4這個位置是項目的目錄,圖片要放在這里


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM