MCPcopy Create free account
hub / github.com/Alibaba-NLP/ViDoRAG / draw_boxes

Function draw_boxes

scripts/ocr_vlms.py:38–48  ·  view source on GitHub ↗
(img_path, boxes)

Source from the content-addressed store, hash-verified

36
37
38def draw_boxes(img_path, boxes):
39 # boxes: [[y_min, x_min, y_max, x_max], ...]
40 img = cv2.imread(img_path)
41 # x_len,y len
42 x_len,y_len = img.shape[1], img.shape[0]
43 for box in boxes:
44 cv2.rectangle(img, (int(box[1] * x_len / 1000), int(box[0] * y_len / 1000)), (int(box[3] * x_len / 1000), int(box[2] * y_len / 1000)), (0, 255, 0), 2)
45 # save the image
46 save_path = img_path.replace('img', 'img_with_boxes_vlmocr')
47 os.makedirs(os.path.dirname(save_path), exist_ok=True)
48 cv2.imwrite(save_path, img)
49
50def ocr(img_path):
51 while True:

Callers 1

ocrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected