当前位置: 首页 > news >正文

河南省网站建设_网站建设公司_云服务器_seo优化

济南 外贸网站建设,wordpress the ken,软件开发外包交易平台,物业管理系统英文一.横平竖直”进行连线 解法1.将一些坐标点按照x相等,y相等连起来 解法1.根据 x或y总有一个相等的,用np.sum来找出和为1的点,然后在连起来,存在重复连线的问题. import numpy as npcoord np.array([[10, 60],[10, 20],[20, 20],[40, 40],[40, 60],[20, 40]])img np.zeros(…一.横平竖直”进行连线 解法1.将一些坐标点按照x相等,y相等连起来 解法1.根据 x或y总有一个相等的,用np.sum来找出和为1的点,然后在连起来,存在重复连线的问题. import numpy as npcoord np.array([[10, 60],[10, 20],[20, 20],[40, 40],[40, 60],[20, 40]])img np.zeros((100, 100))h, w coord.shapefor i in range(h):index np.sum(np.array(coord[i]).reshape(-1, 2) coord, axis-1)y np.where(index 1)for point in coord[y]:cv2.line(img, (coord[i][0], coord[i][1]), (point[0], point[1]), color(255,255,255), thickness3)cv2.imshow(img, img)cv2.waitKey(0) 解法2.先连x相等,在连y相等的 def coord_sort_ind(x,y):#按照x,y来排序ind np.lexsort((y.tolist(), x.tolist())) # Sort by x, then by yreturn ind def simple_line_():import numpy as npcoord np.array([[10, 60],[10, 20],[20, 20],[40, 40],[40, 60],[20, 40]])# 按照先X后Y排的序ind coord_sort_ind(coord[:, 0], coord[:, 1])coord_Xcoord[ind]print(coord_X)# # 按照先Y后X排的序ind coord_sort_ind(coord[:, 1], coord[:, 0])print(ind)coord_Y coord[ind]print(coord_Y)img np.zeros((100, 100))h, w coord.shape# x想等的连接for i in range(0, h, 2):cv2.line(img, (coord_X[i][0], coord_X[i][1]), (coord_X[i 1][0], coord_X[i 1][1]), color(255, 255, 255),thickness3)# y想等的连接cv2.line(img, (coord_Y[i][0], coord_Y[i][1]), (coord_Y[i 1][0], coord_Y[i 1][1]), color(255, 255, 255),thickness3)cv2.imshow(img, img)cv2.waitKey(0) 二.将相邻框进行合并 目前解法是将两个相邻的框合并得到大框在继续合并算法还需要优化成一次性合并成功 import numpy as np import cv2 def get_cluster(points,x_dis,y1_dis):points points[points[:, 0].argsort()]x1,y1,x2,y2points[:,0],points[:,1],points[:,-2],points[:,-1]#只对竖值框进行合并操作pointspoints[np.where(x2-x1y2-y1)[0]]# pointspoints[:13]# print(points:,points)# # debug to show# for i,point in enumerate(points):# font cv2.FONT_HERSHEY_SIMPLEX# cv2.putText(img, str(i), (point[0], point[1]), font, 2.5, (255, 255, 255), 2)# cv2.rectangle(img, (point[0], point[1]), (point[-2], point[-1]), color(255, 255, 255), thickness3)# cv2.imwrite(img_rect.jpg, img)# print(points.shape[0])cluster []while points.shape[0]:temp[]# print(points:,points)#x1-x2index_x np.where(abs(points[0][-2]-points[:, 0]) x_dis)[0]# print(index_x:,index_x)# if len(index_x):# #y1-y1index_y1 np.where(abs(points[0][1]-points[:, 1]) y1_dis)[0]# print(index_y: ,index_y1)#y2-y2hindex_y2 np.where(abs(points[0][-1]-points[:, -1]) (points[:, -1]-points[:, 1]))[0]# print(index_y2:,index_y2)# common_index[i for i in index_x if i in index_y]common_index list(set(index_x) set(index_y1) set(index_y2))# print(common_index:,common_index)# print(common_index:,common_index)if len(common_index):temp.append(points[0])temp.extend(points[common_index])points np.delete(points, objcommon_index[0], axis0)else:temp.append(points[0])pointspoints[1:]cluster.append(temp)# # print(points)# print(cluster:,cluster)# print(len(cluster))# for i in range(len(cluster)):# every_clusternp.array(cluster[i]).reshape(-1,4)# print(every_cluster:,every_cluster)# for point in every_cluster:# font cv2.FONT_HERSHEY_SIMPLEX# cv2.putText(img, str(i), (point[0],point[1]), font, 2, (255, 255, 255), 2)# cv2.rectangle(img,(point[0],point[1]),(point[-2],point[-1]),color(255,255,255),thickness3)# cv2.imwrite(img_rect_clu.jpg,img)return cluster def fix_bbox_point(cluster):points[]for i,evry_cluster in enumerate(cluster):every_cluster np.array(cluster[i]).reshape(-1, 4)x1,y1,x2,y2np.min(every_cluster[:,0]),np.min(every_cluster[:,1])\,np.max(every_cluster[:,-2]),np.max(every_cluster[:,-1])points.append([x1,y1,x2,y2])return np.array(points)def union_bboxs(points):cluster_first get_cluster(points, x_dis50, y1_dis300)# print(cluster)# print(len(cluster_first))first_bboxs fix_bbox_point(cluster_first)cluster_second get_cluster(first_bboxs, x_dis50, y1_dis300)# print(cluster)# print(len(cluster_second))second_bboxs fix_bbox_point(cluster_second)cluster_third get_cluster(second_bboxs, x_dis50, y1_dis400)# print(cluster)# print(len(cluster_third))third_bboxs fix_bbox_point(cluster_third)return third_bboxsif __name__ __main__:# points np.array([[1264, 1480, 1346, 1790],# [2278, 1873, 2380, 2542],# [3209, 2279, 3286, 2599],# [2195, 3468, 2277, 3772],# [844, 1087, 924, 1399],# [92, 876, 181, 1327],# [951, 306, 1033, 596],# [1652, 299, 1729, 604],# [2196, 1957, 2270, 2535],# [916, 4251, 994, 4563],# [1131, 1915, 1214, 2505],# [1042, 265, 1116, 532],# [2124, 2036, 2195, 2603],# [934, 1054, 1003, 1258],# [1522, 3561, 1585, 4086],# [999, 4220, 1068, 4422],# [2404, 586, 2516, 1209],# [1452, 3618, 1528, 4151],# [1354, 1449, 1425, 1655],# [1583, 3532, 1683, 4109],# [1207, 1525, 1256, 1792],# [2144, 3511, 2191, 3779],# [3162, 2319, 3205, 2549],# [787, 1124, 837, 1395],# [896, 339, 944, 606],# [1741, 260, 1813, 467],# [219, 3230, 330, 3785],# [1424, 2675, 1506, 2818],# [2528, 538, 2714, 1709],# [2287, 664, 2394, 1596],# [231, 1703, 428, 2598],# [287, 248, 473, 1638],# [186, 280, 265, 1025],# [1670, 3480, 1756, 3852],# [1754, 2277, 1836, 2431],# [3284, 2241, 3360, 2455],# [2823, 1662, 3163, 1730],# [2897, 2852, 3285, 2946],# [2972, 2700, 3049, 2790]])pointsnp.array([[700,1888, 789, 2199],[1918, 1487, 2000, 1798],[1045, 683, 1129, 995],[2867, 279, 2975, 958],[1929, 3088, 2012, 3393],[1006, 272, 1087, 583],[2476, 3089, 2560, 3396],[ 820, 3094, 904, 3406],[2532, 3499, 2616, 3810],[1335, 1080, 1411, 1378],[2204, 2283, 2288, 2587],[1138, 644, 1213, 975],[1611, 1884, 1695, 2196],[2823, 2283, 2906, 2603],[ 773, 2286, 853, 2606],[1562, 262, 1642, 585],[2458, 1883, 2540, 2196],[1749, 3491, 1831, 3803],[ 634, 1266, 715, 1785],[1646, 236, 1722, 515],[ 988, 3889, 1060, 4221],[ 725, 1167, 836, 1743],[2592, 455, 2703, 1365],[2721, 375, 2853, 1289],[ 846, 1104, 938, 1481],[ 857, 2255, 935, 2583],[1419, 1043, 1494, 1316],[1707, 2310, 1814, 3001],[1327, 3046, 1405, 3387],[1244, 3081, 1327, 3404],[1814, 2264, 1903, 2656],[2543, 1844, 2617, 2053],[2845, 3894, 2918, 4215],[2147, 2330, 2197, 2559],[2402, 1922, 2452, 2198],[1058, 3860, 1122, 4065],[3308, 1779, 3396, 2183],[2293, 2248, 2370, 2454],[1857, 1531, 1908, 1760],[1697, 3535, 1745, 3803],[1189, 3133, 1236, 3367],[2419, 3135, 2468, 3360],[1873, 3124, 1923, 3400],[ 988, 719, 1038, 995],[2480, 3539, 2529, 3809],[2017, 3057, 2083, 3278],[2095, 2368, 2138, 2598],[ 766, 3135, 815, 3409],[1559, 1964, 1607, 2160],[1504, 1966, 1550, 2202],[2913, 2248, 2996, 2455],[ 766, 4318, 838, 4580],[1802, 1571, 1848, 1797],[ 374, 801, 457, 1032],[ 637, 1926, 690, 2164],[1636, 2441, 1708, 2998],[ 964, 353, 1012, 549],[3243, 290, 3389, 1431],[1869, 3963, 1952, 4206],[3131, 2120, 3215, 2800],[2858, 4314, 2934, 4593],[2802, 3939, 2844, 4189],[ 484, 716, 570, 955],[2913, 3860, 2988, 4126],[ 330, 645, 566, 717]])# print(points[30:33])# points points[12:21]img np.zeros((5000, 4000))cluster_firstget_cluster(points,x_dis50,y1_dis300)print(first cluster)print(len(cluster_first))first_bboxsfix_bbox_point(cluster_first)print(second cluster)cluster_second get_cluster(first_bboxs, x_dis50, y1_dis400)print(len(cluster_second))second_bboxs fix_bbox_point(cluster_second)# #debug# for i,point in enumerate(first_bboxs):# font cv2.FONT_HERSHEY_SIMPLEX# cv2.putText(img, str(i), (point[0], point[1]), font, 2.5, (255, 255, 255), 2)# cv2.rectangle(img, (point[0], point[1]), (point[-2], point[-1]), color(255, 255, 255), thickness3)# cv2.imwrite(img_rect_first_bbx.jpg, img)### # debug# for i, point in enumerate(second_bboxs):# font cv2.FONT_HERSHEY_SIMPLEX# cv2.putText(img, str(i), (point[0], point[1]), font, 2.5, (255, 255, 255), 2)# cv2.rectangle(img, (point[0], point[1]), (point[-2], point[-1]), color(255, 255, 255), thickness3)# cv2.imwrite(img_rect_second_bbx.jpg, img)cluster_third get_cluster(second_bboxs, x_dis50, y1_dis400)print(cluster)print(len(cluster_third))third_bboxs fix_bbox_point(cluster_third)# debugfor i, point in enumerate(third_bboxs):font cv2.FONT_HERSHEY_SIMPLEXcv2.putText(img, str(i), (point[0], point[1]), font, 2.5, (255, 255, 255), 2)cv2.rectangle(img, (point[0], point[1]), (point[-2], point[-1]), color(255, 255, 255), thickness3)cv2.imwrite(img_rect_third_bbx.jpg, img)合并前  合并后
http://www.ihoyoo.com/news/85155.html

相关文章:

  • sem网站做推广江苏微信网站建设
  • python制作网站开发saas系统
  • 全网vip影视自助建站系统百度搜索关键词规则
  • 建设快照网站高端网站建设 恩愉科技
  • 乡镇网站建设自查报告手机怎么创建网址链接
  • 高端网站建设模板seo软件
  • 网站可以做怀孕单吗做网站的人是什么职位
  • 专业的网站制作正规公司什么专业就业前景好
  • 前端网站做多语言国家高新技术企业难吗
  • 南阳网站seo顾问寻找建设网站客户
  • 网站建站时间查询重庆建设网站公司简介
  • 百度做网站的公司学做网站课程
  • 做网站页面该建多大的画布平面设计公司怎么找客户
  • 怀化百度整站优化服务价格低的英文
  • 网站建设赚取流量费宜昌市建设局网站
  • 广西建设网电子证件查询百度关键字优化
  • 个人+网站可以做导航吗哪个网站查企业信息免费
  • 网站收费标准泰兴网站建设
  • 黄冈公司网站推广软件首选wordpress英文版修改栏
  • 网站建设方案实施宝山网站建设制作
  • 长春专业网站制作如何判断网站程序使用asp还是php
  • vps做网站空间国内网站设计经典案例
  • 专业黑帽seo推广seo管理与优化期末试题
  • 网站开发技术视频wordpress pot 翻译
  • 专业做视频的网站有哪些内容软件开发工具包英文
  • 网站页面设计费用高端炫酷h5怎么制作
  • 网站 做购物车2016年两学一做教育网站
  • 做网站 公司免费网站建站排名
  • 亮点云建站如何注册咨询公司
  • 美丽说网站案例分析东莞市专注网站建设