提交 f0d38bd8 编写于 作者: m0_72150303's avatar m0_72150303

Initial commit

上级
import cv2
from ultralytics import YOLO
import time
import os
import warnings
warnings.filterwarnings("ignore")
# model = YOLO('yolov8n.pt')
# Fastest model with least accuarcy
model = YOLO('yolov8x.pt')
# Slowest model but highest accuracy
cap = cv2.VideoCapture(1)
# cap = cv2.VideoCapture(0)
while cap.isOpened():
success, frame = cap.read()
results = model(frame)
annotated_frame = results[0].plot()
cv2.imshow("YOLOv8 Inference", annotated_frame)
t = time.localtime()
timestamp = str(t.tm_year) + "-" + str(t.tm_mon) + "-" + str(t.tm_mday) + "-" + str(t.tm_hour) + "-" + str(t.tm_min) + "-" + str(t.tm_sec)
if cv2.waitKey(1) & 0xFF == 27:
break
elif cv2.waitKey(1) & 0xFF == 13:
filename = "ObjectDetection_" + timestamp + ".jpg"
output_pth = os.path.join("./Cap/", filename)
cv2.imwrite(output_pth, annotated_frame)
cap.release()
cv2.destroyAllWindows()
@echo off
pip.exe install -r .\requirements.txt
pause
exit
\ No newline at end of file
import cv2
from ultralytics import YOLO
import time
import os
import warnings
warnings.filterwarnings("ignore")
# model = YOLO('yolov8n-pose.pt', task='pose')
# Fastest model with least accuarcy
model = YOLO('yolov8x-pose.pt', task='pose')
# Slowest model but highest accuracy
cap = cv2.VideoCapture(1)
# cap = cv2.VideoCapture(0)
while cap.isOpened():
success, frame = cap.read()
results = model(frame)
annotated_frame = results[0].plot()
cv2.imshow("YOLOv8 Inference", annotated_frame)
t = time.localtime()
timestamp = str(t.tm_year) + "-" + str(t.tm_mon) + "-" + str(t.tm_mday) + "-" + str(t.tm_hour) + "-" + str(t.tm_min) + "-" + str(t.tm_sec)
if cv2.waitKey(1) & 0xFF == 27:
break
elif cv2.waitKey(1) & 0xFF == 13:
filename = "HumanPoint_" + timestamp + ".jpg"
output_pth = os.path.join("./Cap/", filename)
cv2.imwrite(output_pth, annotated_frame)
cap.release()
cv2.destroyAllWindows()
# Instructions For using this project
## You need to first setup environment.
1. Have Python First! (>=3.6)
2. If you are Windows, click the "Environment Setup.bat" to setup.
For Linux and Mac: Open Terminal and input "pip install -r .\requirements.txt"
## Then you can run our demo.
We have 2 demos which you can run.
1. Detection
2. HumanPoint
If you are Windows, click bat files to run.
For Linux and Mac: Type in "python .\PythonFileName"
## Operations
1. You can quit by using pressing Key ESC (Escape) or killing python process.
2. You can also take screenshots by tapping Enter on the keyboard.
## New Update
1. You can Take a Screenshot through taping Enter on your keyboard.
The image will be in Cap folder.
## Model
1. In the code, you can change the model we chose.
The original one is "yolov8x" series, which has the best accuarcy but least efficiency.
2. You can change "yolov8n" series model, which have been downloaded already.
3. You can use this feature by hanging codes.
## Good Luck and Enjoy!
# Sincerely, MMiter, the author
\ No newline at end of file
@echo off
python.exe .\Detection.py
pause
exit
\ No newline at end of file
@echo off
python.exe .\HumanPoint.py
pause
exit
\ No newline at end of file
文件已添加
文件已添加
文件已添加
文件已添加
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册