如何使用c ++在带有opencv 3.0.0的视频中画一条线 [英] how to draw a line in a video with opencv 3.0.0 using c++

查看:228
本文介绍了如何使用c ++在带有opencv 3.0.0的视频中画一条线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有任何源代码,请使用C ++在带有opencv 3.0.0的视频中画线,请告诉我. 亲切地

Please let me know if you have any If you have a source code to draw a line in a video with opencv 3.0.0 using c++ cordially

推荐答案

首先,您应该考虑一个视频,基本上只是一些彼此快速显示的图像.因此,您只需要知道如何在图像上画线以在视频中画线(对每一帧都做同样的事情). cv :: line函数在此处记录: http://docs.opencv.org/3.0-beta/modules/imgproc/doc/drawing_functions.html .

First of all you should consider that a video is basicly just some images displayed quickly after each other. Therefor you only need to know how to draw a line onto an image to draw it in a video (do the same for each frame). The cv::line function is documented here : http://docs.opencv.org/3.0-beta/modules/imgproc/doc/drawing_functions.html.

int main(int argc, char** argv)
{
    // read the camera input
    VideoCapture cap(0);

    if (!cap.isOpened())
        return -1;
    Mat frame;

    /// Create Window
    namedWindow("Result", 1);
    while (true) {

        //grab and retrieve each frames of the video sequentially 
        cap >> frame;
        //draw a line onto the frame
        line(frame, Point(0, frame.rows / 2), Point(frame.cols, frame.rows / 2), Scalar(0), 3);
        //display the result
        imshow("Result", frame);
        //wait some time for the frame to render
        waitKey(30);
    }
    return 0;
}

这将在网络摄像头的视频源上绘制一条水平的黑色3像素粗线.

This will draw a horizontal, black, 3 pixel thick line on the video-feed from your webcam.

这篇关于如何使用c ++在带有opencv 3.0.0的视频中画一条线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆