#include "include/bound.hpp"

std::vector<std::vector<cv::Point>> bound_contours(cv::Mat img) {
    std::vector<std::vector<cv::Point>> contours;
    cv::findContours(img, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);

    return contours;
}

std::vector<cv::Rect>
bound_boxes(std::vector<std::vector<cv::Point>> contours) {
    std::vector<cv::Rect> boxes;;

    for (size_t i = 0; i < contours.size(); i++) {
        cv::Rect box = cv::boundingRect(contours[i]);

        if (box.width < BOUND_MIN_W && box.height < BOUND_MIN_H) continue;

        boxes.push_back(box);
    }

    return boxes;
}
