def draw_straight_line(img, pt1, pt2, color, thickness):
    '\n    直線を引く。OpenCV だと 8bit しか対応してないっぽいので自作。\n\n    Parameters\n    ----------\n    img : array_like\n        image data.\n    pt1 : list(pos_h, pos_v)\n        start point.\n    pt2 : list(pos_h, pos_v)\n        end point.\n    color : array_like\n        color\n    thickness : int\n        thickness.\n\n    Returns\n    -------\n    array_like\n        image data with line.\n\n    Notes\n    -----\n    thickness のパラメータは pt1 の点から右下方向に効きます。\n    pt1 を中心として太さではない事に注意。\n\n    Examples\n    --------\n    >>> pt1 = (0, 0)\n    >>> pt2 = (1920, 0)\n    >>> color = (940, 940, 940)\n    >>> thickness = 4\n    >>> draw_straight_line(img, pt1, pt2, color, thickness)\n    '
    if ((pt1[0] != pt2[0]) and (pt1[1] != pt2[1])):
        raise ValueError('invalid pt1, pt2 parameters')
    if (pt1[0] == pt2[0]):
        thickness_direction = 'h'
    else:
        thickness_direction = 'v'
    if (thickness_direction == 'h'):
        for h_idx in range(thickness):
            img[pt1[1]:pt2[1], (pt1[0] + h_idx), :] = color
    elif (thickness_direction == 'v'):
        for v_idx in range(thickness):
            img[(pt1[1] + v_idx), pt1[0]:pt2[0], :] = color
直線を引く。OpenCV だと 8bit しか対応してないっぽいので自作。

Parameters
----------
img : array_like
    image data.
pt1 : list(pos_h, pos_v)
    start point.
pt2 : list(pos_h, pos_v)
    end point.
color : array_like
    color
thickness : int
    thickness.

Returns
-------
array_like
    image data with line.

Notes
-----
thickness のパラメータは pt1 の点から右下方向に効きます。
pt1 を中心として太さではない事に注意。

Examples
--------
>>> pt1 = (0, 0)
>>> pt2 = (1920, 0)
>>> color = (940, 940, 940)
>>> thickness = 4
>>> draw_straight_line(img, pt1, pt2, color, thickness)
def draw_straight_line(img, pt1, pt2, color, thickness):
    '\n    直線を引く。OpenCV だと 8bit しか対応してないっぽいので自作。\n\n    Parameters\n    ----------\n    img : array_like\n        image data.\n    pt1 : list(pos_h, pos_v)\n        start point.\n    pt2 : list(pos_h, pos_v)\n        end point.\n    color : array_like\n        color\n    thickness : int\n        thickness.\n\n    Returns\n    -------\n    array_like\n        image data with line.\n\n    Notes\n    -----\n    thickness のパラメータは pt1 の点から右下方向に効きます。\n    pt1 を中心として太さではない事に注意。\n\n    Examples\n    --------\n    >>> pt1 = (0, 0)\n    >>> pt2 = (1920, 0)\n    >>> color = (940, 940, 940)\n    >>> thickness = 4\n    >>> draw_straight_line(img, pt1, pt2, color, thickness)\n    '
    if ((pt1[0] != pt2[0]) and (pt1[1] != pt2[1])):
        raise ValueError('invalid pt1, pt2 parameters')
    if (pt1[0] == pt2[0]):
        thickness_direction = 'h'
    else:
        thickness_direction = 'v'
    if (thickness_direction == 'h'):
        for h_idx in range(thickness):
            img[pt1[1]:pt2[1], (pt1[0] + h_idx), :] = color
    elif (thickness_direction == 'v'):
        for v_idx in range(thickness):
            img[(pt1[1] + v_idx), pt1[0]:pt2[0], :] = color