一、无滑动条模板
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
#define W_SRC "srcImage"
#define W_DST "dstImage"
Mat g_srcImage;
Mat g_dstImage;
int main()
{
g_srcImage=imread(".jpg");
namedWindow(,WINDOW_NORMAL);
imshow(,g_dstImage);
waitKey();
return 0;
}
二、滑动条模板
#include<opencv2/opencv.hpp>
using namespace cv;
#define W_SRC "srcImage"
#define W_DST "dstImage"
#define T_DST "size"
Mat g_srcImage;
Mat g_dstImage;
int g_dstImageValue=;
const int g_dstImageValueMax=;
void onChange(int,void*)
{
imshow(W_DST,g_dstImage);
}
int main()
{
g_srcImage=imread("t.jpg");
namedWindow(W_DST,WINDOW_NORMAL);
createTrackbar(T_DST,W_DST,&g_dstImageValue,g_dstImageValueMax,onChange);
onChange(0,0);
waitKey();
return 0;
}
三、视频打开
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat image;
VideoCapture capture;
capture.open(0);
if(capture.isOpened())
{
cout << "Capture is opened" << endl;
for(;;)
{
capture >> image;
if(image.empty())
break;
imshow("Sample", image);
if(waitKey(10) >= 0)
break;
}
}
else
{
cout << "No capture" << endl;
waitKey(0);
}
return 0;
}