def runMotionCudaBeliefPropRefineFromInputFloResults(inFloFile): # retrieve the 'refining parameters' from the input flo file... refiningParams = retrieveParamsRefineResults.retParamsToRefineResults( inFloFile) # set up the environment variables in order to run CUDA belief propagation setupCudaBeliefProp.initToRunCudaBeliefProp() # generate the input parameters to run CUDA belief propagation inParamCudaBeliefProp = inputParamsMultImages.InputParamsMultImages() # adjust the input parameters based on the 'flo' input... inParamCudaBeliefProp.adjustParticParams( refiningParams[ retrieveParamsRefineResultsConsts.START_MOVE_INC_X_PARAM_KEY], refiningParams[ retrieveParamsRefineResultsConsts.START_MOVE_INC_Y_PARAM_KEY], refiningParams[retrieveParamsRefineResultsConsts.MIN_X_MOVE_PARAM_KEY], refiningParams[retrieveParamsRefineResultsConsts.MAX_X_MOVE_PARAM_KEY], refiningParams[retrieveParamsRefineResultsConsts.MIN_Y_MOVE_PARAM_KEY], refiningParams[retrieveParamsRefineResultsConsts.MAX_Y_MOVE_PARAM_KEY]) # generate the header file for the current set of parameters defined in runMotionBeliefPropConsts.py genHeaderFile.genCurrHeaderFile() # clean and make cuda belief propagation cleanAndMakeRunBeliefPropMotion.cleanMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) cleanAndMakeRunBeliefPropMotion.makeMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) # run cuda belief propagation exeBeliefPropMotion.runBeliefPropMotion(inParamCudaBeliefProp)
def runMotionCudaBeliefProp(): # set up the environment variables in order to run CUDA belief propagation setupCudaBeliefProp.initToRunCudaBeliefProp() # generate the input parameters to run CUDA belief propagation inParamCudaBeliefProp = inputParamsRetrieveDataFromFloFiles.InputParamsRetrieveDataFromFloFiles( ) # clean and make cuda belief propagation cleanAndMakeRunBeliefPropMotion.cleanMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) cleanAndMakeRunBeliefPropMotion.makeMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) # run cuda belief propagation exeBeliefPropMotion.runBeliefPropMotion(inParamCudaBeliefProp)
def runMotionCudaBeliefProp(): # set up the environment variables in order to run CUDA belief propagation setupCudaBeliefProp.initToRunCudaBeliefProp() # generate the input parameters to run CUDA belief propagation inParamCudaBeliefProp = inputParams.InputParams() # generate the header file for the current set of parameters defined in runMotionBeliefPropConsts.py genHeaderFile.genCurrHeaderFile() # clean and make cuda belief propagation cleanAndMakeRunBeliefPropMotion.cleanMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) cleanAndMakeRunBeliefPropMotion.makeMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) # run cuda belief propagation exeBeliefPropMotion.runBeliefPropMotion(inParamCudaBeliefProp)
def runMotionBeliefPropTakePrevMotionAndNoExpMotionResultIntoAccount(): # set up the environment variables in order to run CUDA belief propagation setupCudaBeliefProp.initToRunCudaBeliefProp() # retrieve the 'refining parameters' from the input flo file... refiningParams = retrieveParamsRefineResults.retParamsToRefineResults( runMotionBeliefPropGivenExpMotionInputs.FILE_PATH_EXPECTED_MOTION) # generate the input parameters to run CUDA belief propagation inParamCudaBeliefProp = inputParamsGivenExpMotion.InputParamsGivenExpMotion( ) # adjust the input parameters based on the 'flo' input... inParamCudaBeliefProp.adjustParticParams( refiningParams[ retrieveParamsRefineResultsConsts.START_MOVE_INC_X_PARAM_KEY], refiningParams[ retrieveParamsRefineResultsConsts.START_MOVE_INC_Y_PARAM_KEY], refiningParams[retrieveParamsRefineResultsConsts.MIN_X_MOVE_PARAM_KEY], refiningParams[retrieveParamsRefineResultsConsts.MAX_X_MOVE_PARAM_KEY], refiningParams[retrieveParamsRefineResultsConsts.MIN_Y_MOVE_PARAM_KEY], refiningParams[retrieveParamsRefineResultsConsts.MAX_Y_MOVE_PARAM_KEY]) # adjust the output 'movement' image inParamCudaBeliefProp.adjustOutputMovementImage( runMotionBeliefPropRefineFromFloResultsAndUseNoExpMoveFloResultConsts. FILE_PATH_OUTPUT_IMAGE_NO_ACCOUNT_EXP_MOTION) # adjust the input parameter to save the flo motion... inParamCudaBeliefProp.adjustOutputMotionFloFile( runMotionBeliefPropRefineFromFloResultsAndUseNoExpMoveFloResultConsts. PATH_FLO_FILE_EXP_MOTION_NOT_USED) # adjust the parameter to not take expected motion into account... inParamCudaBeliefProp.adjustTakeExpMotionWeight( runMotionBeliefPropRefineFromFloResultsAndUseNoExpMoveFloResultConsts. WEIGHT_EXP_MOTION_WHEN_NOT_USED) # adjust the smoothing sigma inParamCudaBeliefProp.adjustSmoothingSigmaInputImages( runMotionBeliefPropRefineFromFloResultsAndUseNoExpMoveFloResultConsts. SMOOTHING_SIGMA_WHEN_EXP_MOTION_NOT_USED) # generate the header file for the current set of parameters defined in runMotionBeliefPropConsts.py genHeaderFile.genCurrHeaderFile() # clean and make cuda belief propagation cleanAndMakeRunBeliefPropMotion.cleanMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) cleanAndMakeRunBeliefPropMotion.makeMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) # run cuda belief propagation exeBeliefPropMotion.runBeliefPropMotion(inParamCudaBeliefProp) # retrieve the motion data of the 'rough results' motionDataRoughResults = motionData.MotionData() motionDataRoughResults.readMotionFromFloFile( runMotionBeliefPropGivenExpMotionInputs.FILE_PATH_EXPECTED_MOTION) # retrieve the motion data of the results that don't use the expected motion motionDontUseExpMotion = motionData.MotionData() motionDontUseExpMotion.readMotionFromFloFile( runMotionBeliefPropRefineFromFloResultsAndUseNoExpMoveFloResultConsts. PATH_FLO_FILE_EXP_MOTION_NOT_USED) # merge the two results motionDataRoughResults.mergeMotionData(motionDontUseExpMotion) # save the merged results motionDataRoughResults.saveMotionToFloFile( runMotionBeliefPropRefineFromFloResultsAndUseNoExpMoveFloResultConsts. PATH_FLO_FILE_MERGED_RESULT_ACCOUNT_BOTH_MOTIONS) # adjust the parameter to use the merged results inParamCudaBeliefProp.adjustInputFloFile( runMotionBeliefPropRefineFromFloResultsAndUseNoExpMoveFloResultConsts. PATH_FLO_FILE_MERGED_RESULT_ACCOUNT_BOTH_MOTIONS) # adjust the output 'movement' image inParamCudaBeliefProp.adjustOutputMovementImage( runMotionBeliefPropGivenExpMotionInputs. FILE_PATH_SAVE_RESULTING_MOTION_IMAGE) # adjust the parameter to take expected motion into account... inParamCudaBeliefProp.adjustTakeExpMotionWeight( runMotionBeliefPropGivenExpMotionInputs. EST_MOVEMENT_WEIGHT_BP_MOTION_TEST) # adjust the parameter for the flo file of the output motion inParamCudaBeliefProp.adjustOutputMotionFloFile( runMotionBeliefPropGivenExpMotionInputs. FILE_PATH_SAVED_MOVEMENT_DATA_FLO_FORMAT) # adjust the smoothing sigma inParamCudaBeliefProp.adjustSmoothingSigmaInputImages( runMotionBeliefPropGivenExpMotionInputs.SMOOTHING_SIGMA_BP_MOTION_TEST) # now run the data using the merged results as the input 'flo' file... cleanAndMakeRunBeliefPropMotion.cleanMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) cleanAndMakeRunBeliefPropMotion.makeMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) # run cuda belief propagation exeBeliefPropMotion.runBeliefPropMotion(inParamCudaBeliefProp)
def runMotionBpMultImagesAdjInputs(): # initialize a dictionary for all the results allResultsDict = {} # need a loop for each 'different' input # make the 'data cost' adjustable for currDataCost in runMotionBeliefPropMultImagesAdjInputsInVals.LIST_DATA_COST_CAPS: # make the 'data weight' adjustable for currDataWeight in runMotionBeliefPropMultImagesAdjInputsInVals.LIST_DATA_WEIGHTS: # make the 'smoothness cost' adjustable for currSmoothnessCost in runMotionBeliefPropMultImagesAdjInputsInVals.LIST_SMOOTHNESS_COST_CAPS: # make the 'estimated movement weight' adjustable for currEstMoveWeight in runMotionBeliefPropMultImagesAdjInputsInVals.LIST_EST_MOVE_WEIGHTS: # make the 'estimated movement cost' adjustable for currEstMoveCost in runMotionBeliefPropMultImagesAdjInputsInVals.LIST_EST_MOVE_COST_CAPS: # initialize the dictionary with the current set of results dictResultsSet = { runMotionBeliefPropMultImagesAdjInputsConsts.DATA_COST_CAP_NAME_CONST: currDataCost, runMotionBeliefPropMultImagesAdjInputsConsts.DATA_WEIGHT_NAME_CONST: currDataWeight, runMotionBeliefPropMultImagesAdjInputsConsts.SMOOTHNESS_COST_CAP_NAME_CONST: currSmoothnessCost, runMotionBeliefPropMultImagesAdjInputsConsts.EST_MOVEMENT_WEIGHT_NAME_CONST: currEstMoveWeight, runMotionBeliefPropMultImagesAdjInputsConsts.EST_MOVEMENT_COST_CAP_NAME_CONST: currEstMoveCost } # set up the environment variables in order to run CUDA belief propagation setupCudaBeliefProp.initToRunCudaBeliefProp() # generate the input parameters to run CUDA belief propagation inParamCudaBeliefProp = inputParamsMultImages.InputParamsMultImages( runMotionBeliefPropMultImagesAdjInputsInVals. FILE_PATH_INPUT_IMAGE_FILE_BASE, runMotionBeliefPropMultImagesAdjInputsInVals. FILE_PATH_START_IMAGE_NUM, runMotionBeliefPropMultImagesAdjInputsInVals. FILE_PATH_END_IMAGE_NUM, runMotionBeliefPropMultImagesAdjInputsInVals. FILE_PATH_END_EXTENSION, runMotionBeliefPropMultImagesAdjInputsInVals. FILE_PATH_SAVE_RESULTING_MOTION_IMAGE, runMotionBeliefPropMultImagesAdjInputsInVals. WIDTH_INPUT_IMAGE_BP_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. HEIGHT_INPUT_IMAGE_BP_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. NUM_BELIEF_PROP_LEVELS_BP_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. NUM_BELIEF_PROP_ITERS_PER_LEVEL_BP_MOTION_TEST, currDataCost, currSmoothnessCost, currDataWeight, runMotionBeliefPropMultImagesAdjInputsInVals. CURRENT_MOVE_INCREMENT_BP_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. SAMPLING_LEVEL_BP_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. X_MOVE_MIN_BP_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. X_MOVE_MAX_BP_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. Y_MOVE_MIN_BP_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. Y_MOVE_MAX_BP_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. RANGE_DISPLAY_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. GROUND_TRUTH_MOVEMENT_FLO_FORMAT, runMotionBeliefPropMultImagesAdjInputsInVals. FILE_PATH_SAVED_MOVEMENT_DATA_FLO_FORMAT, runMotionBeliefPropMultImagesAdjInputsInVals. PROP_CHANGE_MOVE_NEXT_LEVEL_BP_MOTION_TEST, runMotionBeliefPropMultImagesAdjInputsInVals. SMOOTHING_SIGMA_BP_MOTION_TEST, currEstMoveCost, currEstMoveWeight) # generate the header file for the current set of parameters defined in runMotionBeliefPropConsts.py genHeaderFile.genCurrHeaderFile() # clean and make cuda belief propagation cleanAndMakeRunBeliefPropMotion.cleanMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) cleanAndMakeRunBeliefPropMotion.makeMotionBeliefProp( runMotionBeliefPropConsts.DIR_MAKEFILE) # run cuda belief propagation exeBeliefPropMotion.runBeliefPropMotion( inParamCudaBeliefProp, runMotionBeliefPropMultImagesAdjInputsInVals. FILE_SAVE_OUT_MOTION) # extract the results as a dictionary resultsDict = extractResultAsDict.retResultingDict( runMotionBeliefPropMultImagesAdjInputsInVals. FILE_SAVE_OUT_MOTION) # add the 'extracted results' dictResultsSet.update(resultsDict) print allResultsDict # go through the set of results and add to the overall results... for dictKey, dictVal in dictResultsSet.iteritems(): if (dictKey in allResultsDict.keys()): allResultsDict[dictKey].append(dictVal) else: allResultsDict[dictKey] = [dictVal] # delete the file with the saved info os.remove(runMotionBeliefPropMultImagesAdjInputsInVals. FILE_SAVE_OUT_MOTION) print allResultsDict # print the output dictionary print allResultsDict # write the results to a csv file... writeOutputDictToCsv.writeOutputResultsCsvFile( allResultsDict, runMotionBeliefPropMultImagesAdjInputsInVals.FILE_OUT_MOTION_INFO)