mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
2a70226181
imgproc: fix missing tipLength validation in arrowedLine #29191 ### Pull Request Description **Issue/Bug:** Currently, the `cv::arrowedLine` function in `modules/imgproc/src/drawing.cpp` lacks boundary validation for the `tipLength` parameter. Passing an invalid ratio (e.g., negative values or values > 1.0) leads to mathematically distorted arrowhead coordinates being silently passed to the underlying `line()` drawing function, resulting in severely deformed output without any warning. **Solution:** Added a `CV_Assert` to enforce the geometric contract of `tipLength`, ensuring it strictly falls within the logical bounds `(0.0, 1.0]`. This adheres to the fail-fast principle and prevents silent geometric failures. **Testing:** Successfully built the project locally and added a dedicated regression test (`arrowedLine_tipLength_validation`) using Google Test in `modules/imgproc/test/test_drawing.cpp`. Tested with boundary values (e.g., `tipLength = 1.5` and `-0.5`), and the assertion correctly intercepts the invalid parameters before rasterization. *(Note: This contribution is part of a university engineering project evaluating open-source workflow and C++ robustness.)*