您当前的位置: 首页 >  Python

程序员正茂

暂无认证

  • 2浏览

    0关注

    283博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

python-opencv在世界地图图片上标记经纬度点

程序员正茂 发布时间:2020-09-02 18:28:22 ,浏览量:2

import cv2
import numpy as np
from matplotlib import pyplot as plt
from PIL import Image
import pytesseract
import math;

def latLon2Imagexy(lat, lon, w, h):
    #lon = lon * 0.9
    #lat = lat * 1.05
    
    x = w * (lon +180) / 360
    y = h * (1- (lat +90) / 180)
    x = math.floor(x)
    y = math.floor(y)
    return x, y
    
img_rgb = cv2.imread('USNI.jpg')
img_rgb=cv2.resize(img_rgb,None,fx=0.25,fy=0.25,interpolation=cv2.INTER_CUBIC)  

h = img_rgb.shape[0]
w = img_rgb.shape[1]

#经纬度(0,9)与图中心(0,0)偏差
deltaLat = 0;
deltaLon = -25;
pixel_x, pixel_y = latLon2Imagexy(0+deltaLat, 0+deltaLon, w,h)    
cv2.rectangle(img_rgb, (pixel_x,pixel_y), (pixel_x+5,pixel_y+5), (0,0,255), 2)

cv2.namedWindow('input_image', cv2.WINDOW_AUTOSIZE)
cv2.imshow('input_image', img_rgb)
cv2.waitKey(0)
cv2.destroyAllWindows()

关注
打赏
1660743125
查看更多评论
立即登录/注册

微信扫码登录

0.2518s