Exemplo n.º 1
0
def upload(name, img_url, tags):
    picture = Picture()
    picture.name = name
    picture.img_url = img_url
    picture.tags = tags
    picture.save()
    return picture
Exemplo n.º 2
0
 def insert_list_picture(self, mimg):
     try:
         for m in mimg:
             picture = Picture(img=m.get("data"), datatype=m.get("type"))
             session.add(picture)
         session.commit()
         return picture.id
     except Exception as ex:
         session.rollback()
         logger.warnning("插入picture表发生异常" + str(ex))
Exemplo n.º 3
0
    def _compute(self, img: np.ndarray) -> Picture:
        kps = []
        for x in range(0, img.shape[1], self.step_size):
            for y in range(0, img.shape[0], self.step_size):
                for s in self.scales:
                    kp = cv2.KeyPoint(x, y, s)
                    kps.append(kp)
        kps, des = self._sift.compute(img, kps)

        return Picture(img.shape[:2], kps, des)
Exemplo n.º 4
0
def once_load_all():
    for str_tag in available_tags:
        for i in range(1, 21):
            snum = str(i)
            while len(snum) < 5:
                snum = '0' + snum

            picture = Picture()
            picture.name = snum + '-' + str_tag
            picture.img_url = '/' + snum + '-' + str_tag + '.jpg'
            picture.tags = [str_tag]
            picture.likes = random.randint(0, 666)

            picture.save()