一、代码
#include
#include
#include // Include RealSense Cross Platform API
using namespace cv;
using namespace dnn;
using namespace std;
using namespace rs2;
// 类名数组,这里需要替换为实际YOLO模型所检测的对象的类名
const char* classNames[] = {"object1", "object2", "object3", "object4"};
int main(int argc, char** argv)
{
// 模型权重和配置文件路径,这些文件包含了训练好的YOLO模型参数和网络配置
String model = "yolov5.onnx"; // 替换为实际模型文件路径
// 加载预训练的模型和配置到DNN网络中
Net net = readNetFromONNX(model);
// 设置推理引擎后端为OpenCV,目标设备为CPU
net.setPreferableBackend(DNN_BACKEND_OPENCV);
net.setPreferable服务器托管网Target(DNN_TARGET_CPU);
// Declare depth colorizer for pretty visualization of depth data
colorizer color_map;
// Declare RealSense pipeline, encapsulating the actual device and sensors
pipeline p;
// Start streaming with default recommended configuration
p.start();
// 循环直到用户按下键盘上的任意键
while (waitKey(1) outs;
net.forward(outs, net.getUnconnectedOutLayersNames());
// 遍历网络输出的每一层结果
for (size_t i = 0; i 0.5) {
int centerX = (int)(outs[i].at(j, 0) * frame.cols);
int centerY = (int)(outs[i].at(j, 1) * frame.rows);
int width = (int)(outs[i].at(j, 2) * frame.cols);
int height = (int)(outs[i].at(j, 3) * frame.rows);
int left = centerX - width / 2;
int top = centerY - height / 2;
rectangle(frame, Rect(left, top, width, height), Scalar(0, 255, 0), 2);
int classIdx = static_cast(classIdPoint.x);
string classLabel = string(classNames[classIdx]);
string label = classLabel + ":" + format("%.2f", confidence);
int baseLine;
Size labelSize = getTextSize(label, FONT_HERSH服务器托管网EY_SIMPLEX, 0.5, 1, &baseLine);
top = max(top, labelSize.height);
rectangle(frame, Point(left, top - labelSize.height), Point(left + labelSize.width, top + baseLine), Scalar::all(255), FILLED);
putText(frame, label, Point(left, top), FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0,0,0));
}
}
}
// 展示处理后的帧
imshow("YoloV8", frame);
}
return 0;
}
注意:由于手头上没有该摄像头,本人只是查询资料,以及文档之后写的代码,并没有实操
二、安装包
需要安装opencv、librealsense2库
链接:Intel.RealSense.SDK.zip资源-CSDN文库
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
SQL性能分析 1、SQL执行频率 MySQL 客户端连接成功后,通过 show [session|global] status 命令可以提供服务器状态信 息。通过如下指令,可以查看当前数据库的INSERT、UPDATE、DELETE、SELECT的访问频…