Skip to content

Commit

Permalink
Add webcam inference
Browse files Browse the repository at this point in the history
  • Loading branch information
adaniel105 committed Jul 28, 2024
1 parent f5b3122 commit 23f1b4a
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
38 changes: 38 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import cv2
import supervision as sv
from ultralytics import YOLO

model = YOLO("yolov10s.pt")
bounding_box_annotator = sv.BoundingBoxAnnotator()
label_annotator = sv.LabelAnnotator()


cap = cv2.VideoCapture(-1)

if not cap.isOpened:
print("Unable to read camera feed")


while True:
ret, frame = cap.read()

if not ret:
break

results = model(frame)[0]
detections = sv.Detections.from_ultralytics(results)

annotated_image = bounding_box_annotator.annotate(
scene=frame, detections=detections
)
annotated_image = label_annotator.annotate(
scene=annotated_image, detections=detections
)

cv2.imshow("Webcam", annotated_image)

k = cv2.waitKey(1)

if k % 256 == 27:
print("Escape hit, closing...")
break
110 changes: 110 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
certifi==2024.7.4
charset-normalizer==3.3.2
contourpy==1.2.1
cycler==0.12.1
defusedxml==0.7.1
dill==0.3.8
filelock==3.15.4
fonttools==4.53.1
fsspec==2024.6.1
idna==3.7
Jinja2==3.1.4
kiwisolver==1.4.5
MarkupSafe==2.1.5
matplotlib==3.9.1
mpmath==1.3.0
networkx==3.3
numpy==1.26.4
nvidia-cublas-cu12==12.1.3.1
nvidia-cuda-cupti-cu12==12.1.105
nvidia-cuda-nvrtc-cu12==12.1.105
nvidia-cuda-runtime-cu12==12.1.105
nvidia-cudnn-cu12==9.1.0.70
nvidia-cufft-cu12==11.0.2.54
nvidia-curand-cu12==10.3.2.106
nvidia-cusolver-cu12==11.4.5.107
nvidia-cusparse-cu12==12.1.0.106
nvidia-nccl-cu12==2.20.5
nvidia-nvjitlink-cu12==12.5.82
nvidia-nvtx-cu12==12.1.105
opencv-python==4.10.0.84
opencv-python-headless==4.10.0.84
packaging==24.1
pandas==2.2.2
pillow==10.4.0
psutil==6.0.0
py-cpuinfo==9.0.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytz==2024.1
PyYAML==6.0.1
requests==2.32.3
scipy==1.14.0
seaborn==0.13.2
six==1.16.0
supervision==0.22.0
sympy==1.13.1
torch==2.4.0
torchvision==0.19.0
tqdm==4.66.4
triton==3.0.0
typing_extensions==4.12.2
tzdata==2024.1
ultralytics==8.2.68
ultralytics-thop==2.0.0
urllib3==2.2.2
certifi==2024.7.4
charset-normalizer==3.3.2
contourpy==1.2.1
cycler==0.12.1
defusedxml==0.7.1
dill==0.3.8
filelock==3.15.4
fonttools==4.53.1
fsspec==2024.6.1
idna==3.7
Jinja2==3.1.4
kiwisolver==1.4.5
MarkupSafe==2.1.5
matplotlib==3.9.1
mpmath==1.3.0
networkx==3.3
numpy==1.26.4
nvidia-cublas-cu12==12.1.3.1
nvidia-cuda-cupti-cu12==12.1.105
nvidia-cuda-nvrtc-cu12==12.1.105
nvidia-cuda-runtime-cu12==12.1.105
nvidia-cudnn-cu12==9.1.0.70
nvidia-cufft-cu12==11.0.2.54
nvidia-curand-cu12==10.3.2.106
nvidia-cusolver-cu12==11.4.5.107
nvidia-cusparse-cu12==12.1.0.106
nvidia-nccl-cu12==2.20.5
nvidia-nvjitlink-cu12==12.5.82
nvidia-nvtx-cu12==12.1.105
opencv-python==4.10.0.84
opencv-python-headless==4.10.0.84
packaging==24.1
pandas==2.2.2
pillow==10.4.0
psutil==6.0.0
py-cpuinfo==9.0.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytz==2024.1
PyYAML==6.0.1
requests==2.32.3
scipy==1.14.0
seaborn==0.13.2
six==1.16.0
supervision==0.22.0
sympy==1.13.1
torch==2.4.0
torchvision==0.19.0
tqdm==4.66.4
triton==3.0.0
typing_extensions==4.12.2
tzdata==2024.1
ultralytics==8.2.68
ultralytics-thop==2.0.0
urllib3==2.2.2
Binary file added yolov10s.pt
Binary file not shown.

0 comments on commit 23f1b4a

Please sign in to comment.