学习《OpenCV应用开发:入门、进阶与工程化实践》一书,学会本文所有技能就这么简单!
做真正的OpenCV开发者,从入门到入职,一步到位!
YOLOv8全系模型推理支持
大家好,OpenCV实验大师最新C++ SDK已经支持全系YOLOv8模型推理,基于OpenCV实现,支持CPU与GPU推理。支持对象检测、实例分割、姿态评估、旋转对象检测,模型部署推理,简单易容,只要三行代码即可调用,实现YOLOv8模型的C++ 推理部署,支持多种系统包括乌班图、Jetson、Win10与Win11上运行。
SDK效果演示
YOLOv8对象检测
YOLOv8对象检测C++ 调用代码示例
std::shared_ptr<YOLOv8Detector> detector(new YOLOv8Detector());
detector->initConfig("D:/python/my_yolov8_train_demo/yolov8n.onnx", 0.25, 640,640, false);
detector->detect(image, results)
YOLOv8实例分割
YOLOv8实例分割 C++ 调用代码示例:
std::shared_ptr<YOLOv8SegDetector> detector(new YOLOv8SegDetector());
detector->initConfig("D:/python/my_yolov8_train_demo/yolov8n.onnx", 0.4, 0.25f);
cv::VideoCapture capture("D:/bird_test/Pexels_Videos_2670.mp4");
cv::Mat frame;
std::vector<DetectResult> results;
while (true) {
bool ret = capture.read(frame);
if (frame.empty()) {
break;
}
detector->detect(frame, results);
for (DetectResult dr : results) {
cv::Rect box = dr.box;
cv::putText(frame, classNames[dr.classId], cv::Point(box.tl().x, box.tl().y - 10), cv::FONT_HERSHEY_SIMPLEX, .5, cv::Scalar(0, 0, 0));
}
cv::imshow("YOLOv8 实例分割 + OpenCV", frame);
char c = cv::waitKey(1);
if (c == 27) { // ESC 退出
break;
}
// reset for next frame
results.clear();
}
YOLOv8姿态评估
YOLOv8姿态评估 C++ 调用代码示例:
std::shared_ptr<YOLOv8PoseDetector> detector(new YOLOv8PoseDetector());
detector->initConfig("D:/python/my_yolov8_train_demo/yolov8n-pose.onnx", 0.25, 640,640, false);
cv::VideoCapture capture("D:/bird_test/hongyegu.mp4");
cv::Mat frame;
std::vector<YOLODetBox> results;
while (true) {
bool ret = capture.read(frame);
if (frame.empty()) {
break;
}
detector->detect(frame, results);
for (YOLODetBox dr : results) {
cv::Rect box = dr.box;
cv::putText(frame, classNames[0], cv::Point(box.tl().x, box.tl().y - 10), cv::FONT_HERSHEY_SIMPLEX, .5, cv::Scalar(0, 0, 0));
}
cv::imshow("OpenCV YOLOv8姿态评估", frame);
char c = cv::waitKey(1);
if (c == 27) { // ESC 退出
break;
}
// reset for next frame
results.clear();
}
return 0;
QTC++ 封装开发
然后我基于QT5 + OpenCV4.8 实现了全面界面化处理开发,知道自定义的YOLOv8对象检测一键部署,完成各种自定义对象检测功能,运行如下:
安全帽检测
无人机检测
细胞检测
姿态评估
QQ 读者交流 657875553
学习《OpenCV应用开发:入门、进阶与工程化实践》一书
做真正的OpenCV开发者,从入门到入职,一步到位!