tracking_tools/test.py
2021-01-21 08:33:02 +01:00

45 lines
1.7 KiB
Python

import matplotlib.pyplot as plt
import numpy as np
from IPython import embed, embed_kernel
from tracking_result import TrackingResult
import image_marker as im
def show_tracking_results(dlc_results_file):
tr = TrackingResult(dlc_results_file)
print("scorer: ", tr.scorer)
print("bodyparts:", tr.bodyparts)
t, x, y, l, name = tr.position_values(bodypart="snout", framerate=30)
print("frame_count:", len(t))
print("bodypart: %s" % name)
print("min x pos: %.2f, max x pos: %.2f" % (np.min(x), np.max(x)))
print("min y pos: %.2f, max y pos: %.2f" % (np.min(y), np.max(y)))
print("min likelihood: %.2f, max likelihood: %.2f" % (np.min(l), np.max(l)))
tr.plot(bodypart="snout")
def show_image_marking(video_file):
tank_task = im.MarkerTask("tank limits", ["bottom left corner", "top left corner", "top right corner", "bottom right corner"], "Mark tank corners")
feeder_task = im.MarkerTask("Feeder positions", list(map(str, range(1, 9))), "Mark feeder positions", color="tab:red", marker="s")
dark_light_task = im.MarkerTask('Dark side', ['left', 'right', 'dark_center'], 'Mark light dark separator line')
tasks = [tank_task, feeder_task, dark_light_task]
image_marker = im.ImageMarker(tasks)
marker_positions = image_marker.mark_movie(video_file, 100)
for t in marker_positions:
print(t)
def main(dlc_results_file, video_file):
show_tracking_results(dlc_results_file)
show_image_marking(video_file)
if __name__ == "__main__":
filename = "../boldness/videos/day_8/2020.12.11_lepto48DLC_resnet50_boldnessDec11shuffle1_200000.h5"
video = "../boldness/videos/day_8/2020.12.11_lepto48DLC_resnet50_boldnessDec11shuffle1_200000_labeled.mp4"
main(filename, video)