현재 공중 이미지에서 이미지 왜곡을 보정하기 위해 Python에서 OpenCV를 사용하고 있습니다. 롤, 피치 및 요에 대한 데이터가 있습니다. 워프 매트릭스를 만들고 원래의 좌표 포인트에 매트릭스를 적용하여 이미지 출력 지점을 만들어야한다는 것을 알고 있습니다. 나는 이미지가 움직이는 방식에 영향을 미칠 수 있지만, 아주 작은 값에 대해서만 작용하는 유일한 값이기 때문에 에러가 있다고 생각한다. 당신은() 변환 행렬을 찾기 위해 getPerspectiveTransform를 사용하여 다음 네 개의 점을 투영하여 경사 행렬을 계산하는 코드의 시작 부분에서롤, 피치 및 요를 사용하여 이미지 뒤틀림
warp_mat = np.array([[math.cos(theta)*math.cos(psy), math.cos(phi)*math.sin(psy)+math.sin(phi)*math.sin(theta)*math.cos(psy), math.sin(phi)*math.sin(psy)-math.cos(phi)*math.sin(theta)*math.cos(psy)],\
[-1*math.cos(theta)*math.sin(psy), math.cos(phi)*math.cos(psy)-math.sin(phi)*math.sin(theta)*math.sin(psy), math.sin(phi)*math.cos(psy)+math.cos(phi)*math.sin(theta)*math.sin(psy)],\
[math.sin(theta), -1*math.sin(phi)*math.cos(theta), math.cos(phi)*math.cos(theta)]], dtype='float32')
srcPts = np.array([[-2064, 1161, 1],\
[2064, 1161, 1],\
[2064, -1161, 1],\
[-2064, -1161, 1]], dtype='float32')
dstPts = np.empty(shape = (4,3), dtype='float32')
dstPts[0][0] = srcPts[0][0] * warp_mat[0][0] + srcPts[0][1] * warp_mat[1][0] + srcPts[0][2] * warp_mat[2][0];
dstPts[0][1] = srcPts[0][0] * warp_mat[0][1] + srcPts[0][1] * warp_mat[1][1] + srcPts[0][2] * warp_mat[2][1];
dstPts[0][2] = srcPts[0][0] * warp_mat[0][2] + srcPts[0][1] * warp_mat[1][2] + srcPts[0][2] * warp_mat[2][2];
dstPts[1][0] = srcPts[1][0] * warp_mat[0][0] + srcPts[1][1] * warp_mat[1][0] + srcPts[1][2] * warp_mat[2][0];
dstPts[1][1] = srcPts[1][0] * warp_mat[0][1] + srcPts[1][1] * warp_mat[1][1] + srcPts[1][2] * warp_mat[2][1];
dstPts[1][2] = srcPts[1][0] * warp_mat[0][2] + srcPts[1][1] * warp_mat[1][2] + srcPts[1][2] * warp_mat[2][2];
dstPts[2][0] = srcPts[2][0] * warp_mat[0][0] + srcPts[2][1] * warp_mat[1][0] + srcPts[2][2] * warp_mat[2][0];
dstPts[2][1] = srcPts[2][0] * warp_mat[0][1] + srcPts[2][1] * warp_mat[1][1] + srcPts[2][2] * warp_mat[2][1];
dstPts[2][2] = srcPts[2][0] * warp_mat[0][2] + srcPts[2][1] * warp_mat[1][2] + srcPts[2][2] * warp_mat[2][2];
dstPts[3][0] = srcPts[3][0] * warp_mat[0][0] + srcPts[3][1] * warp_mat[1][0] + srcPts[3][2] * warp_mat[2][0];
dstPts[3][1] = srcPts[3][0] * warp_mat[0][1] + srcPts[3][1] * warp_mat[1][1] + srcPts[3][2] * warp_mat[2][1];
dstPts[3][2] = srcPts[3][0] * warp_mat[0][2] + srcPts[3][1] * warp_mat[1][2] + srcPts[3][2] * warp_mat[2][2];
dstPts[0][0] = dstPts[0][0]/dstPts[0][2];
dstPts[0][1] = dstPts[0][1]/dstPts[0][2];
dstPts[0][2] = dstPts[0][2]/dstPts[0][2];
dstPts[1][0] = dstPts[1][0]/dstPts[1][2];
dstPts[1][1] = dstPts[1][1]/dstPts[1][2];
dstPts[1][2] = dstPts[1][2]/dstPts[1][2];
dstPts[2][0] = dstPts[2][0]/dstPts[2][2];
dstPts[2][1] = dstPts[2][1]/dstPts[2][2];
dstPts[2][2] = dstPts[2][2]/dstPts[2][2];
dstPts[3][0] = dstPts[3][0]/dstPts[3][2];
dstPts[3][1] = dstPts[3][1]/dstPts[3][2];
dstPts[3][2] = dstPts[3][2]/dstPts[3][2];
srcPts2 = np.array([[srcPts[0][0],srcPts[0][1]],\
[srcPts[1][0],srcPts[1][1]],\
[srcPts[2][0],srcPts[2][1]],\
[srcPts[3][0],srcPts[3][1]]], dtype='float32')
dstPts2 = np.array([[dstPts[0][0],dstPts[0][1]],\
[dstPts[1][0],dstPts[1][1]],\
[dstPts[2][0],dstPts[2][1]],\
[dstPts[3][0],dstPts[3][1]]], dtype='float32')
transMatrix = cv.getPerspectiveTransform(srcPts2, dstPts2)
dst = cv.warpPerspective(imgFile,transMatrix,(4128,2322) ,borderMode = cv.BORDER_CONSTANT,borderValue = 0)