mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-11-02 19:13:13 +00:00
fix: make cv2 dependency optional (#1234)
Makes CV2 dependency optional. It's not used in any of the functional code.
This commit is contained in:
parent
5052e6cb3b
commit
dde3eb058b
@ -11,6 +11,7 @@
|
||||
|
||||
### Fixes
|
||||
|
||||
* Make cv2 dependency optional
|
||||
* Edit `add_pytesseract_bbox_to_elements`'s (`ocr_only` strategy) `metadata.coordinates.points` return type to `Tuple` for consistency.
|
||||
* Re-enable test-ingest-confluence-diff for ingest tests
|
||||
* Fix syntax for ingest test check number of files
|
||||
|
||||
@ -1 +1 @@
|
||||
__version__ = "0.10.9-dev3"
|
||||
__version__ = "0.10.9-dev3" # pragma: no cover
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
from typing import List
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from unstructured.utils import requires_dependencies
|
||||
|
||||
"""
|
||||
|
||||
This module contains the implementation of the XY-Cut sorting approach
|
||||
@ -157,7 +158,10 @@ def bbox2points(bbox):
|
||||
return [left, top, right, top, right, bottom, left, bottom]
|
||||
|
||||
|
||||
@requires_dependencies("cv2")
|
||||
def vis_polygon(img, points, thickness=2, color=None):
|
||||
import cv2
|
||||
|
||||
br2bl_color = color
|
||||
tl2tr_color = color
|
||||
tr2br_color = color
|
||||
@ -196,6 +200,7 @@ def vis_polygon(img, points, thickness=2, color=None):
|
||||
return img
|
||||
|
||||
|
||||
@requires_dependencies("cv2")
|
||||
def vis_points(
|
||||
img: np.ndarray,
|
||||
points,
|
||||
@ -206,13 +211,15 @@ def vis_points(
|
||||
|
||||
Args:
|
||||
img:
|
||||
points: [N, 8] 8: x1,y1,x2,y2,x3,y3,x3,y4
|
||||
points: [N, 8] 8: x1,y1,x2,y2,x3,y3,x4,y4
|
||||
texts:
|
||||
color:
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
import cv2
|
||||
|
||||
points = np.array(points)
|
||||
assert len(texts) == points.shape[0]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user