MCPcopy Create free account
hub / github.com/FeiYull/TensorRT-Alpha / img_pred_thread

Function img_pred_thread

examples/python_with_dll/python_trt.py:61–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59
60
61 def img_pred_thread():
62
63 global frame
64 global source_w
65 global source_h
66 det = Detector(dll_path="./python_dll.dll", trt_path="./yolov8n.trt", window_width=source_w,
67 window_height=source_h)
68 clock = Clock()
69
70 windows_title = "cvwindow"
71 cv2.namedWindow(windows_title, cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # allow window resize (Linux)
72
73 max_w = 576
74 max_h = 324
75 if source_h > max_h or source_w > max_w:
76 cv2.resizeWindow(windows_title, max_w, source_h * max_w // source_w)
77
78 while True:
79 aims = det.predict(frame)
80 for aim in aims:
81 cv2.rectangle(frame, (int(aim[0]), int(aim[1])), (int(aim[2]), int(aim[3])), (0, 255, 0), 2)
82 det_info = class_names[int(aim[4])] + " " + str(aim[5])
83 cv2.putText(frame, det_info, (int(aim[0]), int(aim[1])), cv2.FONT_HERSHEY_DUPLEX, 0.6, (255, 0, 255), 1,
84 cv2.LINE_AA)
85
86 cv2.putText(frame, "FPS:{:.1f}".format(clock.get_fps()), (10, 50), cv2.FONT_HERSHEY_SIMPLEX,
87 2, (0, 0, 235), 4)
88 cv2.imshow('cvwindow', frame)
89 cv2.waitKey(1)
90
91 clock.tick(200)
92
93
94 # 4:3 800x600 center region detect

Callers

nothing calls this directly

Calls 2

predictMethod · 0.95
DetectorClass · 0.85

Tested by

no test coverage detected