예제 #1
0
def read_all_patches_from_log(fileName, type=0):
    # initialize the parser
    my_parser = Parser()
    # register the protobuf message name for the 'ImageTop'
    my_parser.register("ImageTop", "Image")
    my_parser.register("BallCandidatesTop", "BallCandidates")
    my_parser.register("CameraMatrixTop", "CameraMatrix")

    # get all the images from the logfile
    # images = map(getPatches, LogReader(fileName, my_parser))

    camera_index = []
    patches = []
    for frame in LogReader(fileName, my_parser):
        ball_candidates = frame["BallCandidates"]
        for p in ball_candidates.patches:
            if p.type == type:
                data = numpy.fromstring(p.data, dtype=numpy.uint8)
                patches.append(data)
                camera_index.append([0])

        ball_candidates_top = frame["BallCandidatesTop"]
        for p in ball_candidates_top.patches:
            if p.type == type:
                data = numpy.fromstring(p.data, dtype=numpy.uint8)
                patches.append(data)
                camera_index.append([1])

    return patches, camera_index
예제 #2
0
파일: drawEdgels.py 프로젝트: tarsoly/NaoTH
    edgelsPlot = [
        plt.scatter([], [], point_size),
        plt.scatter([], [], point_size)
    ]

ax = fig.add_subplot(1, 2, 2, aspect='equal')
ax.set_xlim([-10000, 10000])
ax.set_ylim([-10000, 10000])
projectedEdgelsPlot = [
    plt.scatter([], [], point_size, color='black'),
    plt.scatter([], [], point_size, color='orange')
]

linePlot = LinePlot(ax, (-10000, 10000), (-10000, 10000))

# init parser
logParser = Parser()
logParser.register("ScanLineEdgelPerceptTop", "ScanLineEdgelPercept")
logParser.register("CameraMatrixTop", "CameraMatrix")

log = iter(LogReader(args.logfile, logParser, getEdgels))

# start animation
ani = animation.FuncAnimation(fig,
                              animate,
                              frames=100,
                              fargs=(log, edgelsPlotTop, linePlot, edgelsPlot,
                                     projectedEdgelsPlot),
                              interval=66)
plt.show()
예제 #3
0
#!/usr/bin/python

from naoth.LogReader import LogReader
from naoth.LogReader import Parser


def get_camera_matrix(frame):
    cm_bottom = frame["CameraMatrix"]
    cm_top = frame["CameraMatrixTop"]
    return [frame.number, cm_bottom, cm_top]


def get_edgels(frame):
    edgel_percepts = frame["ScanLineEdgelPercept"]
    return [frame.number, edgel_percepts]


if __name__ == "__main__":
    myParser = Parser()
    myParser.register("CameraMatrixTop", "CameraMatrix")

    for msg in LogReader("./game.log", myParser, get_edgels):
        print(msg)
예제 #4
0
#!/usr/bin/python

import os
import os.path

from naoth.LogReader import LogReader

import json

if __name__ == "__main__":
    index = {}

    for dirpath, dirnames, filenames in os.walk("."):
        for filename in [f for f in filenames if f.endswith(".log")]:
            f = os.path.join(dirpath, filename)

            try:
                reader = LogReader(f)
            except:
                print('scanning ', f, ' failed')
            else:
                for rep in reader.names:
                    if (rep in index.keys()):
                        index[rep].append(f)
                    else:
                        index[rep] = [f]

    with open('index.json', 'w') as index_file:
        json.dump(index, index_file, indent=4, sort_keys=True)
예제 #5
0
#!/usr/bin/python

from naoth.LogReader import LogReader
from naoth.LogReader import Parser

  
def get_audio(frame):
  return frame["AudioData"]

if __name__ == "__main__":
  myParser = Parser()

  newFile = open("audio.raw", "wb")
  
  timestamp = 0
  for s in LogReader("./test_new_recorder.log", myParser, get_audio):
      if s.timestamp > timestamp:
        timestamp = s.timestamp
        #print (type(s.samples))
        print (timestamp)
        newFile.write(s.samples)

  newFile.close()
예제 #6
0
    meta.add_text("roll", str(roll))
    img.save(target_dir + "/" + str(j) + ".png", pnginfo=meta)


if __name__ == "__main__":

    fileName, target_dir = parse_arguments(sys.argv[1:])

    # initialize the parser
    myParser = Parser()
    # register the protobuf message name for the 'ImageTop'
    myParser.register("ImageTop", "Image")
    myParser.register("CameraMatrixTop", "CameraMatrix")

    # get all the images from the logfile
    images = map(get_images, LogReader(fileName, myParser))

    for i, imgB, imgT, cmB, cmT in images:
        imgB = imgB.convert('RGB')
        imgT = imgT.convert('RGB')

        if target_dir is not None:

            targetTop = target_dir + "/top"
            targetBottom = target_dir + "/bottom"

            if not os.path.exists(targetTop):
                os.makedirs(targetTop)
            if not os.path.exists(targetBottom):
                os.makedirs(targetBottom)
예제 #7
0
    try:
        if "BehaviorStateComplete" in frame.messages:
            m, o = frame["BehaviorStateComplete"]
        else:
            m, o = frame["BehaviorStateSparse"]

        return [m["robot_pose.x"], m["robot_pose.y"], m["fall_down_state"]]

    except KeyError as k:
        raise StopIteration


if __name__ == "__main__":
    parser = BehaviorParser()
    fileName = "./game.log"
    log = LogReader(fileName, parser)  # , filter=headYaw)

    # we want only the frames which contain BehaviorState
    b = [
        behavior(f) for f in log if "BehaviorStateComplete" in f.messages
        or "BehaviorStateSparse" in f.messages
    ]

    upright = filter(lambda m: m[2] == 1, b)
    fall = filter(lambda m: m[2] != 1, b)

    print "step 2"
    du = zip(*upright)
    df = zip(*fall)

    pyplot.plot(du[0], du[1], '.')
from naoth.LogReader import LogReader
from naoth.LogReader import Parser


def get_whistle_percept(frame):
    percept = None
    try:
        percept = frame["WhistlePercept"]
    except:
        pass

    if percept:
        return [frame.number, percept]
    else:
        return None


if __name__ == "__main__":
    myParser = Parser()

    for msg in LogReader(
            "\\\\nao\\rc17\\go18\\game_logs\\2018-04-28_GO_nomadz_half2\\090917-0100-Nao0225\\game.log",
            myParser, get_whistle_percept):
        if msg:
            print(msg)