python中xy坐标如何从十个中找到最远的两个_python – Opencv单应性从像素xy坐标中查找全局xy坐标...

我试图找到变换矩阵H,以便我可以乘以(x,y)像素坐标并得到(x,y)真实世界坐标.这是我的代码:

import cv2

import numpy as np

from numpy.linalg import inv

if __name__ == '__main__' :

D=[159.1,34.2]

I=[497.3,37.5]

G=[639.3,479.7]

A=[0,478.2]

# Read source image.

im_src = cv2.imread('/home/vivek/june_14.png')

# Four corners of the book in source image

pts_src = np.array([D,I,G,A])

# Read destination image.

im_dst = cv2.imread('/home/vivek/june_14.png')

# Four corners of the book in destination image.

print "img1 shape:",im_dst.shape

scale=1

O=[0.0,0.0]

X=[134.0*scale,0]

Y=[0.0,184.0*scale]

P=[134.0*scale,184.0*scale]

# lx = 75.5 * scale

# ly = 154.0 * scale

pts_dst = np.array([O,X,P,Y])

# Calculate Homography

h, status = cv2.findHomography(pts_src, pts_dst)

print "homography:",h

print "inv of H:",inv(h)

print "position of the blob on the ground xy plane:",np.dot(np.dot(h,np.array([[323.0],[120.0],[1.0]])),scale)

# Warp source image to destination based on homography

im_out = cv2.warpPerspective(im_src, h, (im_dst.shape[1],im_dst.shape[0]))

# Display images

cv2.imshow("Source Image", im_src)

cv2.imshow("Destination Image", im_dst)

cv2.imshow("Warped Source Image", im_out)

cv2.imwrite("im_out.jpg", im_out)

cv2.waitKey(0)

我得到的全球xy非常关闭.我在某处做错了吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值