c++ opencv怎么将yolov5模型对照片进行识别与定位

目前我只有yolov5模型,以及配置好opencv环境变量的vs,没有一个很好的思路

  • 这篇博客: 2021.09.02更新说明 c++下使用opencv部署yolov5模型 (三)中的 一、设置yolov5网络的一些参数。 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 对Yolo类加一点细节,设置一些必要的网络参数

    //参数为私有参数,当然也可以是设置成公开或者保护。
    private:
        //计算归一化函数
    	float Sigmoid(float x) {
    		return static_cast<float>(1.f / (1.f + exp(-x)));
    	}
        //anchors
    	const float netAnchors[3][6] = { { 10.0, 13.0, 16.0, 30.0, 33.0, 23.0 },{ 30.0, 61.0, 62.0, 45.0, 59.0, 119.0 },{ 116.0, 90.0, 156.0, 198.0, 373.0, 326.0 } };
        //stride
    	const float netStride[3] = { 8.0, 16.0, 32.0 };
    	const int netWidth = 640; //网络模型输入大小
    	const int netHeight = 640;
    	float nmsThreshold = 0.45; 
    	float boxThreshold = 0.35;
    	float classThreshold = 0.35;
        //类名
    	std::vector<std::string> className = { "person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
    		"fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
    		"elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
    		"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
    		"tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
    		"sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
    		"potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
    		"microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
    		"hair drier", "toothbrush" };