I see issues with cv::line and possibly other drawing primitives, which may be r…elated.
firstly, the expected output (thickness, lineType) isn't documented all that precisely. it may be implementation-defined (depends on operating system or 3rd party graphics library?), but then that should be stated in the docs.
secondly, what it currently does (v4.1.1 on Win10, also 3.4.4 on a raspbian) is unexpected and follows no discernible pattern. Progressions of line thickness cause monotonously widening lines (at least!), but in uneven steps, and don't interpret thickness as either radius or diameter.
Following are a few reproducible examples with halfway visible pixels you can look at.
Questions:
* how much of a concern is this?
* what *should* be the intended behavior?
```py
# simple diagonal line, not bresenham but acceptable
>>> img = np.zeros((16,16), np.uint8); img = cv.line(img, (4,6), (12,10), color=99, thickness=1, lineType=cv.LINE_4); img
array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 99, 99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 99, 99, 99, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 99, 99, 99, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 99, 99, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 99, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
```
```py
# thickness=3 actually means radius=3? or what does it mean?
>>> img = np.zeros((16,16), np.uint8); img = cv.line(img, (4,8), (12,8), color=99, thickness=3, lineType=cv.LINE_4); img
array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0, 0, 0],
[ 0, 0, 0, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0, 0],
[ 0, 0, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0],
[ 0, 0, 0, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0, 0],
[ 0, 0, 0, 0, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
```
```py
# straight line, thickness=1 with LINE_AA, doesn't even produce a line of thickness 1
>>> img = np.zeros((16,16), np.uint8); img = cv.line(img, (4,8), (12,8), color=99, thickness=1, lineType=cv.LINE_AA); img
array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 10, 19, 21, 21, 21, 21, 21, 21, 10, 0, 0, 0],
[ 0, 0, 0, 0, 55, 89, 90, 90, 90, 90, 90, 90, 59, 0, 0, 0],
[ 0, 0, 0, 0, 11, 23, 23, 23, 23, 23, 23, 23, 12, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
```
```py
# LINE_AA with thickness=3 makes it even worse
>>> img = np.zeros((16,16), np.uint8); img = cv.line(img, (4,8), (12,8), color=99, thickness=3, lineType=cv.LINE_AA); img
array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 10, 19, 21, 21, 21, 21, 21, 21, 10, 0, 0, 0],
[ 0, 0, 0, 34, 99, 99, 99, 99, 99, 99, 99, 99, 99, 34, 0, 0],
[ 0, 0, 0, 75, 99, 99, 99, 99, 99, 99, 99, 99, 99, 64, 0, 0],
[ 0, 0, 76, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 48, 0],
[ 0, 0, 2, 79, 99, 99, 99, 99, 99, 99, 99, 99, 99, 65, 2, 0],
[ 0, 0, 0, 36, 99, 99, 99, 99, 99, 99, 99, 99, 99, 38, 0, 0],
[ 0, 0, 0, 0, 11, 23, 23, 23, 23, 23, 23, 23, 12, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
```