解决->错误ox80070091:目录不是空的

打开cmd,输入chkdsk /F N:
N为修复的盘符.

#include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; struct point { double x, y; }; class ROI { private: double width; // 设为private避免负值 double height; // 同上 string color; protected: point center; // 便于扩展子类 public: ROI(double w, double h, point c, string clr) : width(w > 0 ? w : 0), height(h > 0 ? h : 0), center(c), color(clr) {} vector<point> getVertices(); void setColor(string newColor); static double nroi(const ROI& a, const ROI& b); }; // 获取四个顶点坐标 vector<point> ROI::getVertices() { double hw = width / 2, hh = height / 2; return { {center.x - hw, center.y - hh}, {center.x + hw, center.y - hh}, {center.x + hw, center.y + hh}, {center.x - hw, center.y + hh} }; } // 计算两个ROI的相交面积 double ROI::nroi(const ROI& a, const ROI& b) { // 计算x轴方向重叠 double left = max(a.center.x - a.width / 2, b.center.x - b.width / 2); double right = min(a.center.x + a.width / 2, b.center.x + b.width / 2); double ox = right > left ? right - left : 0; // 计算y轴方向重叠 double bottom = max(a.center.y - a.height / 2, b.center.y - b.height / 2); double top = min(a.center.y + a.height / 2, b.center.y + b.height / 2); double oy = top > bottom ? top - bottom : 0; return ox * oy; } // 修改颜色标签 void ROI::setColor(string newcolor) { if (newcolor.empty()) { color = newcolor; } } int main() { vector<ROI> sroi; // 创建测试代码对象 sroi.emplace_back(4, 6, point{ 2,3 }, "red"); sroi.emplace_back(3, 3, point{ 3,4 }, "red"); sroi.emplace_back(5, 5, point{ 4,5 }, "blue"); // 测试代码顶点获取 auto vertices = sroi[0].getVertices(); cout << "第一个顶点坐标:"; for (auto& p : vertices) cout << "(" << p.x << "," << p.y << ") "; // 测试相交面积 double area = ROI::nroi(sroi[1], sroi[2]); cout << "\n相交面积:" << area << endl; // 统计红色ROI总面积 double totalRed = 0; for (auto& s : sroi) { if (s.getcolor() == "red") { totalRed += s.getarea(); // 需添加getArea()方法 } } cout << "红色ROI总面积:" << totalRed << endl; // 修改颜色测试 sroi[1].setColor("green"); cout << "修改后颜色:" << sroi[1].getcolor(); return 0; }类ROI里没有getcolor,请修改代码,且不用getarea直接算
最新发布
03-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值