bool tool_class::creatColor(std::string image_p){// 指定图像的宽度和高度int width =640;int height =480;// 创建一个空白图像cv::Mat gradientImage(height, width, CV_8UC3);// 生成渐变色for(int y =0; y < height; y++){for(int x =0; x < width; x++){// 计算RGB颜色值,根据x和y的位置生成渐变色uchar blue =static_cast<uchar>(x *255/ width);uchar green =static_cast<uchar>((x + y)*255/(width + height));uchar red =static_cast<uchar>(y *255/ height);// 设置像素颜色// 三通道:at<Vec3b>(row, col)// 单通道:at<uchar>(row, col)gradientImage.at<cv::Vec3b>(y, x)= cv::Vec3b(blue, green, red);}}// 保存图像为文件(可选)cv::imwrite(image_p.c_str(), gradientImage);// 显示渐变色图像cv::imshow("Gradient Image", gradientImage);// 等待用户按下任意键后关闭窗口cv::waitKey(0);// 关闭窗口cv::destroyAllWindows();returntrue;}
绘制多边形
bool tool_class::drawPolygon(std::string image_p, std::vector<cv::Point> points){cv::Mat ima = cv::imread(image_p.c_str());// 读取图像,替换为你的图片路径 cv::Scalar red = cv::Scalar(0,0,255);// Red color cv::Scalar blue = cv::Scalar(255,0,0);// Red color int thickness =2;// 使用polylines函数给图片绘制多边形cv::polylines(ima, points,true, red, thickness,8,0);// 填充颜色cv::fillPoly(ima, std::vector<std::vector<cv::Point>>{points}, blue,8,0);// 显示图像 cv::imshow("Image with line", ima);// 绘制cv::imwrite(image_p.c_str(), ima);returntrue;}
绘制多线
bool tool_class::drawLines(std::string image_p, std::vector<cv::Point> points){cv::Mat ima = cv::imread(image_p.c_str());// 读取图像,替换为你的图片路径 cv::Scalar red = cv::Scalar(0,0,255);// Red color int thickness =2;// 遍历点列表,绘制线段for(size_t i =0; i < points.size()-1; i++){cv::Point2f start = points[i];cv::Point2f end = points[i +1];cv::line(ima, start, end, red, thickness);}cv::imwrite(image_p.c_str(), ima);returntrue;}
改变像素点颜色
bool tool_class::changeColor(std::string image_p,int width,int height){cv::Mat ima = cv::imread(image_p.c_str());// 读取图像,替换为你的图片路径 cv::Scalar Red = cv::Scalar(0,0,255);// Red color // 改变像素点的颜色ima.at<cv::Vec3b>(height, width)[0]=0;ima.at<cv::Vec3b>(height, width)[1]=0;ima.at<cv::Vec3b>(height, width)[2]=255;// 或者//uchar blue = 0;//uchar green = 0;//uchar red = 255;//ima.at<cv::Vec3b>(height, width) = cv::Vec3b(blue, green, red);cv::imwrite(image_p.c_str(), ima);returntrue;}
编辑器:arduino IDE
主板:arduino uno
传感器:
0.96寸的OLED屏(四脚) 声音模块 土壤温湿度模块 DS18B20温度模块(这里用到防水的) 光敏电阻模块(买成三脚的了只能显示高低&#x…
地区 & IP 库
yudao-spring-boot-starter-biz-ip (opens new window)业务组件,提供地区 & IP 库的封装。
#1. 地区
AreaUtils (opens new window)是地区工具类,可以查询中国的省、市、区县,也可以查询国外的国家。
它的数据来自 …