OpenCV study notes

Rect:

A piece of code to judge the similarity of two candidate boxes:

    inline int32_t operator()(const cv::Rect& r1, const cv::Rect& r2) const
    {
        double delta = eps * (std::min(r1.width, r2.width) + std::min(r1.height, r2.height)) * 0.5;  //计算阈值
        return (abs(r1.x - r2.x) <= delta &&                                                         
            abs(r1.y - r2.y) <= delta &&
            abs(r1.x + r1.width - r2.x - r2.width) <= delta &&
            abs(r1.y + r1.height - r2.y - r2.height) <= delta) || (r1 & r2).area() == std::min(r1.area(), r2.area());
    }

The difference between the first 4 and the upper left and lower right coordinates used to ensure that the two rectangular boxes are less than the threshold, the last one or consider whether one of the rectangles completely contains the other rectangle

Rect rect = rect1 & rect2;
rect is the intersection of two rectangles

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325019486&siteId=291194637