Skip to content

Commit

Permalink
Update object detection section in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
umair-imran committed Apr 4, 2024
1 parent 4925574 commit 9f15ead
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,32 +120,20 @@ python main.py data/sample_videos/test.mp4

```python
import asone
from asone import utils
from asone import ASOne
import cv2

video_path = 'data/sample_videos/test.mp4'
detector = ASOne(detector=asone.YOLOV7_PYTORCH, use_cuda=True) # Set use_cuda to False for cpu
from asone import ASOne, VideoReader
from tqdm import tqdm

filter_classes = ['car'] # Set to None to detect all classes

cap = cv2.VideoCapture(video_path)

while True:
_, frame = cap.read()
if not _:
break
detector = ASOne(detector=asone.YOLOV7_PYTORCH, use_cuda=True) # Set use_cuda to False for cpu
cap = VideoReader('data/sample_videos/test.mp4')

for frame in tqdm(cap):
dets, img_info = detector.detect(frame, filter_classes=filter_classes)
frame = ASOne.draw_boxes(frame, dets)

bbox_xyxy = dets[:, :4]
scores = dets[:, 4]
class_ids = dets[:, 5]

frame = utils.draw_boxes(frame, bbox_xyxy, class_ids=class_ids)

# Show Video
cv2.imshow('result', frame)

if cv2.waitKey(25) & 0xFF == ord('q'):
break
```
Expand Down

0 comments on commit 9f15ead

Please sign in to comment.