Description Usage Arguments Value Considerations Note See Also Examples
gridify
- A wrapper function for grid_calc
and plot_grid
used to read in a directory of png
files. Add grid lines. Output to directory.
gridify_pdf
- A lighter weight version of
gridify
intended to be used as a part of the
workflow for for larger jobs (though restricted to PDF file
output).
1 2 3 4 5 6 7 8 9 10 11 12 13 | gridify(path = ".", out = file.path(path, "out"), pdf = TRUE,
columns = 30, rows = columns, parallel = TRUE,
cores = parallel::detectCores()/2, width = 6, height = 6,
text.color = "gray60", text.size = 2, grid.size = 0.25,
grid.color = text.color, fps = 4, size = "500x500", other.opts = "",
crop = "", code.sheet = file.path(out, "embodied.csv"), duration = NULL,
people = paste("person", 1:3, sep = "_"), clean = FALSE, bins = NULL,
compress.pdf = TRUE, ...)
gridify_pdf(pngs, out = "out/pdf", columns = 30, rows = columns,
parallel = TRUE, cores = parallel::detectCores()/2, width = 6,
height = 6, text.color = "gray60", text.size = 2, grid.size = 0.25,
grid.color = text.color, fps = 4, ...)
|
path |
Path to the in directory with the .png files or a single .mp4 file. |
out |
Path to the out directory. |
pdf |
logical. If |
columns |
The number of grid columns. |
rows |
The number of grid rows. |
parallel |
logical. If |
cores |
The number of cores to use if |
width |
The width of the device. |
height |
The height of the device. |
text.color |
The color to make the coordinate labels. |
text.size |
The size of the coordinate labels. |
grid.color |
The color to make the grid. |
grid.size |
The thickness of the grid lines. |
fps |
The number of image frames per second to output. Generally the fps used to desconstruct a video into images will be used to reconstruct the images back to video. |
size |
Character string of the output size of the png files in the form of "width x height" (in px and no spaces). |
other.opts |
other options to be passed to ffmpeg. |
crop |
Character string of
ffmpeg code used to crop
the images (e.g. |
code.sheet |
A path to the embodied .csv coding sheet. |
duration |
An aptional duration of the original
video, in seconds, if .png files are passed to
|
people |
The people whose coordinates will be logged. |
clean |
logical. If |
bins |
The number of combined PDF files to make id
|
compress.pdf |
logical. If |
... |
other arguments passed to
|
pngs |
A vector of paths to multiple png files. |
Returns multiple files with grid lines.
Larger mp4 files may cause errors or unexpected hangups
due to extended processig time and large file sizes. The
user may want to consider breaking the job into smaller
subcomponents and using elementary, non-wrapper functions
including gridify_pdf
). See the Example
section for an example workflow utilizing this approach.
Note that in order to properly view the time format column
in the code.sheet
, the user may need to adjust the
.csv display settings when the .csv is opened. Within some
spreadsheet programs, changing the format to a
custom of hh:mm:ss.00
enables proper
viewing.
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 | ## Not run:
deb <- system.file("extdata", package = "embodied")
gridify(deb, "out")
#=============================#
# AN APPROACH FOR LARGER JOBS #
#=============================#
## Create png files from .mp4
loc <- "foo.mp4"
fps <- 4
x <- mp4_to_png(loc, fps = fps)
## Generate gridified pdfs
y <- folder(folder.name=file.path(x, "out"))
imgs <- dir(x)[grep("image-", dir(x))]
bins <- binify(file.path(x, imgs))
pdfs <- file.path(y, "pdfs")
lapply(bins, gridify_pdf, out=pdfs)
## Merge PDFs, compact PDF, clean up
library(tools)
z <- file.path(pdfs, dir(pdfs))
## size <- 500 #typically a good cut value
size <- 50
z2 <- binify(z, length(z)/size)
lapply(names(z2), function(x) {
merge_pdf(z2[x], sprintf("%s/batch_%s.pdf", y, x))
compactPDF(sprintf("%sbatch_%s.pdf", y, x))
print(x)
flush.console()
})
delete(pdfs)
## Code sheet
write_embodied(
id = file_path_sans_ext(imgs),
time = mp4_to_times(loc, fps = fps)[seq_along(imgs)],
file = file.path(y, "coding.csv")
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.