如何在opencv视频中添加圆圈/点
How to add a circle/dot to a opencv video?
我有一个带有x和y坐标的逗号分隔值文件。我需要在来自相机的opencv视频上放置一个点/圆圈,并使用逗号分隔值文件中的x y坐标进行跟踪。我有显示相机的代码:
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
VideoCapture cap(0); // open the video camera no. 0
if (!cap.isOpened()) // if not success, exit program
{
cout << "Cannot open the video cam" << endl;
return -1;
}
double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
cout << "Frame size : " << dWidth << " x " << dHeight << endl;
namedWindow("CameraDisplay",CV_WINDOW_AUTOSIZE); //create a window called "CameraDisplay"
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 a frame from video stream" << endl;
break;
}
imshow("CameraDisplay", frame); //show the frame in "CameraDisplay" window
if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
}
return 0;
}
网络摄像头捕获的帧只不过是单个图像。因此,您可以像处理单个图像一样在网络摄像头视频上放置一个圆圈。
以下是在图像上放置圆圈的 openCV 方法:
void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
例如:
circle(frame, Point2i(x-coordinate, y-coordinate), 5, Scalar(0,125,230), 4, 3);
相关文章:
- 如何在Visual Studio中添加OpenCV文件
- 如何将opencv包添加到CMakelists.txt
- OpenCV-如何将vale添加到图像一部分的所有像素
- 在所有程序中,在Visual Studio中添加OpENCV的一般方法是什么?
- QT 创建器:无法添加 OpenCV dll 库 ( "File format not recognized" )
- 当尝试添加OpenCV库时,CMAKE错误
- 套接字不起作用,当添加 opencv libriary
- 当将OPENCV添加到库时,Apple Mach-O Linker(LD)错误组;可能的修复
- 使用Nuget软件包添加与CUDA的OPENCV到Visual Studio程序
- OpenCV 创建 MAT 并添加元素
- 如何在opencv中为图像添加边框,边框颜色必须与图像颜色相同
- 将OpenCV .dll文件添加到NetBeans C QT应用程序
- 在OpenCV图像中添加文本标签
- OpenCV-将变量添加到类成员崩溃程序
- 将2个Mat的内容添加到另一个Mat opencv c++中
- 将opencv库添加到QT创建者并获取错误:链接器命令失败,退出代码为1
- openCV 2.4.7 添加符号时出错:命令行中缺少 DSO
- 如何使用 OpenCV 为图像添加水印
- 如何使用 Eclipse 在 JNI "include"文件夹中添加 openCV 文件
- 调试断言失败!当我在VC++窗口窗体应用程序中添加opencv标头时