-
Notifications
You must be signed in to change notification settings - Fork 0
/
annotateall.R
51 lines (33 loc) · 1.02 KB
/
annotateall.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
library(stringr)
checkpath <- function(indir){
if(!dir.exists(indir)){
stop(paste(indir, "does not exist"))
}
if(is.na(str_match(indir, "/$"))){
indir <- paste0(indir, "/")
}
return(indir)
}
options <- commandArgs(trailingOnly = TRUE)
if(length(options) != 4){
stop("Expecting input video, output folders, face detection folder, object tracking folder ")
}
inputdir <- checkpath(options[1])
outputdir <- checkpath(options[2])
facedir <- checkpath(options[3])
objectdir <- checkpath(options[4])
videofiles <- list.files(inputdir, pattern = "P\\d+_video.mp4$")
for(v in videofiles){
rootname <- str_extract(v, "(P\\d+)")
outname <- paste0(rootname, "_bboxes.avi")
facename <- paste0("pface", rootname, ".csv")
objectname <- paste0(rootname, "_video.csv")
cmd <- paste0("python showboxes.py ",
inputdir, v, " ",
outputdir, outname, " ",
facedir, facename, " ",
objectdir, objectname
)
print(cmd)
system(cmd)
}