問題ない。

```
    import cv2
    import numpy as np

    # 入力画像を読み込みます
    img = cv2.imread('input_photo.jpg')

    # 画像をグレースケールに変換します
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    # 画像のエッジを検出します
    edges = cv2.Canny(gray, 50, 150, apertureSize=3) 

    # ハフ変換を用いて，画像中の線を検出します
    lines = cv2.HoughLines(edges, 1, np.pi / 180, 200)

    # 検出された線の平均角度を求めます
    angles = [].
    for line in lines：
        for rho, theta in line：
            a = np.cos(theta)
            b = np.sin(theta)
            x0 = a * rho
            y0 = b * rho
            x1 = int(x0 + 1000 * (-b))
            y1 = int(y0 + 1000 * (a))
            x2 = int(x0 - 1000 * (-b))
            y2 = int(y0 - 1000 * (a))
            angle = np.arctan2(y2 - y1, x2 - x1) * 180 / np.pi
            angles.append(angle)

    # 画像を平均角度だけ回転させる
    avg_angle = np.mean(angles)
    rows, cols, _ = img.shape.
    M = cv2.getRotationMatrix2D((cols / 2, rows / 2), avg_angle, 1).
    rotated = cv2.warpAffine(img, M, (cols, rows))

    # 回転した画像を保存します．
    cv2.imwrite('output_photo.png', rotated)
```
No problem, here you go.

    import cv2
    import numpy as np

    # Load input image
    img = cv2.imread('input_photo.jpg')

    # Convert image to grayscale
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    # Detect edges in the image
    edges = cv2.Canny(gray, 50, 150, apertureSize=3)

    # Detect lines in the image using Hough transform
    lines = cv2.HoughLines(edges, 1, np.pi / 180, 200)

    # Compute the average angle of the detected lines
    angles = []
    for line in lines:
        for rho, theta in line:
            a = np.cos(theta)
            b = np.sin(theta)
            x0 = a * rho
            y0 = b * rho
            x1 = int(x0 + 1000 * (-b))
            y1 = int(y0 + 1000 * (a))
            x2 = int(x0 - 1000 * (-b))
            y2 = int(y0 - 1000 * (a))
            angle = np.arctan2(y2 - y1, x2 - x1) * 180 / np.pi
            angles.append(angle)

    # Rotate the image by the average angle
    avg_angle = np.mean(angles)
    rows, cols, _ = img.shape
    M = cv2.getRotationMatrix2D((cols / 2, rows / 2), avg_angle, 1)
    rotated = cv2.warpAffine(img, M, (cols, rows))

    # Save the rotated image
    cv2.imwrite('output_photo.png', rotated)