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

Function decode_image

scripts/ocr_triditional.py:34–46  ·  view source on GitHub ↗

Decode the image from the given path.

(image_path)

Source from the content-addressed store, hash-verified

32# ----------------------- Function Definitions -----------------------
33
34def decode_image(image_path):
35 """
36 Decode the image from the given path.
37 """
38 if isinstance(image_path, str):
39 image = Image.open(image_path).convert('RGB')
40 elif isinstance(image_path, Image.Image):
41 image =image_path
42 else:
43 raise ValueError("Invalid image path or image object.")
44 image = np.array(image)
45 image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
46 return image
47
48def calculate_spaces_and_newlines(current_box, previous_box, space_threshold=45, line_threshold=15):
49 """Calculate the number of spaces and newlines between two text boxes."""

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected