Пример #1
0
    def run(self, vf):
        fr = FrameReader(vf)
        for frame in fr.next():
            hands = self._hd.run(frame)
            frameg = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            ch = self._cd.run(frameg, hands.left)

            self.__show(frame, hands.left.box, ch)
            cv2.waitKey(4)
Пример #2
0
 def run(self, vf, nframes):
     self._vf = vf
     fr = FrameReader(vf)
     n, c = nframes.pop(0), 0
     for frame in fr.next():
         c += 1
         if c == n:
             n = nframes.pop(0)
             hands = self._hd.run(frame)
             self.__dump(frame, hands.left, n)
             if not nframes:
                 break
Пример #3
0
    def run(self, vf):
        fr = FrameReader(vf)
        # assert os.path.exists(vf), '! video file...'
        # self._vc = cv2.VideoCapture(vf)
        state = State(self._nframe)
        strum = Strum()

        # while self._vc.isOpened():
        #    try:
        #        ret, frame = self._vc.read()
        #        assert frame.any()
        #    except AttributeError:
        #        break
        for frame in fr.next():

            frameg = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

            if state.reinit():
                hands = self._hd.run(frame)
                pts = hands.get_points()
                self._tracker = PointTracker(frameg, pts)
            else:
                pts = self._tracker.run(frameg)

            strum.append(pts)
            state.update()

            if self._display:
                self.__show_points(frame, pts)
                key = cv2.waitKey(1)
                if key == ord("q"):
                    break
                elif key == ord("s"):
                    hands.save("hands.pck")

        return strum