import os
import PyIPSDK
import PyIPSDK.IPSDKIPLGeometricTransform as gtrans
imagesSamplePath = PyIPSDK.getIPSDKDirectory(PyIPSDK.eInternalDirectory.eID_Images)
inputImgPath = os.path.join(imagesSamplePath, "IPSDK_flyer1.tif")
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
targetWidth = 400
targetHeight = 550
inPtColl = [[327, 83],
[697, 216],
[459, 763],
[29, 552]]
outPtColl = [[100, 100],
[100+targetWidth, 100],
[100+targetWidth, 100+targetHeight],
[100, 100+targetHeight]]
transform, res = PyIPSDK.homographyTransform2dSimpleEstimation(inPtColl, outPtColl)
outImg = gtrans.warp2dImg(inImg, transform)
tmpPath = PyIPSDK.getIPSDKDefaultDirectory(PyIPSDK.eDefaultExternalDirectory.eDED_Tmp)
outputImgPath = os.path.join(tmpPath, "warp2dImg.tif")
print("Writing result in file : " + outputImgPath)
PyIPSDK.saveTiffImageFile(outputImgPath, outImg)