/
verb_review.R
56 lines (52 loc) · 1.48 KB
/
verb_review.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#' Review files
#'
#' Interactive review of images (if present) and acquired informations
#'
#' @param x [Momocs2::mom] object, typically returned by [sniff] here
#'
#' @export
review <- function(x){
UseMethod("review")
}
#' @rdname review
#' @export
review.default <- function(x){
.msg_info("review: no method defined for this class")
}
# will probably allow it for mom_tbl
#' @rdname review
#' @export
review.sniff_tbl <- function(x){
# check for paths
# checks for images in path
repeat {
readline(prompt = "Press <Enter> to continue, <Esc> to quit...")
x_i <- x %>% Momocs2::slive()
path_i <- dplyr::pull(x_i, .data$path)
if (is_imagepath(path_i)){
paste0("Viewing: ", path_i) %>% cli::cat_line()
# regular viewer
path_i %>% magick::image_read() %>% print()
# # classic viewer
# gr <- path_i %>% magick::image_read() %>% magick::image_draw()
# print(gr)
# if (Momocs2::coo_nb(x_i)>0){
# coo <- Momocs2::pick(x_i, 1) %>% as.matrix()
# # print(coo)
# image_draw_outline <- function(x){
# polygon(x[, 1], x[, 2], border="red", lwd=2)
# points(x[1, 1], x[1, 2], pch=24, cex=2, col="red", bg="grey50")
# }
# image_draw_outline(coo)
# dev.off()
# print(gr)
# }
} else {
paste0(path_i, " not an image; skipping") %>% .msg_info()
next()
}
}
}
#
# "~/Research/2020-VitisRef/data/def_masks/" %>% sniff() %>%
# dplyr::slice(1:10) %>% review()