fix formatting issues
This commit is contained in:
parent
8e1a62651d
commit
5867b339f4
|
@ -9,12 +9,16 @@ using namespace cv;
|
||||||
//extract name
|
//extract name
|
||||||
std::string GetImageFileName(const std::string& imagePath) {
|
std::string GetImageFileName(const std::string& imagePath) {
|
||||||
size_t lastSlash = imagePath.find_last_of("/\\");
|
size_t lastSlash = imagePath.find_last_of("/\\");
|
||||||
if (lastSlash == std::string::npos) {
|
if (lastSlash == std::string::npos)
|
||||||
|
{
|
||||||
return imagePath;
|
return imagePath;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::string fileName = imagePath.substr(lastSlash + 1);
|
std::string fileName = imagePath.substr(lastSlash + 1);
|
||||||
size_t lastDot = fileName.find_last_of(".");
|
size_t lastDot = fileName.find_last_of(".");
|
||||||
if (lastDot != std::string::npos) {
|
if (lastDot != std::string::npos)
|
||||||
|
{
|
||||||
return fileName.substr(0, lastDot);
|
return fileName.substr(0, lastDot);
|
||||||
}
|
}
|
||||||
return fileName;
|
return fileName;
|
||||||
|
@ -60,8 +64,8 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < val_image.size(); i++) {
|
for (int i = 0; i < val_image.size(); i++)
|
||||||
|
{
|
||||||
//create pred file
|
//create pred file
|
||||||
std::string val_image_name = GetImageFileName(val_image[i]);
|
std::string val_image_name = GetImageFileName(val_image[i]);
|
||||||
std::string filename = folder+"/"+ val_image_name + ".txt";
|
std::string filename = folder+"/"+ val_image_name + ".txt";
|
||||||
|
@ -86,7 +90,8 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
sv::Box b;
|
sv::Box b;
|
||||||
tgts.targets[j].getBox(b);
|
tgts.targets[j].getBox(b);
|
||||||
file<<tgts.targets[j].category_id<<" "<<(float)(b.x1+b.x2)/(2*cols)<<" "<<(float)(b.y1+b.y2)/(2*rows)<<" "<<(float)(b.x2-b.x1)/cols<<" "<<(float)(b.y2-b.y1)/rows<<" "<<(float)tgts.targets[j].score<<"\n";
|
file << tgts.targets[j].category_id << " " << (float)(b.x1+b.x2) / (2*cols) << " " << (float)(b.y1+b.y2) / (2*rows) << \
|
||||||
|
" " << (float)(b.x2-b.x1) / cols << " " << (float)(b.y2-b.y1) / rows << " " << (float)tgts.targets[j].score << "\n";
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,8 @@ for image in images:
|
||||||
'image_id': int(image_name),
|
'image_id': int(image_name),
|
||||||
'category_id': int(category_id),
|
'category_id': int(category_id),
|
||||||
'bbox': [xmin, ymin, w, h],
|
'bbox': [xmin, ymin, w, h],
|
||||||
'score': float(pred[5])})
|
'score': float(pred[5])
|
||||||
|
})
|
||||||
|
|
||||||
# save json
|
# save json
|
||||||
with open(os.path.join(coco_json_save), 'w') as f:
|
with open(os.path.join(coco_json_save), 'w') as f:
|
||||||
|
|
Loading…
Reference in New Issue