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()
python-opencv在世界地图图片上标记经纬度点
关注
打赏