def evaluate_performance(params):

    name, original_path, label_path = params

    y_true = []
    y_pred = []

    video_segmentizer = Segmentizer(352, 288)

    data_loader = LASIESTADataLoader(original_path, label_path)

    for i, (original_frame, label_frame) in enumerate(data_loader):

        predicted_background = video_segmentizer.fit_and_predict(original_frame)

        label_frame = label_frame.tolist()
        label_frame = [[background_map_conversion(rgb) for rgb in row] for row in label_frame]
        y_true += list(chain.from_iterable(label_frame))
        y_pred += list(chain.from_iterable(predicted_background))

        y_pred, y_true = remove_uncertain_pixels(y_pred, y_true)

        score = f1_score(y_true, y_pred)

    print('Finished evaluation of dataset ' + name)

    return name, score
    def __init__(self,
                 source='kinect',
                 visuals=False,
                 filesource='default',
                 caldestination='default'):

        # bit depth of the used depth image
        self.imageDepth = 8

        #current frame thats used for calibration
        self.currentFrame = 0

        #segmentizer, used for segmentating images into segments
        #able to create a matrix with the size of the future obstaclematrix
        self.segmentizer = Segmentizer()

        # create visualizer to show region and segment size
        # The visualizer is the same as the visualizer used to show obstacle avoidance
        # using the visualizer the region of interest for obstacle detection and the segment size can be changed
        if visuals == True:
            import visualisation.avoidancevisualizer
            self.visualizer = visualisation.avoidancevisualizer.AvoidanceVisualizer(
            )

        # filesource is the folder for testfiles. Used for testing
        self.filesource = filesource

        # caldestination is the folder where calibration files will be saved
        # if this module is run on 'kinect-nav', the files will later automatically be send to the 'brain'
        if caldestination == 'default':
            self.caldestination = os.environ[
                'BORG'] + "/brain/src/vision/obstacledetectorutil/"
        else:
            self.caldestination = caldestination

        # specify the source (file or kinect) where the images will be taken from
        # 'file' is used for testing
        # When 'kinect', the images will be taken directly from the Kinect
        self.source = source
        if self.source == "file":
            if self.filesource == 'default':
                self.path = os.environ[
                    'BORG'] + '/brain/data/od_images/ball_none/'
            else:
                self.path = self.filesource
            self.filelist = glob.glob(os.path.join(self.path, '*.png'))

        #Used to retreive depth and RGB data:
        self.rgb_retreiver = util.rosimage.RosImage("/camera/rgb/image_color",
                                                    "passthrough")
        self.depth_retreiver = util.rosimage.RosImage(
            "/camera/depth_registered/image_raw", "passthrough")
示例#3
0
from segmentizer import Segmentizer
from segmentizer.data_loader import LASIESTADataLoader
import time

data_loader = LASIESTADataLoader('/Users/dsoellinger/Downloads/I_SI_01')
video_segmentizer = Segmentizer(352, 288)

start = time.time()

for i, frame in enumerate(data_loader):

    if i == 10:
        break

    print("Frame: " + str(i + 1))
    video_segmentizer.fit_and_predict(frame)

end = time.time()

print("Elapsed time: " + str(end - start))