Add pyclipper to support RapidOCR #6685
-
|
Add pyclipper to support RapidOCR |
Beta Was this translation helpful? Give feedback.
Answered by
ndonkoHenri
Jul 15, 2026
Replies: 1 comment 1 reply
-
|
Add it to your app's dependencies: dependencies = [
"flet",
"pyclipper",
]Example: import flet as ft
import flet.canvas as cv
import pyclipper
def main(page: ft.Page):
page.title = "pyclipper demo"
subj = [[80, 40], [220, 40], [220, 160], [80, 160]] # blue square
clip = [[150, 10], [270, 10], [270, 130], [150, 130]] # green square
pc = pyclipper.Pyclipper()
pc.AddPath(clip, pyclipper.PT_CLIP, True)
pc.AddPath(subj, pyclipper.PT_SUBJECT, True)
result = pc.Execute(pyclipper.CT_INTERSECTION)[0] # red overlap
def edges(poly, color, w):
ring = poly + [poly[0]] # close the loop
return [
cv.Line(
x1=a[0],
y1=a[1],
x2=b[0],
y2=b[1],
paint=ft.Paint(color=color, stroke_width=w),
)
for a, b in zip(ring, ring[1:])
]
page.add(
ft.Text("blue ∩ green = red — computed by pyclipper on-device"),
cv.Canvas(
shapes=edges(subj, ft.Colors.BLUE, 2)
+ edges(clip, ft.Colors.GREEN, 2)
+ edges(result, ft.Colors.RED, 4),
width=300,
height=200,
),
)
ft.run(main)Good to know:
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ndonkoHenri
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

pyclipper1.4.0 is now supported on iOS and Android: https://pypi.flet.dev/pyclipperAdd it to your app's dependencies:
Example: