opencv画坐标系(便于与世界坐标转化)、检测色块(目标物画坐标系(便于与世界坐标转化)、检测色块(目标物
体)体)
① 根据图像尺寸遍历出所有节点;
② 根据行列个数得出边界节点;
③ 画点、两点连线;
④ 将视野中心点特殊标记;
⑤ 实现当色块位于网格节点或者视野中心点时,显示坐标值在图像上;
⑥ 可调整网格间距,10、20或者40等可以被尺寸值整除的数
from collections import deque
import numpy as np
import cv2
import time
class Painter(object):
def __init__(self,img,start_point=(20,20)):
self.horizons_center = (0,0)
self.point_list = [] self.line_list = [] self.get_point_line(img,start_point)
def add_text(self,img,text,point,size=0.5,color=(0,0,255)):
cv2.putText(img,text,point,cv2.FONT_HERSHEY_COMPLEX,size,color,1)
return img
def draw_a_circle(self,img,point,radius=3,color=(255,0,0),thickness=2):
img = self.draw_a_point(img,point,radius,color,thickness)
return img
def draw_a_point(self,img,point,radius=3,color=(255,0,0),thickness=-4):
cv2.circle(img, point, radius, color, thickness)
return img
def draw_all_point(self,img):
for point in self.point_list: