nms过滤包含框

yolov7的:


struct Object
{
	cv::Rect_ rect;
	int label;
	float prob;
};

void nms_sorted_bboxes(const std::vector& faceobjects, std::vector& picked, float nms_threshold);

void YOLO::nms_sorted_bboxes(const std::vector& faceobjects, std::vector& picked, float nms_threshold)
{
	picked.clear();

	const int n = faceobjects.size();

	std::vector areas(n);
	for (int i = 0; i < n; i++)
	{
		areas[i] = faceobjects[i].rect.area();
	}

	for (int i = 0; i < n; i++)
	{
		const Object& a = faceobjects[i];

		int keep = 1;
		for (int j = 0; j < (int)picked.size(); j++)
		{
			const Object& b = faceobjects[picked[j]];

			// intersection over union
			float inter_area = intersection_area(a, b);
			float union_area = areas[i] + areas[picked[j]] - inter_ar 
  

                            
                        
                    
                    
                    

你可能感兴趣的:(c++入门宝典,c++,nms)