Compare commits
2 commits
4fa94a647d
...
c3b3bb6ded
Author | SHA1 | Date | |
---|---|---|---|
|
c3b3bb6ded | ||
|
d7d5887fb1 |
4 changed files with 22 additions and 7 deletions
|
@ -16,18 +16,22 @@ classNames = ["person", "bicycle", "car", "motorbike", "aeroplane", "bus", "trai
|
|||
"teddy bear", "hair drier", "toothbrush"
|
||||
]
|
||||
|
||||
model = YOLO('yolov8s.pt') # Load an official Detect model
|
||||
model = YOLO('yolov8m.pt') # Load an official Detect model
|
||||
|
||||
async def handle_connection(websocket, path):
|
||||
print(f"Connection from: {path}")
|
||||
try:
|
||||
while True:
|
||||
raw_data = await websocket.recv()
|
||||
print(f"downloaded bytes: {len(raw_data)}")
|
||||
|
||||
nparr = np.frombuffer(raw_data, np.uint8).reshape((480, 640, 3))
|
||||
# nparr = np.frombuffer(decoded_bytes, np.uint8).reshape((480, 640, 3))
|
||||
nparr = np.frombuffer(raw_data, dtype=np.uint8)
|
||||
|
||||
# frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
|
||||
frame = cv2.cvtColor(nparr, cv2.COLOR_BGR2RGB)
|
||||
frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
|
||||
|
||||
# frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
|
||||
cv2.imshow("from_remote", frame)
|
||||
|
||||
# Perform object detection
|
||||
results = model.track(frame, persist=True)
|
||||
|
@ -73,6 +77,8 @@ async def handle_connection(websocket, path):
|
|||
|
||||
ret = lines.encode('utf-8')
|
||||
|
||||
cv2.waitKey(1)
|
||||
|
||||
await websocket.send(ret)
|
||||
|
||||
except websockets.exceptions.ConnectionClosed:
|
||||
|
|
|
@ -5,12 +5,13 @@ import cv2
|
|||
import math
|
||||
|
||||
# model
|
||||
model = YOLO("yolov8x.pt")
|
||||
# model = YOLO("yolov8x.pt")
|
||||
model = YOLO('yolov8n_full_integer_quant_edgetpu.tflite', task="detect") # Load an official Detect model
|
||||
|
||||
# start webcam
|
||||
cap = cv2.VideoCapture(0)
|
||||
cap.set(3, 640)
|
||||
cap.set(4, 480)
|
||||
cap.set(4, 640)
|
||||
|
||||
# object classes
|
||||
classNames = ["person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat",
|
||||
|
@ -28,6 +29,8 @@ classNames = ["person", "bicycle", "car", "motorbike", "aeroplane", "bus", "trai
|
|||
|
||||
while True:
|
||||
success, img = cap.read()
|
||||
# img = cv2.resize(img, (512, 512), cv2.INTER_AREA)
|
||||
print(f"Image dimensions: {img.shape}")
|
||||
results = model.track(img, persist=True, stream=True)
|
||||
|
||||
# coordinates
|
||||
|
|
6
Yolo TFLite Export/main.py
Normal file
6
Yolo TFLite Export/main.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from ultralytics import YOLO
|
||||
|
||||
model = YOLO("yolov8n.pt")
|
||||
|
||||
# model.export(format="onnx", simplify=True, int8=True)
|
||||
model.export(format="engine")
|
|
@ -1 +1 @@
|
|||
Subproject commit 66acd4698fcc997099ebc1ddc6f8e5ddd0e3579c
|
||||
Subproject commit 0a47c7a9583148c101652e3772cf5ecad95d3092
|
Loading…
Reference in a new issue