Ask Your Question
0

opencv, Geometric Transformations of Images

asked 2018-06-16 00:48:35 -0600

LFIprogrammer gravatar image

updated 2018-06-16 01:14:33 -0600

berak gravatar image

hi i sezai, while working on OpenCV today. I get a mistake in one subject. "Geometric Transformations of Images" OpenCV version 3.1.0 codes this way.

import cv2
img = cv2.imread('sudoku.png')
rows,cols,ch = img.shape

pts1 = np.float32([[56,65],[368,52],[28,387],[389,390]])
pts2 = np.float32([[0,0],[300,0],[0,300],[300,300]])

M = cv2.getPerspectiveTransform(pts1,pts2)

dst = cv2.warpPerspective(img,M,(300,300))

plt.subplot(121),plt.imshow(img),plt.title('Input')
plt.subplot(122),plt.imshow(dst),plt.title('Output')
plt.show()

I received the error :

Traceback (most recent call last): File "yeni.py", line 13, in <module> plt.subplot(121),plt.imshow(img),plt.title('Input') NameError: name 'plt' is not defined

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-06-16 01:22:54 -0600

berak gravatar image

updated 2018-06-16 04:47:21 -0600

that code is using matplotlib (an alternative drawing/plotting/gui library). you have to import it before usage:

import matplotlib.pyplot as plt

maybe you have to install it before (it's not part of the standard python modules):

pip install matplotlib
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-06-16 00:48:35 -0600

Seen: 112 times

Last updated: Jun 16 '18