OpenCVライブラリを使ってレコードの画像を回転させ、ラベルが正立するようにするPythonプログラムの例だ：

```python
import cv2
import numpy as np

# load input image
img = cv2.imread('record.jpg')

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

# apply edge detection to find the contour of the record
edges = cv2.Canny(gray, 50, 150, apertureSize=3)
contours, hierarchy = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

# find the largest contour (assumed to be the record) and its minimum area bounding rectangle
largest_contour = max(contours, key=cv2.contourArea)
rect = cv2.minAreaRect(largest_contour)

# calculate the angle of the bounding rectangle and rotate the image by that angle
angle = rect[2]
if angle < -45:
    angle += 90
rotation_matrix = cv2.getRotationMatrix2D(rect[0], angle, 1)
rotated = cv2.warpAffine(img, rotation_matrix, (img.shape[1], img.shape[0]), flags=cv2.INTER_CUBIC)

# save the output image as a PNG file
cv2.imwrite('rotated_record.png', rotated)
```

このプログラムでは、まずcv2.imread関数を使ってレコードの入力画像を読み込みます。次に画像をグレースケールに変換し、Cannyアルゴリズムを用いてエッジ検出を行い、レコードの輪郭を見つける。そして，最大輪郭（これはレコードであると仮定される）を関数 max を用いて求め，その最小面積の外接矩形を関数 cv2.minAreaRect を用いて求めます．

そして，rect[2]属性を用いて外接矩形の角度を計算し，cv2.getRotationMatrix2D関数とcv2.warpAffine関数を用いて，その角度だけ画像を回転させます．最後に， cv2.imwrite 関数を用いて，出力画像を PNG ファイルとして保存します．

このプログラムは、レコードが画像中で最大の輪郭であり、そのラベルがレコードの辺に垂直であることを仮定していることに注意してください。これらの仮定が成り立たない場合、プログラムは画像を正しく回転できないことがある。
Sure, here's an example Python program that uses the OpenCV library to rotate an image of a record so that its label is upright:

```python
import cv2
import numpy as np

# load input image
img = cv2.imread('record.jpg')

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

# apply edge detection to find the contour of the record
edges = cv2.Canny(gray, 50, 150, apertureSize=3)
contours, hierarchy = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

# find the largest contour (assumed to be the record) and its minimum area bounding rectangle
largest_contour = max(contours, key=cv2.contourArea)
rect = cv2.minAreaRect(largest_contour)

# calculate the angle of the bounding rectangle and rotate the image by that angle
angle = rect[2]
if angle < -45:
    angle += 90
rotation_matrix = cv2.getRotationMatrix2D(rect[0], angle, 1)
rotated = cv2.warpAffine(img, rotation_matrix, (img.shape[1], img.shape[0]), flags=cv2.INTER_CUBIC)

# save the output image as a PNG file
cv2.imwrite('rotated_record.png', rotated)
```

In this program, we first load the input image of the record using the cv2.imread function. We then convert the image to grayscale and apply edge detection using the Canny algorithm to find the contour of the record. The largest contour (which is assumed to be the record) is then found using the max function, and its minimum area bounding rectangle is calculated using the cv2.minAreaRect function.

We then calculate the angle of the bounding rectangle using the rect[2] attribute, and rotate the image by that angle using the cv2.getRotationMatrix2D and cv2.warpAffine functions. Finally, we save the output image as a PNG file using the cv2.imwrite function.

Note that this program assumes that the record is the largest contour in the image, and that its label is perpendicular to the edges of the record. If these assumptions do not hold, the program may not correctly rotate the image.