【发布时间】:2015-09-11 00:23:34
【问题描述】:
我试图在我的网络摄像头的视频中画一个圆圈我使用这个功能
cv::circle(cap,points(1,0),3,cv::Scalar(255,255,255),-1);
我在文档中找到它,但我不知道为什么它不起作用我多次编辑我的代码,但它仍然给出我的错误,这是我使用 opencv3 的完整代码
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>
#include <iostream>
#include <sstream>
#include <opencv2/video/background_segm.hpp>
#include <opencv2/video/background_segm.hpp>
using namespace cv;
using namespace std;
int main()
{
VideoCapture cap(0); // open the video file for reading
if ( !cap.isOpened() ) // if not success, exit program
{
cout << "Cannot open the video file" << endl;
return -1;
}
//cap.set(CV_CAP_PROP_POS_MSEC, 300); //start the video at 300ms
double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
cout << "Frame per seconds : " << fps << endl;
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
while(1)
{
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read the frame from video file" << endl;
break;
}
imshow("MyVideo", frame); //show the frame in "MyVideo" window
cv::circle(cap,points(1,0),3,cv::Scalar(255,255,255),-1);
if(waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
}
return 0;
}
【问题讨论】:
-
在框架上画圆圈(而不是帽子),然后将 imshow 移动到圆圈之后
标签: c++ opencv video opencv3.0