コード例 #1
0
ファイル: serversingletask.py プロジェクト: zytzjx/pyui
    def _savescrew(self, index, pt):
        #h = a-b if a>b else a+b
        screwLeft = int(self.screwW / 2)
        screwRight = int(self.screwW - screwLeft)
        screwTop = int(self.screwH / 2)
        screwBottom = int(self.screwH - screwTop)
        x = pt.x() - screwLeft if pt.x() - screwLeft > 0 else 0
        y = pt.y() - screwTop if pt.y() - screwTop > 0 else 0

        width, height = self._imagepixmapback.size

        #x1 = pt.x() + self.screwW if pt.x() + self.screwW < self._imagepixmapback.width() else self._imagepixmapback.width()
        #y1 = pt.y() + self.screwH if pt.y() + self.screwH < self._imagepixmapback.height() else self._imagepixmapback.height()
        x1 = pt.x() + screwRight if pt.x() + screwRight < width else width
        y1 = pt.y() + screwBottom if pt.y() + screwBottom < height else height

        #currentQRect = QRect(QPoint(x,y),QPoint(x1,y1))
        cropQPixmap = self._imagepixmapback.crop(
            (x, y, x1, y1))  #.copy(currentQRect)
        print("copy image")
        profilepath = self._profilepath
        filename = self._fileprechar(index) + str(self._indexscrew) + ".png"
        profilepath = os.path.join(profilepath, self._DirSub(index), filename)
        self._indexscrew += 1
        cropQPixmap.save(profilepath)
        screwpoint = profiledata.screw(self.profilename, filename, pt,
                                       QPoint(x, y), QPoint(x1, y1))
        #self.ProfilePoint.append(screwpoint)
        sinfo = profilepath + ", " + str(x) + ", " + str(x1) + ", " + str(
            y) + ", " + str(y1)
        print(sinfo)
        profiletxt = os.path.join(self._profilepath, self._DirSub(index),
                                  self.profilename + ".txt")
        self._append_new_line(profiletxt, sinfo)
コード例 #2
0
ファイル: servertask.py プロジェクト: zytzjx/jetsonUI
    def _savescrew(self, index, pt):
        #h = a-b if a>b else a+b
        x = pt.x() - self.screwW if pt.x() - self.screwW > 0 else 0
        y = pt.y() - self.screwH if pt.y() - self.screwH > 0 else 0

        x1 = pt.x(
        ) + self.screwW if pt.x() + self.screwW < self._imagepixmapback.width(
        ) else self._imagepixmapback.width()
        y1 = pt.y(
        ) + self.screwH if pt.y() + self.screwH < self._imagepixmapback.height(
        ) else self._imagepixmapback.height()

        currentQRect = QRect(QPoint(x, y), QPoint(x1, y1))
        cropQPixmap = self._imagepixmapback.copy(currentQRect)
        profilepath = self._profilepath
        filename = self._fileprechar(index) + str(self._indexscrew) + ".png"
        profilepath = os.path.join(profilepath, self._DirSub(index), filename)
        self._indexscrew += 1
        cropQPixmap.save(profilepath)
        screwpoint = profiledata.screw(self.profilename, filename, pt,
                                       QPoint(x, y), QPoint(x1, y1))
        #self.ProfilePoint.append(screwpoint)
        sinfo = profilepath + ", " + str(x) + ", " + str(x1) + ", " + str(
            y) + ", " + str(y1)
        profiletxt = os.path.join(self._profilepath, self._DirSub(index),
                                  self.profilename + ".txt")
        self._append_new_line(profiletxt, sinfo)
コード例 #3
0
ファイル: ImageLabel.py プロジェクト: zytzjx/jetsonUI
    def _savescrew(self, pt):
        screwLeft = int(myconstdef.screwWidth / 2)
        screwRight = int(myconstdef.screwWidth - screwLeft)
        screwTop = int(myconstdef.screwHeight / 2)
        screwBottom = int(myconstdef.screwHeight - screwTop)
        x = pt.x() - screwLeft if pt.x() - screwLeft > 0 else 0
        y = pt.y() - screwTop if pt.y() - screwTop > 0 else 0

        #x = pt.x()-self.screwW if pt.x()-self.screwW > 0 else 0
        #y = pt.y()-self.screwH if pt.y()-self.screwH > 0 else 0
        #x1 = pt.x() + self.screwW if pt.x() + self.screwW < self._imagepixmapback.width() else self._imagepixmapback.width()
        #y1 = pt.y() + self.screwH if pt.y() + self.screwH < self._imagepixmapback.height() else self._imagepixmapback.height()

        x1 = pt.x(
        ) + screwRight if pt.x() + screwRight < self._imagepixmapback.width(
        ) else self._imagepixmapback.width()
        y1 = pt.y(
        ) + screwBottom if pt.y() + screwBottom < self._imagepixmapback.height(
        ) else self._imagepixmapback.height()

        currentQRect = QRect(QPoint(x, y), QPoint(x1 - 1, y1 - 1))
        cropQPixmap = self._imagepixmapback.copy(currentQRect)
        profilepath = os.path.join(self.profilerootpath,
                                   self.profile.profilename)
        filename = self.fileprechar(self._camerapoisition) + str(
            self._indexscrew) + ".png"
        profilepath = os.path.join(profilepath,
                                   self.DirSub(self._camerapoisition),
                                   filename)
        cropQPixmap.save(profilepath)
        screwpoint = profiledata.screw(self.profile.profilename, filename, pt,
                                       QPoint(x, y), QPoint(x1, y1))
        self.ProfilePoint.append(screwpoint)
        sinfo = profilepath + ", " + str(x) + ", " + str(x1) + ", " + str(
            y) + ", " + str(y1)
        profiletxt = os.path.join(self.profilerootpath,
                                  self.profile.profilename,
                                  self.DirSub(self._camerapoisition),
                                  self.profile.profilename + ".txt")
        self.append_new_line(profiletxt, sinfo)
        self._indexscrew += 1