-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
30 lines (22 loc) · 879 Bytes
/
Copy pathexample.py
File metadata and controls
30 lines (22 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import cv2
from vzglyad_vision import VisionPredictor
def main():
print("Запуск модуля...")
predictor = VisionPredictor(r"path\to\your\model", device='cpu')
img_path = r"path\to\your\image.png"
import numpy as np
import os
if not os.path.exists(img_path):
print(f"Ошибка: Файл не найден по пути: {img_path}")
return
img_array = np.fromfile(img_path, np.uint8)
img = cv2.imdecode(img_array, cv2.IMREAD_COLOR)
if img is None:
print(f"Ошибка: Не удалось прочитать изображение: {img_path}")
return
results, im0 = predictor.predict(img, conf_thres=0.015)
img_drawn = predictor.draw_results(img, results)
cv2.imshow("Result", img_drawn)
cv2.waitKey(0)
if __name__ == '__main__':
main()