Exemplo n.º 1
0
    def save_contour(self):
        # 判断鼠标点击是否在原轮廓,
        # mesure = cv.pointPolygonTest(self.cnt, (self.x_clicked, self.y_clicked), measureDist=False)
        # # 不在,说明原轮廓处理完毕,可以将其所包含的区域填充黑色
        # if mesure != 1:
        #     # 将self.image 修改了
        # 获取色调范围列表
        self.image = cv.drawContours(self.image, [self.cnt], 0, (0, 0, 0), -1)
        contour_year = int(self.editYearInfo.text())
        contour_name = self.editcontourName.text()
        contour_points_arr = self.cnt

        print(contour_points_arr.shape)

        # narray 转换为二进制
        contour_points = dumps(contour_points_arr)
        print(len(contour_points))
        contour_area = float(self.editContourArea.text())
        contour_perimeter = float(self.editContourPerimeter.text())
        contour_centre = self.editContourCentre.text()

        mysqlConn = MySqlConn()
        mysqlConn.contour_insert(contour_year, contour_name, contour_points,
                                 contour_area, contour_perimeter,
                                 contour_centre)
Exemplo n.º 2
0
 def save_site(self):
     site_year = int(self.editYearInfo.text())
     site_name = self.editSiteName.text()
     site_contour = self.site_ContourName.text()
     site_slpoe = float(self.siteSlope)
     site_lenth = float(self.siteLenth)
     site_centre = str(self.site_centre)
     mysqlConn = MySqlConn()
     mysqlConn.site_insert(site_year, site_name, site_contour, site_slpoe,
                           site_lenth, site_centre)
Exemplo n.º 3
0
    def loadImage(self):
        fname, _ = QFileDialog.getOpenFileName(
            self, "选择地图", 'D:\\0Kind of File\\Map\\中国历史地图第三版',
            'Image files(*.jpg *.gif *.png)')
        # fi = QtCott
        # re.QFileInfo(fname) 获取fname的信息
        if not fname:
            pass
        else:
            # 从新加载图片,清空变量
            # 存储加载的图片和抽取的轮廓
            self.image = array([])
            self.cnt = array([])

            # 鼠标点击坐标和鼠标释放坐标
            self.x_clicked = 0
            self.y_clicked = 0
            self.x_released = 0
            self.y_released = 0

            self.image = cv.imdecode(fromfile(fname, dtype=uint8), -1)
            year_img = self.image[0:100, 0:500]
            cut_bila = cv.bilateralFilter(year_img,
                                          d=0,
                                          sigmaColor=75,
                                          sigmaSpace=15)
            cv.imwrite('image/year.jpg', cut_bila)
            year_str = self.baidu_api.picture2text('image/year.jpg')
            year_int = findall(r'\d+', year_str)
            if '前' in year_str:
                map_year = -int(year_int[0])
            else:
                map_year = int(year_int[0])
            myimage = open(fname, 'rb')
            map_img = myimage.read()
            mysqlConn = MySqlConn()
            self.editYearInfo.setText(str(map_year))
            # print(len(map_img))
            mysqlConn.img_insert(map_year=map_year, map_img=map_img)
            image_height, image_width, image_depth = self.image.shape
            QIm = cv.cvtColor(self.image, cv.COLOR_BGR2RGB)
            QIm = QImage(QIm.data, image_width, image_height,
                         image_width * image_depth, QImage.Format_RGB888)
            self.viewer.setPhoto(QPixmap.fromImage(QIm))
            self.viewer.fitInView()
Exemplo n.º 4
0
    def save_rele(self):
        contour_year = int(self.editYearInfo.text())
        contour_name = contour_year+self.editcontourName.text()

        contour_year_1 = int(self.editYearInfo_1.text())
        contour_name_1 = contour_year_1+self.editcontourName_1.text()

        mysqlConn = MySqlConn()
        mysqlConn.rele_insert(contour_year,contour_name,contour_name_1,"")
        mysqlConn.rele_insert(contour_year_1,contour_name_1,"",contour_name)
Exemplo n.º 5
0
from mysql_conn import MySqlConn
from pickle import dumps, loads

#mysqlConn = MySqlConn()
# contour_year=936
# contour_name="楚"
# ret=mysqlConn.select_contour_info(contour_year,contour_name)
#
# contour=ret[0]
# print(contour[1])
# print(type(contour[2]))
# point_list=loads(contour[2])
# print(point_list)
# ret = mysqlConn.select_all_contour_info()
#mysqlConn.delete_contour_point(229,"孙吴")
mysqlConn1 = MySqlConn()
ret = mysqlConn1.select_contour_info(229, "羌胡")
points = ret[0][2]
points_list = loads(points).tolist()
print(points_list)
temp_list = []
for item in points_list:
    point = item[0]
    temp_list.append(point)
print(temp_list)
for temp in temp_list:
    point_x = temp[0]
    point_y = temp[1]
    mysqlConn = MySqlConn()
    mysqlConn.insert_contour_point(229, "羌胡", point_x, point_y)
# print(len(ret))