opencv 学习笔记二 直线、矩形、圆形绘制


#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <stdio.h>

using namespace cv;
using namespace std;


RNG rng(12345);
Scalar color[7] = {
    (Scalar(0,0,255)),//红色
    (Scalar(0,255,0)),//绿色
    (Scalar(255,0,0)),//蓝色
    (Scalar(255,255,0)),//浅蓝色
    (Scalar(255,0,255)),//紫色
    (Scalar(0,255,255)),//黄色
    (Scalar(128,128,192)),//浅粉色
};
int main()
{
    Mat image,img_line,img_rect,img_circle;

    image = imread("../test.jpg", 1);
    if (image.empty()) {
        cout << "无此图片" << endl;
        return 0;
    }

    img_line = image.clone();
    img_rect = image.clone();
    img_circle = image.clone();

    while (1) 
    {
        imshow("原图", image);
        waitKey(1);

        //直线绘制
        line(img_line, Point(100, 100), Point(150, 150), Scalar(0, 0, 255), 3, 8, 0);
        line(img_line, Point(200, 200), Point(350, 350), Scalar(0, 0, 255), 3, 8, 0);
        imshow("直线绘制", img_line);
        waitKey(1);


        //矩形绘制
        rectangle(img_rect, Rect(300, 300, 100, 200), Scalar(0, 255, 255), 3, 8, 0);
        imshow("矩形绘制", img_rect);
        waitKey(1);

        //圆形绘制
        circle(img_circle, Point(200, 200), 50, Scalar(255, 0, 255), 3, 8, 0);
        imshow("圆形绘制", img_circle);
        waitKey(1);
    }
    return 1;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

逐梦者-未来

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值