Opencv绘制载入等待图

本文介绍了一个使用OpenCV库实现的简单图形程序,该程序在屏幕上动态绘制旋转的圆形,并通过改变圆的位置和大小模拟加载动画效果。此外,程序还通过文本输出的方式展示了加载过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

寒假在家闲来无事,(玩游戏之前)写点代码自娱自乐……


惯例先放效果图:



下面就是简单粗暴的代码啦:


#include <opencv2/highgui/highgui.hpp>  
#include <opencv2/imgproc/imgproc.hpp>  
#include <opencv2/core/core.hpp>  
#include<thread>
#include<iostream>
#define PI 3.1415926
#define R 150
using namespace cv;
using namespace std;

int main() {
	Point center = Point(250, 250);
	int temp = 0;
	while (waitKey(60)!=27) {
		temp++;
		temp = temp % 72;
		float 角度 = temp / 18.0 * PI;
		Mat picture(500, 500, CV_8UC3, Scalar(255, 255, 255));
	//	center = Point(palm[0] + 320, palm[2] + 240);
	//	r = palm[1] / 2;
		center.x = 250+R*sin(角度);
		center.y = 250 - R*cos(角度);
		int r = 20;
		circle(picture, center, r, Scalar(255, 0, 0),-1);

		for (int i = 1; i < 7; i++) {
			角度 = (temp-3*i) / 18.0 * PI;
			r = 20 - i * 2;
			center.x = 250 + R*sin(角度);
			center.y = 250 - R*cos(角度);
			circle(picture, center, r, Scalar(255, 0, 0), -1);
		}
		string 内容 = "Loading...";
		switch ((temp % 36) / 12) {
		case 0:内容 = "Loading."; break;
		case 1:内容 = "Loading.."; break;
		case 2:内容 = "Loading..."; break;
		}
		cv::putText(picture, 内容, cv::Point(180, 250), 3, 1, cvScalar(0, 0, 255));

		imshow("Loading...", picture);
		
	}
}

提前祝新年快乐咯~


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

朱铭德

五毛也是爱٩(●´৺`●)૭

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

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

打赏作者

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

抵扣说明:

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

余额充值