Package 'ovml'

Title: Machine Learning Tools for Volleyball
Description: Image and video machine learning tools, for application to volleyball analytics.
Authors: Ben Raymond [aut, cre], Adrien Ickowicz [aut], openvolley.org [org]
Maintainer: Ben Raymond <[email protected]>
License: MIT + file LICENSE
Version: 0.1.7
Built: 2026-05-16 08:45:27 UTC
Source: https://github.com/openvolley/ovml

Help Index


ovml

Description

Image and video machine learning tools, for application to volleyball analytics.

Author(s)

Maintainer: Ben Raymond [email protected]

Authors:

  • Adrien Ickowicz

Other contributors:

  • openvolley.org [originator]


Install Python dependencies for ONNX inference

Description

Install Python dependencies for ONNX inference

Usage

ovml_install_onnxruntime(gpu = FALSE)

Inspect ONNX model input/output names and shapes

Description

Inspect ONNX model input/output names and shapes

Usage

ovml_onnx_inspect(onnx_file)

List available ONNX model versions

Description

List available ONNX model versions

Usage

ovml_onnx_versions()

Construct YOLO network

Description

Construct YOLO network

Usage

ovml_yolo(version = 4, device = "cuda", weights_file = "auto", class_labels)

Arguments

version

integer or string: one of

  • 3 : YOLO v3

  • 4 : YOLO v4

  • "4-tiny" : YOLO v4-tiny

  • "4-mvb" : an experimental network trained specifically to detect (only) volleyballs

  • "4-tiny-mvb" : the v4-tiny version of the same

  • 7 or "7-tiny" : YOLO v7 or v7-tiny

device

string: "cpu" or "cuda"

weights_file

string: either the path to the weights file that already exists on your system or "auto". If "auto", the weights file will be downloaded if necessary and stored in the directory given by ovml_cache_dir()

class_labels

character: the class labels used for network training. If missing or NULL, these default to ovml_class_labels("coco") for all models except "mvb" models, which use ovml_class_labels("mvb")

Value

A YOLO network object

References

https://github.com/pjreddie/darknet, https://github.com/WongKinYiu/yolov7

Examples

## Not run: 
  dn <- ovml_yolo()
  img <- ovml_example_image()
  res <- ovml_yolo_detect(dn, img)
  ovml_ggplot(img, res)

## End(Not run)

Run YOLO inference on a video (sampled frames + timestamps)

Description

This is a convenience wrapper around ovideo::ov_video_frames() and ovml_yolo_detect(), adding time-windowing, frame sampling and timestamps.

Usage

ovml_yolo_detect_video(
  net,
  video_file,
  start_time = 0,
  end_time,
  duration,
  fps_extract = 5,
  fps_video,
  conf = 0.6,
  nms_conf = 0.4,
  classes,
  batch_size = 4,
  outdir,
  keep_frames = FALSE,
  format = "jpg",
  jpg_quality = 1,
  debug = FALSE
)

Arguments

net

YOLO network as returned by ovml_yolo().

video_file

Path to a video file.

start_time

Numeric seconds from the start of the video (default 0).

end_time

Numeric seconds from the start of the video (optional).

duration

Numeric seconds (optional). If end_time is missing, duration is used.

fps_extract

Numeric. Frames per second to extract (sampling rate). If NULL, all frames are extracted.

fps_video

Numeric. Video framerate. If missing, inferred via av::av_video_info(). Used only to compute timestamps when fps_extract is NULL.

conf, nms_conf, classes, batch_size

Passed to ovml_yolo_detect().

outdir

Output directory for extracted frames. If missing, a temp dir is used.

keep_frames

Logical; if FALSE, extracted frames are deleted on exit.

format

"jpg" or "png" (passed to ovideo::ov_video_frames()).

jpg_quality

Numeric 1-31 (passed to ovideo::ov_video_frames() if format="jpg").

debug

Logical; passed to ovideo::ov_video_frames().

Value

A list with elements: detections, frames, meta.

See Also

ovml_yolo()

Examples

## Not run: 
  library(ovideo)
  v <- ov_example_video(1)
  dn <- ovml_yolo()
  out <- ovml_yolo_detect_video(dn, v, start_time = 0, duration = 3, fps_extract = 5)
  head(out$detections)

## End(Not run)

Detect objects in image using a YOLO network

Description

Detect objects in image using a YOLO network

Usage

## Default S3 method:
ovml_yolo_detect(net, ...)

Processing of a video file requires that ffmpeg be installed on your system. ovideo::ov_install_ffmpeg() can help with this on Windows and Linux.

Description

Processing of a video file requires that ffmpeg be installed on your system. ovideo::ov_install_ffmpeg() can help with this on Windows and Linux.

Usage

## S3 method for class 'ovml_yolo'
ovml_yolo_detect(
  net,
  image_file,
  conf = 0.6,
  nms_conf = 0.4,
  classes,
  batch_size = 4,
  ...
)

Arguments

net

yolo: as returned by ovml_yolo()

image_file

character: path to one or more image files, or a single video file (mp4, m4v, or mov extension)

conf

scalar: confidence level

nms_conf

scalar: non-max suppression confidence level

classes

character: vector of class names, only detections of these classes will be returned

batch_size

integer: the number of images to process as a batch. Increasing batch_size will make processing of multiple images faster, but requires more memory

...

: currently ignored

Value

A data.frame with columns "image_number", "image_file", "class", "score", "xmin", "xmax", "ymin", "ymax"

See Also

ovml_yolo()

Examples

## Not run: 
  dn <- ovml_yolo()
  img <- ovml_example_image()
  res <- ovml_yolo_detect(dn, img)
  ovml_ggplot(img, res)

## End(Not run)

Create an ONNX-backed YOLO detector (Ultralytics export)

Description

Create an ONNX-backed YOLO detector (Ultralytics export)

Usage

ovml_yolo_onnx(
  version = "11n-coco-nms",
  weights_file = "auto",
  providers = c("CPUExecutionProvider")
)

Arguments

providers

Execution providers in priority order, e.g. c("CUDAExecutionProvider","CPUExecutionProvider").

onnx_file

Path to an exported ONNX model (recommended: exported with nms=True).

class_labels

Character vector of class labels (index -> label).

input_size

Model input size (typically 640).