2017-06-06 6 views
1

私はPython 2.7.13 | Anaconda 4.3.1(64ビット)とOpenCv '2.4.13.2'を使用しています。 私はopencvでcvPoint2D32f関数が見つからないのはなぜですか?

CvPoint2D32f center = cvPoint2D32f(x, y) 

を使用する必要があるため、私は画像に幾何学的変換を適用しようとしていますが、私はこの機能を見つけることができませんよ、このPythonで利用できるか、廃止されていません。

答えて

1

タイプCvPoint2D32fは古い/推奨されないタイプです。 OpenCV 2はタイプPoint2fを導入しました。それにかかわらず、あなたはPythonでその型を必要としません。あなたが必要とするのは、dtype = np.float32の数値配列です。ポイントの場合、配列は以下のように構築する必要があります。

points = np.array([ [[x1, y1]], ..., [[xn, yn]] ], dtype=np.float32) 

あなたは常に(例えばcv2.findHomography()のような)いくつかの機能は、整数を取るとして、dtypeを設定する必要はありません。以下の画像になります

import cv2 
import numpy as np 

src = cv2.imread('book2.jpg') 
pts_src = np.array([[141, 131], [480, 159], [493, 630],[64, 601]], dtype=np.float32) 
dst = cv2.imread('book1.jpg') 
pts_dst = np.array([[318, 256],[534, 372],[316, 670],[73, 473]], dtype=np.float32) 

transf = cv2.getPerspectiveTransform(pts_src, pts_dst) 
warped = cv2.warpPerspective(src, transf, (dst.shape[1],dst.shape[0])) 

alpha = 0.5 
beta = 1 - alpha 
blended = cv2.addWeighted(warped, alpha, dst, beta, 1.0) 

cv2.imshow("Blended Warped Image", blended) 
cv2.waitKey(0) 

this tutorialからの画像と、我々は画像にホモグラフィを見つけて適用するには、次の操作を行うことができ使用されているこれらの点の例えば

Warped image showing the output of a transformation.

関連する問題