Ejemplo n.º 1
0
    def test_replaceOutlier(self):
        vd = VelocityDetector()

        actual = vd.replaceOutlier(29, 30, 300, 32, 33)

        # Assert
        self.assertEqual(actual, 31)
Ejemplo n.º 2
0
    def run(self):
        stepSize = self.step_size()
        print "using stepSize: " + str(stepSize)

        folderStruct = self.__folderStruct
        # velocityDetector = VelocityDetectorMultiThreaded(folderStruct)
        # videoStream = VideoStreamMultiThreaded(folderStruct.getVideoFilepath())

        if not folderStruct.fileExists(folderStruct.getRawDriftsFilepath()):
            self.__createNewRawFileWithHeaderRow(folderStruct)

        logger = Logger.openInAppendMode(folderStruct.getRawDriftsFilepath())

        rawDriftData = DriftRawData(folderStruct)
        maxFrameID = rawDriftData.maxFrameID()
        if maxFrameID > 1:
            startFrameID = maxFrameID + stepSize
        else:
            startFrameID = 5

        #cv2.startWindowThread()
        #imageWin = ImageWindow("mainWithRedDots", Point(700, 200))

        print("starting processing from frame", startFrameID)

        velocityDetector = VelocityDetector()
        videoStream = VideoStream(folderStruct.getVideoFilepath())
        velocityDetector.runLoop(startFrameID, stepSize, logger, videoStream)

        logger.closeFile()
Ejemplo n.º 3
0
    def test_getDriftsCount_twoValuesButVeryDifferent(self):

        vd = VelocityDetector()

        actual = vd.excludeOutliers([Vector(47, -408), Vector(-6, 41)])

        # Assert
        expected = [Vector(47, -408), Vector(-6, 41)]
        self.assertEqual(2, len(expected))
        self.assertEqual(2, len(actual))
        self.assertEqual(Vector.vectorArrayAsString(actual),
                         Vector.vectorArrayAsString(expected))
Ejemplo n.º 4
0
    def test_getDriftsCount_zeroZero(self):
        vd = VelocityDetector()

        actual = vd.excludeOutliers(
            [Vector(0, 0),
             Vector(-6, 41),
             Vector(-6, 41),
             Vector(-6, 41)])

        # Assert
        expected = [Vector(-6, 41), Vector(-6, 41), Vector(-6, 41)]
        self.assertEqual(Vector.vectorArrayAsString(actual),
                         Vector.vectorArrayAsString(expected))
Ejemplo n.º 5
0
    def ttest_getDriftsCount_outlierIsSymmetricalOverZero(self):
        vd = VelocityDetector()

        actual = vd.excludeOutliers(
            [Vector(0, 30), Vector(0, 30),
             Vector(0, -32)])

        # Assert
        expected = [Vector(0, 30), Vector(0, 30)]
        self.assertEqual(2, len(expected))
        self.assertEqual(2, len(actual))
        self.assertEqual(Vector.vectorArrayAsString(actual),
                         Vector.vectorArrayAsString(expected))
Ejemplo n.º 6
0
    def test_getDriftsCount_outlierIsMinimalTotal3Values(self):

        vd = VelocityDetector()

        actual = vd.excludeOutliers(
            [Vector(47, -408),
             Vector(-6, 41), Vector(-6, 41)])

        #Assert
        expected = [Vector(-6, 41), Vector(-6, 41)]
        self.assertEqual(2, len(expected))
        self.assertEqual(2, len(actual))
        self.assertEqual(Vector.vectorArrayAsString(actual),
                         Vector.vectorArrayAsString(expected))
Ejemplo n.º 7
0
    def __createNewRawFileWithHeaderRow(self, folderStruct):
        driftsFileHeaderRow = VelocityDetector.infoHeaders()

        logger = Logger.openInOverwriteMode(
            folderStruct.getRawDriftsFilepath())
        logger.writeToFile(driftsFileHeaderRow)
        logger.closeFile()
Ejemplo n.º 8
0
    def test_getDriftsCount_2outliersAboveMedian(self):
        vd = VelocityDetector()

        actual = vd.excludeOutliers([
            Vector(-5, 44),
            Vector(-5, 44),
            Vector(-5, 43),
            Vector(30, 526),
            Vector(30, 526)
        ])

        # Assert
        expected = [Vector(-5, 44), Vector(-5, 44), Vector(-5, 43)]
        self.assertEqual(3, len(expected))
        self.assertEqual(3, len(actual))
        self.assertEqual(Vector.vectorArrayAsString(actual),
                         Vector.vectorArrayAsString(expected))