OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'warpPerspective'
Overload resolution failed:
- src is not a numpy array, neither a scalar
- Expected Ptr<cv::UMat> for argument 'src'
import numpy as np
img = cv2.VideoCapture(0)
while True:
# Step 1: Define 4 corner points , use any photo editor like paint to get pixel location of the points
pts1 = np.float32([[85,30],[150,30],[86,125],[150,125]])
# Step 2: Define location of the points
width, height = 250, 350 # getting required size by taking care of height & width ratio of card
pts2 = np.float32([[0,0],[width,0],[0,height],[width,height]])
# Step 3: Make matrix
matrix = cv2.getPerspectiveTransform(pts1,pts2)
# Get Output image based on the above matrix
imgOutput = cv2.warpPerspective(img, matrix, (width, height))
cv2.imshow("Image",img)
cv2.imshow("Output", imgOutput)
if cv2.waitKey(1) == ord('q'):
break
img.release()
cv2.destroyAllWindows()```