def test_getMiddleFrameIDOfBiggestGap_dot2LargestGapInTheBegining_middleFrameOfStartingGapIsReturned(
            self):
        df = pd.DataFrame()

        df = self.add_value_to_df(df, 10, RedDotsData.VALUE_ORIGIN_raw,
                                  RedDotsData.VALUE_ORIGIN_interpolate)
        df = self.add_value_to_df(
            df, 11, RedDotsData.VALUE_ORIGIN_raw,
            RedDotsData.VALUE_ORIGIN_interpolate)  # largest gap here
        df = self.add_value_to_df(df, 12, RedDotsData.VALUE_ORIGIN_raw,
                                  RedDotsData.VALUE_ORIGIN_interpolate)
        df = self.add_value_to_df(df, 13, RedDotsData.VALUE_ORIGIN_raw,
                                  RedDotsData.VALUE_ORIGIN_raw)
        df = self.add_value_to_df(df, 14, RedDotsData.VALUE_ORIGIN_raw,
                                  RedDotsData.VALUE_ORIGIN_interpolate)
        df = self.add_value_to_df(df, 15, RedDotsData.VALUE_ORIGIN_raw,
                                  RedDotsData.VALUE_ORIGIN_raw)

        rdData = RedDotsData.createWithRedDotsManualData(None, None)
        rdData.getPandasDF = MagicMock(return_value=df)

        # Exercise
        frame, gap = rdData.getMiddleFrameIDOfBiggestGap()

        # Assert
        self.assertEqual(11, frame)
        self.assertEqual(3, gap)
    def test_getMiddleFrameIDOfBiggestGap_originsOfDot2AreRawAndManual_middleFrameOfSecondGapIsReturned(
            self):
        df = pd.DataFrame()

        df = self.add_value_to_df(df, 10, RedDotsData.VALUE_ORIGIN_raw,
                                  RedDotsData.VALUE_ORIGIN_raw)

        df = self.add_value_to_df(df, 11, RedDotsData.VALUE_ORIGIN_raw,
                                  RedDotsData.VALUE_ORIGIN_interpolate)

        df = self.add_value_to_df(df, 12, RedDotsData.VALUE_ORIGIN_raw,
                                  RedDotsData.VALUE_ORIGIN_manual)

        df = self.add_value_to_df(df, 13, RedDotsData.VALUE_ORIGIN_raw,
                                  RedDotsData.VALUE_ORIGIN_interpolate)
        df = self.add_value_to_df(
            df, 14, RedDotsData.VALUE_ORIGIN_raw,
            RedDotsData.VALUE_ORIGIN_interpolate)  #Largest Gap here

        df = self.add_value_to_df(df, 15, RedDotsData.VALUE_ORIGIN_raw,
                                  RedDotsData.VALUE_ORIGIN_raw)

        rdData = RedDotsData.createWithRedDotsManualData(None, None)
        rdData.getPandasDF = MagicMock(return_value=df)

        # Exercise
        frame, gap = rdData.getMiddleFrameIDOfBiggestGap()

        # Assert
        self.assertEqual(13, frame)
        self.assertEqual(3, gap)
    def regenerateSeefloor(self):
        driftsStepSize = self.step_size()
        print "Using driftsStepSize: " + str(driftsStepSize)

        #TODO: extract logic in few rows into a "regenerate drafts" module/class
        print("regenerating/interpolating Drafts")
        manualDrifts = DriftManualData.createFromFile(self.__folderStruct)

        rawDrifts = DriftRawData(self.__folderStruct)
        df = rawDrifts.interpolate(manualDrifts, driftsStepSize)

        drifts = DriftData.createFromFolderStruct(self.__folderStruct)
        drifts.setDF(df)
        drifts.saveToFile(self.__folderStruct.getDriftsFilepath())

        print("regenerating/interpolating RedDots")
        rdd = RedDotsData.createFromFolderStruct(self.__folderStruct)
        rdd.saveInterpolatedDFToFile(drifts.minFrameID(),
                                     drifts.maxFrameID() + 1)

        print("regenerating SeeFloor")
        sf = SeeFloor.createFromFolderStruct(self.__folderStruct)
        sf.saveToFile()

        print("regenerating crabs_on_seefloor")
        crabs = CrabsData(self.__folderStruct)
        crabs_on_seefloor_df = crabs.generate_crabs_on_seefloor(sf)
        crabs_on_seefloor_df.save_file_csv(
            self.__folderStruct.getCrabsOnSeefloorFilepath())
    def test_getMiddleFrameIDOfBiggestGap_allRedDotsFileAreEmpty(self):
        df = pd.DataFrame()

        rdData = RedDotsData.createWithRedDotsManualData(None, None)
        rdData.getPandasDF = MagicMock(return_value=df)

        #Exercise
        result = rdData.getMiddleFrameIDOfBiggestGap()

        #Assert
        self.assertIsNone(result)
    def regenerateGraphs(self):
        print("drawign graphs for RedDots")
        rdd = RedDotsData.createFromFolderStruct(self.__folderStruct)
        rdd.saveGraphOfAngle()
        rdd.saveGraphOfDistance()

        print("drawing graphs for SeeFloor")
        sf = SeeFloor.createFromFolderStruct(self.__folderStruct)
        sf.saveGraphSeefloorY()
        sf.saveGraphSeefloorX()
        sf.saveGraphSeefloorXY()
        sf.saveGraphDriftsMillimeters()
        sf.saveGraphDriftsPixels()
示例#6
0
    def createFromFolderStruct(folderStruct):
        # type: (FolderStructure) -> SeeFloorNoBadBlocks

        driftsData = DriftData.createFromFolderStruct(folderStruct)
        redDotsData = RedDotsData.createFromFolderStruct(folderStruct)

        filepath = folderStruct.getSeefloorFilepath()
        if folderStruct.fileExists(filepath):
            #df = pd.read_csv(filepath, delimiter="\t", na_values="(null)")
            df = PandasWrapper.readDataFrameFromCSV(filepath)
        else:
            df = None
        newObj = SeeFloorNoBadBlocks(driftsData, redDotsData, folderStruct, df)
        return newObj
示例#7
0
    def createFromFolderStruct(folderStruct):
        # type: (FolderStructure) -> SeeFloor

        driftsData = DriftData.createFromFolderStruct(folderStruct)
        badFramesData = BadFramesData.createFromFolderStruct(folderStruct)
        redDotsData = RedDotsData.createFromFolderStruct(folderStruct)

        filepath = folderStruct.getSeefloorFilepath()
        if folderStruct.fileExists(filepath):
            df = PandasWrapper.readDataFrameFromCSV(filepath)
        else:
            df = None
        newObj = SeeFloor(driftsData, badFramesData, redDotsData, folderStruct,
                          df)
        return newObj
示例#8
0
    def __init__(self, imageWin, folderStruct, videoStream, driftData):
        # type: (ImageWindow, FolderStructure, VideoStream, DriftData) -> ScientistUI

        self.__zoom = False
        self.__markingDrift = False
        self.__contrastLevel = self.CONTRAST_NORMAL
        self.__imageWin = imageWin
        self.__folderStruct = folderStruct
        self.__videoStream = videoStream

        self.__driftData = driftData
        self.__badFramesData = BadFramesData.createFromFolderStruct(
            folderStruct)
        self.__redDotsData = RedDotsData.createFromFolderStruct(folderStruct)

        self.__seeFloor = SeeFloor.createFromFolderStruct(folderStruct)
        self.__seeFloorNoBadBlocks = SeeFloorNoBadBlocks.createFromFolderStruct(
            folderStruct)

        self.__crabData = CrabsData(self.__folderStruct)
        self.__redDotsUI = RedDotsUI(self.__videoStream)
        self.__markersData = MarkersData(folderStruct)
        self.__marker_id = "0"
示例#9
0
 def refreshItself(self):
     self.__driftData = DriftData.createFromFolderStruct(
         self.__folderStruct)
     self.__redDotsData = RedDotsData.createFromFolderStruct(
         self.__folderStruct)
     self.saveToFile()
    # rootDir = "C:/workspaces/AnjutkaVideo/2020-Kara/2020.09.13_6916"
    # videoFileName = "V20200913_204908_001"

    rootDir = "C:/workspaces/AnjutkaVideo/2020-Kara/2020.09.16_6922"
    videoFileName = "R_20200916_194953_20200916_195355"

    folderStruct = FolderStructure(rootDir, videoFileName)

StreamToLogger(folderStruct.getLogFilepath())
print("Starting Manually Improving RedDots")

timer = MyTimer("Starting manuallyImproveRedDots")
videoStream = VideoStream(folderStruct.getVideoFilepath())
timer.lap("Initialized VideoStream")

redDotsData = RedDotsData.createFromFolderStruct(folderStruct)
timer.lap("Initialized redDotsData")

interpolator = InterpolateController(folderStruct)
interpolator.regenerateSeefloor()
timer.lap("Interpolated SeeFloor")

redDotsUI = RedDotsUI(videoStream)
timer.lap("Initialized RedDotsUI")

ui = FillRedDotsGapsController(redDotsData, redDotsUI)
timer.lap("Initialized FillRedDotsGapsController")
ui.showUI()

cv2.destroyAllWindows()
timer.lap("Finished session")