lundi 28 février 2022

OpenCV putText() is too slow for multiple lines. How to speed it up?

I need to overlay about ~50 lines of text on a video stream from an IP camera. But I have found that I cannot use the newline character in putText(), I have to split and print each line individually, which means multiple calls to putText(). This method slows down the video stream from 30 fps to ~3 fps and overloads the video encoder in my IP camera. Are there any methods to improve performance when calling putText multiple times? My code is similar to the following:

void* TextThread(){
    std::vector<std::string> infoValues{...};
    int verticalShift = 0;
    for (auto it = infoValues.begin(); it != infoValues.end(); ++it, verticalShift++){
        cv::putText(img, *it, cv::Point(1470, 30 + 25*verticalShift), FONT_HERSHEY_SIMPLEX, 0.85, cv::Scalar(255, 0, 0), 2, LINE_AA);
    }
}

Aucun commentaire:

Enregistrer un commentaire