找到detect.py文件
for *xyxy, conf, cls in reversed(det):
if save_txt: # Write to file
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh
line = (cls, *xywh, conf) if save_conf else (cls, *xywh) # label format
with open(txt_path + '.txt', 'a') as f:
f.write(('%g ' * len(line)).rstrip() % line + '\n')
if save_img or save_crop or view_img: # Add bbox to image
c = int(cls) # integer class
label = None if hide_labels else (names[c] if hide_conf else f'{names[c]} {conf:.2f}')
annotator.box_label(xyxy, label, color=colors(c, True))
if save_crop:
save_one_box(xyxy, imc, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)
进入box_label函数
108-110行是新增的打印坐标,加到101行后
print("zuo shang:(" + str(p1[0]) + "," + str(p1[1]) + "),you shang:(" + str(p2[0]) + "," + str(p1[1]) + ")")
print("zuo xia:(" + str(p1[0]) + "," + str(p2[1]) + "),you xia:(" + str(p2[0]) + "," + str(p2[1]) + ")")
print("center("+str((p2[0]-p1[0])/2+p1[0])+","+str((p2[1]-p1[1])/2+p1[1])+ ")")
结果能打出来