寒假在家闲来无事,(玩游戏之前)写点代码自娱自乐……
惯例先放效果图:
下面就是简单粗暴的代码啦:
#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);
}
}
提前祝新年快乐咯~