Skip to content

Instantly share code, notes, and snippets.

@sachadee
Last active May 10, 2025 17:57
Show Gist options
  • Save sachadee/b85d5d064b53ac0249fc76ff9ca68c4b to your computer and use it in GitHub Desktop.
Save sachadee/b85d5d064b53ac0249fc76ff9ca68c4b to your computer and use it in GitHub Desktop.
ONNX PaddleOCR inference code
import os
import cv2
import numpy as np
from util import detectionclass as net
detection = net.Detection('./weights/detection.onnx')
def main():
frame = cv2.imread('./images/plate.jpg')
image = frame.copy()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
points = detection(frame)
points = net.sort_polygon(list(points))
# draw detected polygon
for point in points:
point = np.array(point, dtype=np.int32)
cv2.polylines(image,
[point], True,
(0, 255, 0), 2)
cv2.imshow('Detection',image)
cv2.waitKey(0)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment