所以使用時必須加入下面的程式碼。
#include <opencv2/nonfree/nonfree.hpp> #pragma comment(lib, "opencv_nonfree247d.lib") #pragma comment(lib, "opencv_nonfree247.lib")
使用前須初始化
cv::initModule_nonfree();
#include <opencv2/nonfree/nonfree.hpp> #pragma comment(lib, "opencv_nonfree247d.lib") #pragma comment(lib, "opencv_nonfree247.lib")
cv::initModule_nonfree();
IplImage *iplImage = cvLoadImage(imageFile, 1); cv::Mat matImage(iplImage);
cv::Mat matImage(cv::Size(width, height), CV_8UC3); IplImage *iplImage = cvCreateImage(cvSize(width, height), 8, 3); iplImage = &matImage.operator IplImage();
glut.h → C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\GL glut.lib → C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib glut32.dll → C:\Windows\SysWOW64
#include <GL/gult.h>
<PropertyGroup> <IncludePath>$(IncludePath);C:\opencv247\build\include</IncludePath> </PropertyGroup> <PropertyGroup> <LibraryPath>$(LibraryPath);C:\opencv247\build\x64\vc11\lib</LibraryPath> </PropertyGroup>
<PropertyGroup> <IncludePath>$(IncludePath);C:\opencv247\build\include</IncludePath> </PropertyGroup> <PropertyGroup> <LibraryPath>$(LibraryPath);C:\opencv247\build\x86\vc11\lib</LibraryPath> </PropertyGroup>
#include <opencv2\opencv.hpp> #ifdef _DEBUG #pragma comment(lib,"opencv_imgproc247d.lib") #pragma comment(lib,"opencv_core247d.lib") #pragma comment(lib,"opencv_highgui247d.lib") #pragma comment(lib,"opencv_calib3d247d.lib") #else #pragma comment(lib,"opencv_imgproc247.lib") #pragma comment(lib,"opencv_core247.lib") #pragma comment(lib,"opencv_highgui247.lib") #pragma comment(lib,"opencv_calib3d247.lib") #endif int main() { cv::Mat img = cv::imread("圖片路徑"); cv::imshow("test", img); cv::waitKey(0); return 0; }