예제 #1
0
    def extract(self, path):

        capture = cv2.VideoCapture(path)

        # frame size
        # height = int(capture.get(cv.CV_CAP_PROP_FRAME_HEIGHT))
        # width = int(capture.get(cv.CV_CAP_PROP_FRAME_WIDTH))

        # video "size"
        framePerSecond = capture.get(cv.CV_CAP_PROP_FPS)
        frameCount = int(capture.get(cv.CV_CAP_PROP_FRAME_COUNT))
        # duration = frameCount / framePerSecond

        data = np.NaN * np.ones((frameCount, self.get_dimension()))

        while True:

            f = int(capture.get(cv.CV_CAP_PROP_POS_FRAMES))

            success, frame = capture.read()
            if not success:
                break

            data[f, :] = self.process_frame(frame)

        duration = step = 1. / framePerSecond
        sliding_window = SlidingWindow(start=0., duration=duration, step=step)
        return SlidingWindowFeature(data, sliding_window)
예제 #2
0
    def iterdiff(self, feature, focus):
        """(middle, difference) generator

        `middle`
        `difference`


        Parameters
        ----------
        feature : SlidingWindowFeature
            Pre-extracted features
        """

        sliding_window = SlidingWindow(duration=self.duration,
                                       step=self.step,
                                       start=focus.start,
                                       end=focus.end)

        for left in sliding_window:

            right = Segment(start=left.end + self.gap,
                            end=left.end + self.gap + self.duration)
            middle = .5 * (left.end + right.start)

            yield middle, self.diff(left, right, feature)
예제 #3
0
    def __init__(self, duration=0.025, step=0.01):

        super(LibrosaFeatureExtractor, self).__init__()

        self.duration = duration
        self.step = step

        self.sliding_window_ = SlidingWindow(start=-.5 * self.duration,
                                             duration=self.duration,
                                             step=self.step)
예제 #4
0
    def __init__(self, sample_rate=16000, duration=0.025, step=0.01):

        super(PySpeechFeaturesExtractor, self).__init__()

        self.sample_rate = sample_rate
        self.duration = duration
        self.step = step

        self.sliding_window_ = SlidingWindow(start=-.5 * self.duration,
                                             duration=self.duration,
                                             step=self.step)
예제 #5
0
    def __init__(self, sample_rate=16000, augmentation=None,
                 duration=0.025, step=0.01):

        super().__init__(sample_rate=sample_rate,
                         augmentation=augmentation)
        self.duration = duration
        self.step = step

        self.sliding_window_ = SlidingWindow(start=-.5*self.duration,
                                             duration=self.duration,
                                             step=self.step)
예제 #6
0
    def __init__(self, duration=0.025, step=0.010, stack=1):

        super(YaafeFeatureExtractor, self).__init__()

        self.duration = duration
        self.step = step
        self.stack = stack

        start = -0.5 * self.duration
        self.sliding_window_ = SlidingWindow(start=start,
                                             duration=self.duration,
                                             step=self.step)

        self.engine_ = yaafelib.Engine()