bounding box的提取

#include <iostream> 
#include <fstream> 
#include <opencv2/opencv.hpp>
#define random(x) (rand()%x)
using namespace std;
using namespace cv;
int main()
{
 string Imagedir = "D:/300-w data/300W1/01_Indoor/indoor_001.png";
 Mat image = imread(Imagedir, -1);    //读取原图 
 
 
 ofstream file_out1;
 ofstream file_out2;
 file_out1.open("D:/300-w data/300W1/stan.txt", std::ios::out | std::ios::app);
 file_out2.open("D:/300-w data/300W1/nois.txt", std::ios::out | std::ios::app);
 char dir[50];
 if (!file_out1.is_open() && !file_out2.is_open())
    return 0;
 for (int j = 1; j < 301; j++)
 { if (j <10){
   sprintf(dir, "%s%d%s", "D:/300-w data/300W1/01_Indoor/indoor_00", j, ".pts");
   
 }
 else if (j >= 10 && j<100 ){
   sprintf(dir, "%s%d%s", "D:/300-w data/300W1/01_Indoor/indoor_0", j, ".pts");
   //cout << dir << endl;
 }
 else if (j>=100){
   sprintf(dir, "%s%d%s", "D:/300-w data/300W1/01_Indoor/indoor_", j, ".pts");
 }
  ifstream input;
  input.open(dir);
  string s;
  for (int k = 0; k < 3; k++) {    //前三行 
   getline(input, s);
   //cout << s << endl;
  }
  vector<Point2f> points;
  Point2f point;
  for (int i = 0; i < 68; i++) {
   input >> point.x >> point.y;
   //cout << point.x << " " << point.y << endl;
  
   points.push_back(point);
  }
  float xmax=0.0, ymax=0.0,xmin=4000.0,ymin=4000.0;
  float xmax_n, ymax_n, xmin_n, ymin_n;
  for (int i = 0; i < 68; i++){
   if (xmax < points[i].x)
    xmax = points[i].x;
  }
  //cout << xmax << endl;
  for (int i = 0; i < 68;i++){
   if (ymax < points[i].y)
    ymax = points[i].y;
  }
  //cout << ymax << endl;
  for (int i = 0; i < 68; i++){
   if (xmin >= points[i].x)
    xmin = points[i].x;
  }
  //cout << xmin << endl;
  for (int i = 0; i < 68; i++){
   //cout << points[i].y << endl;
   if (ymin >= points[i].y)
    ymin = points[i].y;
  }
  //cout << ymin << endl;
  xmax_n = xmax + random(100)-50;
  ymax_n = ymax + random(100)-50;
  xmin_n = xmin + random(100)-50;
  ymin_n = ymin + random(100)-50;
  file_out1 << xmin << " " << ymin<< " " << ymax << " " << ymax << endl;
  file_out2 << xmin_n << " " << ymin_n << " " << xmax_n << " " << ymax_n << endl;
  
 }
 file_out1.close();
 file_out2.close();
 cin.get();
 return 0;
}

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Anchor BoxBounding Box的区别是,Anchor Box是一种被设计用来做目标检测的技术,它是一种已经预定义的框架,用来指导模型检测特定物体的位置;而Bounding Box是一种用来标记边界框的方法,用来提取特定物体的轮廓和位置信息。 ### 回答2: Anchor box(锚定框)和bounding box(边界框)是在目标检测和物体识别中常用的两个概念。 边界框(bounding box)是用于描述和定位目标物体的矩形框,通常由左上角和右下角的坐标表示。边界框可以准确地框住目标物体,以便进行目标检测和识别。 锚定框(anchor box),也称为先验框(prior box),是一组预定义的边界框,具有不同的尺寸和宽高比。锚定框通常是在输入图像中以相对位置进行均匀分布的。目标检测算法会根据锚定框对感兴趣的区域进行候选框的生成,然后判断这些候选框是否包含目标物体。 边界框和锚定框的区别在于它们的作用和使用方式。边界框用于描述目标物体的精确位置和边界,而锚定框用于生成检测器的候选框。边界框用于标注目标物体的位置,然后通过边界框的坐标信息进行目标定位和识别。而锚定框则在目标检测算法中作为一种基于先验知识的辅助工具,用于生成候选框,然后通过分类和回归等技术对候选框进行进一步的处理和筛选。 总而言之,边界框用于描述目标位置和形状,而锚定框用于生成候选框并辅助目标检测算法进行目标识别。 ### 回答3: anchor boxbounding box是在目标检测模型中常用的概念,用于定位和识别图像中的目标物体。 首先,bounding box是一个由四个坐标值(通常是左上角和右下角的坐标)定义的矩形框,用于标记图像中目标物体的位置和大小。bounding box可以围住目标物体,使得模型可以定位和识别目标。 而anchor box(也称为prior box)是在目标检测模型中使用的一组预定义的固定大小和宽高比的矩形框。这些anchor box通常是在训练模型之前通过聚类等方式选择得到的。目标检测模型使用这些anchor box作为候选框,通过对这些anchor box进行调整和分类,来实现对物体的定位和识别。 anchor boxbounding box的区别主要在于用途和性质上。bounding box是用于表示真实目标物体的位置和大小的框,而anchor box是一组预定义框,用于通过模型的候选框生成机制选取候选框。bounding box一般是根据真实目标物体标注得到的,而anchor box则是通过聚类等方式选择得到的。另外,bounding box是根据实际物体进行调整得到的,而anchor box则是通过在图像上定位和尺度空间的规定选择得到的。 在目标检测模型的训练中,通常会使用anchor box来生成候选框,然后通过和真实目标物体的bounding box比较,计算损失函数进行优化。这样模型可以通过学习来调整和预测出更好的bounding box来定位和识别目标物体。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值