![](/img/trans.png)
[英]How do I get z-axis coordinate from ply file for a given point ( x, y ) in python?
[英]How do I make perspective transform of point with x and y coordinate
所以我寫了這個小程序,它允許我在兩個圖像上選擇4個點。
將這些點用於我得到的變換矩陣。 之后,我在其中一個圖像上選擇一個點,並希望可視化該點在其他圖像上的位置。
說我的觀點是這樣的 - > (x,y)
- 所以它是一個元組。 我應該如何在圖像上格式化這個“位置”,以便可以對其進行轉換。
我查看了perspectiveTransform()方法的文檔,並認為我應該將它存儲在以下形狀中:
numpy.array([
[self.points[self.length-1][0]],
[self.points[self.length-1][1]]
], dtype="float32")
這會給我一次點擊這種格式:
Point= [[ 2300.]
[ 634.]]
這種格式似乎不起作用,我使用這個轉換矩陣:
M = [[ -1.71913123e+00 -4.76850572e+00 5.27968944e+03]
[ 2.07693562e-01 -1.09738424e+01 6.35222770e+03]
[ 1.02865125e-04 -4.80067600e-03 1.00000000e+00]]
在這個方法中(並得到以下錯誤):
cv2.perspectiveTransform(src, M)
OpenCV Error: Assertion failed (scn + 1 == m.cols) in cv::perspectiveTransform, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\core\src\matmul.cpp
歡迎任何建議或提示。
我想出了答案。
在此鏈接上找到它
關鍵是要表達你的觀點:
pts = numpy.array([[x,y]], dtype = "float32")
然后在現有變量pts
上調用另一個numpy.array
:
pts = numpy.array([pts])
此后的程序是相同的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.