python で画像処理する際の質問です。 ANACONDAを使っています。 先ほどOpenCVをインストールして、画像処理をしようとして、プロンプトで出力したらエラーが出ました。
(base) C:\Users\a.sakata\Desktop\python_lesson>python script.py
Traceback (most recent call last):
File "script.py", line 22, in <module>
halfImg = cv2.resize(img, size)
TypeError: integer argument expected, got float
python
1 2import cv2 3 4import numpy as np 5 6 7 8img = cv2.imread('WIN_20190306_10_38_28_Pro.jpg') 9 10 11 12orgHeight, orgWidth = img.shape[:2] 13 14size = (orgHeight/2, orgWidth/2) 15 16 17 18#Create Half Size Image 19 20#halfImg = cv2.resize(img, (orgHeight / 2, orgWidth / 2)) 21 22halfImg = cv2.resize(img, size) 23 24 25 26#Create 2 times big Image 27 28twiceImg = cv2.resize(img, None, fx = 2, fy = 2) 29 30 31 32cv2.imwrite('half.jpg', halfImg) 33 34cv2.imwrite('twiceImg.jpg', twiceImg) 35
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。