Last active
December 10, 2022 10:42
-
-
Save kagaya/32706c38404c99431669ba34b8bccbac to your computer and use it in GitHub Desktop.
read raw.pkl file from soft_skeleton_solver (https://github.com/katsuma-inoue/soft_skeleton_solver)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(reticulate) | |
read_raw_pkl <- function(file_path="/path/to/raw.pkl"){ | |
# https://gist.github.com/kagaya/32706c38404c99431669ba34b8bccbac | |
j <- import("joblib") # python package joblib is loaded via {reticulate} | |
arm_xy <- j$load(file_path) | |
tibble(t=1:length(arm_xy$path), path=arm_xy$path) %>% | |
group_by(t) %>% | |
mutate(x=list(path[[1]][[1]][[2]][,1]), | |
y=list(path[[1]][[1]][[2]][,2])) %>% | |
select(t, x, y) %>% | |
unnest(cols=c(x,y)) %>% | |
ungroup() %>% | |
group_by(t) %>% | |
mutate(node=1:length(x)) %>% | |
ungroup() | |
} | |
txy <- read_raw_pkl("path/to/raw.pkl") # this will load the data as tibble |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment