1 | initial version |
image is none. Check it
2 | No.2 Revision |
image is none. Check itTry warped = cv2.warpAffine(image[:,:,0], mat_[0], dsize)
3 | No.3 Revision |
Try warped = cv2.warpAffine(image[:,:,0], mat_[0], dsize)
estimateAffine2D return two values -> read doc
4 | No.4 Revision |
Try warped = cv2.warpAffine(image[:,:,0], mat_[0], dsize)
estimateAffine2D return two values -> read doc no error with this code windows 64 bits and '4.2.0-dev'
import numpy as np
import cv2
image = cv2.imread('g:/lib/opencv/samples/data/lena.jpg')
if image is None:
print("error")
tx1,ty1=100,100
tx2,ty2=100,200
tx3,ty3=200,200
tx4,ty4=200,100
scale = 1
x1,y1=100,100
x2,y2=100,200
x3,y3=200,200
x4,y4=200,100
target_pts = np.array([[tx1, ty1], [tx2, ty2], [tx3, ty3], [tx4, ty4]]).astype(np.float32) * scale
org_pts = np.array([[x1, y1], [x2, y2], [x3, y3], [x4, y4]]).astype(np.float32)
mat_,inlier = cv2.estimateAffine2D(org_pts, target_pts)
dsize = (int(120 * scale), int(48 * scale))
warped = cv2.warpAffine(image, mat_, dsize)