- Notifications
You must be signed in to change notification settings - Fork5.9k
Closed
Labels
Description
- OpenCV => 4.2
- Operating System / Platform => Windows 64 Bit
- Compiler =>Visual Studio 2019
Detailed description
For opencv_contrib/modules/ximgproc/src/seeds.cpp
lines 136-141
//compute initial label for sublevels: level <= seeds_top_level//this is an equally sized grid with size nr_h[level]*nr_w[level]int computeLabel(int level, int x, int y) { return std::min(y / (height / nr_wh[2 * level + 1]), nr_wh[2 * level + 1] - 1) * nr_wh[2 * level] + std::min((x / (width / nr_wh[2 * level])), nr_wh[2 * level] - 1);}When processing a large number of images, a program crash can occur with a divide by zero error in the above function. This can be rectified by changing to the following:
//compute initial label for sublevels: level <= seeds_top_level//this is an equally sized grid with size nr_h[level]*nr_w[level]int computeLabel(int level, int x, int y) { return std::min(y * nr_wh[2 * level + 1] / height), nr_wh[2 * level + 1] - 1) * nr_wh[2 * level] + std::min((x * nr_wh[2 * level] / width)), nr_wh[2 * level] - 1);}