DemaConsulting.AgentVision.Core 0.1.0-beta.1

Prefix Reserved
This is a prerelease version of DemaConsulting.AgentVision.Core.
dotnet add package DemaConsulting.AgentVision.Core --version 0.1.0-beta.1
                    
NuGet\Install-Package DemaConsulting.AgentVision.Core -Version 0.1.0-beta.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DemaConsulting.AgentVision.Core" Version="0.1.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DemaConsulting.AgentVision.Core" Version="0.1.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="DemaConsulting.AgentVision.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DemaConsulting.AgentVision.Core --version 0.1.0-beta.1
                    
#r "nuget: DemaConsulting.AgentVision.Core, 0.1.0-beta.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DemaConsulting.AgentVision.Core@0.1.0-beta.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DemaConsulting.AgentVision.Core&version=0.1.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DemaConsulting.AgentVision.Core&version=0.1.0-beta.1&prerelease
                    
Install as a Cake Tool

AgentVision

GitHub forks GitHub stars GitHub contributors License Build Quality Gate Security NuGet NuGet

AgentVision gives AI agents fast access to webcams. It is delivered as the DemaConsulting.AgentVision.Core .NET library and the DemaConsulting.AgentVision.Tool .NET tool (command agentvision), which is a thin command-line front-end for the library. The goal of the project is low-latency webcam capture: keeping multiple cameras open ("hot") so that frames can be captured, cropped, scaled, and saved with almost no delay, using FlashCap and DemaConsulting.CanvasNet, with the command-line tool optionally running through a background daemon.

Status: under active development. Both packages can list the cameras of a machine and the video formats each one supports (agentvision cameras, or CameraEnumerator in the library), save one picture of a camera, whole or in part (a region, scaled down, with a labeled grid), as PNG, JPEG, or BMP (agentvision snap, or CameraSnapper in the library), and keep cameras open ("hot") so that the newest frame can be handed out, cropped, and saved with almost no delay. The command-line tool reaches the hot cameras through a background daemon: agentvision start starts it, agentvision snap then takes every picture from the cameras that it already holds open, and agentvision stop ends it. Without a daemon, agentvision snap still works: it opens the camera, waits for the warm-up, and closes it again.

The workflow below shows how an AI agent uses it: the agent runs agentvision commands, the daemon holds the cameras hot, and each picture comes back to the agent as an image file.

Workflow: an AI agent runs agentvision commands, the commands talk through a per-user pipe to a daemon that keeps
the cameras open, the daemon writes PNG, JPEG, or BMP image files, and the agent opens the files and looks at the
pictures

Features

AgentVision provides:

  • Background Daemon: agentvision start starts a per-user daemon that keeps cameras open ("hot"), so that every picture after the first is a read of the newest frame instead of a camera start-up; status, open, close, and stop inspect and control it
  • Camera Enumeration: agentvision cameras lists the video capture devices of the machine with their stable identifiers, names, and supported formats (resolution, pixel format, and frame rate), using FlashCap; a machine without a camera is reported plainly and is not an error
  • Snapshot Command: agentvision snap --camera <index|id|name> --output <file> saves one picture as PNG, JPEG, or BMP, taking it from the daemon when one runs and otherwise opening the camera, waiting for it to warm up, and closing it again; problems give a clear message on standard error and a non-zero exit code
  • One Entry per Camera: agentvision cameras lists each physical camera once, however many capture backends (DirectShow, Media Foundation) report it, and opens it through the preferred backend, falling back to the next one
  • Several Views of One Frame: --output can be repeated, and the region, scale, and grid options that follow an --output apply to that picture only, so an overview and a detail come from the same frame in one command
  • All Cameras in One Picture: snap --camera all --output room.png composes every camera into one labeled picture
  • JSON Output: --json makes cameras, snap, start, stop, status, open, and close write exactly one JSON object, with the result, the errors, and the warnings in it, for programs that drive the tool
  • Glance, Then Focus: snap can keep a region (--crop, --region, or --cell), scale the picture down (--max-size or --scale, never enlarging it), and draw a labeled grid (--grid), so that an agent takes a small look at the whole frame first and then asks for the cells that matter; the one-line result names the picture size, the frame size, and the region of the frame
  • Hot Camera Capture (library): CameraOpener opens one or several cameras by index, identifier, or name and keeps them streaming; CameraSession.Snapshot() returns the newest frame from any thread without waiting, after a configurable warm-up that discards the dark first frames; disposing a session stops the camera
  • Daemon Client and Server (library): DaemonServer and DaemonClient in the library implement the daemon and its versioned JSON-lines protocol, so an application can host or call a daemon without the tool
  • Image Operations (library): decode a frame, select a region (pixels, fractions, or grid cells), scale it down, draw the labeled grid of the full frame, and save it as PNG, JPEG, or BMP by the file extension, using DemaConsulting.CanvasNet
  • Standardized Command-Line Interface: Context class handling common arguments (--version, --help, --silent, --validate, --results, --depth, --log)
  • Self-Validation: Built-in validation tests with TRX/JUnit output
  • Built-in Help: agentvision help serves Markdown help cards (DemaConsulting.HelpCards) with runnable examples, search, and JSON output for AI agents
  • Reusable Library: DemaConsulting.AgentVision.Core is the home of all camera logic and is usable by any .NET application without the tool
  • Multi-Platform Support: Builds and runs on Windows and Linux
  • Multi-Runtime Support: Targets .NET 10 and 11
  • Comprehensive CI/CD: GitHub Actions workflows with quality checks, builds, and integration tests
  • Linting Enforcement: LintMark, TextLint, and yamllint enforced on every CI run
  • Continuous Compliance: Compliance evidence generated automatically on every CI run, following the Continuous Compliance methodology
  • SonarCloud Integration: Quality gate and security analysis on every build
  • Documentation Generation: Automated build notes, user guide, code quality reports, requirements, justifications, and trace matrix
  • Requirements Traceability: Requirements linked to passing tests with auto-generated trace matrix

Installation

Install the tool globally using the .NET CLI:

dotnet tool install -g DemaConsulting.AgentVision.Tool

Add the library to a project with:

dotnet add package DemaConsulting.AgentVision.Core

Usage

The most common use is a small overview of the whole frame with a labeled grid, then a detail of the cells that matter, both from one frame. Everything you need for that is at the top of agentvision --help:

agentvision cameras                                                        # <n> below is the camera number it shows
agentvision start                                                          # keep the cameras open, so snaps are instant
agentvision snap --camera <n> --output overview.png --max-size 640 --grid --output detail.png --cell C3:D4
agentvision snap --camera all --output room.png --max-size 1280            # every camera in one labeled picture
agentvision stop                                                           # close the cameras and end the daemon
agentvision snap --camera <n> --output frame.png                           # no daemon: opens the camera itself, slower

The rest of this section and the following ones show every command and option.

# Default behavior (no arguments) — displays banner, copyright, and a pointer to the help
agentvision

# List the cameras of this machine and the formats they support
agentvision cameras

# Save one picture of a camera (by index, identifier, or name) to a file
agentvision snap --camera 0 --output frame.png

# Capture at a smaller format, keep only a region (x,y,width,height; quote the value), and warm up for 2 seconds
agentvision snap --camera 0 --output region.jpg --crop "100,50,400,300" --capture-width 1280 --capture-height 720 --fps 30 --warmup 2000

# Glance at the whole frame, small and with a labeled grid, then focus on cells C3 to D4, both from one frame
agentvision snap --camera 1 --output glance.png --max-size 640 --grid --output focus.png --cell C3:D4 --max-size 800

# Every camera in one labeled picture, and the result as one JSON object
agentvision snap --camera all --output room.png --max-size 1280 --json

# Keep the cameras open in a background daemon, so that every picture is fast
agentvision start
agentvision snap --camera 1 --output first.png
agentvision snap --camera 1 --output second.png
agentvision status
agentvision stop

# Display version (the version only; the commands print no banner, only --help, --validate, and no arguments do)
agentvision --version

# Display help
agentvision --help

# List the built-in help topics, then read one
agentvision help
agentvision help getting-started
agentvision help cameras
agentvision help snap
agentvision help snap-output
agentvision help daemon

# Run self-validation
agentvision --validate

# Save validation results (--result is an accepted alias for --results)
agentvision --validate --results results.trx
agentvision --validate --result results.xml

# Set heading depth for embedded validation output
agentvision --validate --depth 2

# Silent mode with logging
agentvision --silent --log output.log cameras

Listing Cameras

agentvision cameras lists the video capture devices that the machine reports, one entry for each physical camera. It only looks at the devices and does not start capturing from any of them. It exits with code 0 also when it finds no camera, which is a normal answer on servers and build agents.

Cameras found: 1

Camera 0: Integrated Webcam
  Backends:    MediaFoundation (preferred), DirectShow
  Best:        1920x1080 JPEG 30 fps (2 formats)

Add --formats to list every format of each camera.

The compact listing shows the index, the name, the backends, and the best resolution and frame rate of each camera; agentvision cameras --formats adds the identifier, the description, and every format (Formats (2): followed by 1920x1080 JPEG 30 fps and so on).

When no camera is found, the output is No cameras found. Windows can report one physical camera through several backends (Media Foundation, DirectShow, and Video for Windows). The tool lists the camera once, with its preferred backend (MediaFoundation, then DirectShow, then AVFoundation, then V4L2) and a Backends: line for the others. Entries with the same device identity in their Id are one camera, so two cameras of one model stay two cameras; an entry without such an identity (a virtual device, a V4L2 node) joins a camera of the same name only when that camera has no entry of the same backend yet. The Video for Windows entry (usually named Default) cannot be opened, so it is never listed. agentvision cameras --all-backends lists every entry that each backend reports, with the camera that it belongs to, and marks the entries that are not listed; use it to check why a camera is listed as it is. The number is the index of the camera, the name selects the camera whichever backend reports it (two cameras with one name are an error that lists their numbers), and the Id of one entry selects exactly that backend and never falls back. A camera opens through its preferred backend and, when that backend fails to open or delivers no frame, through the next one, so a driver problem of one backend does not stop a picture. On Linux, cameras are reported through V4L2 and your account needs access to the /dev/video* devices, normally through the video group. If every snapshot shows a placeholder image, check the camera's privacy shutter/switch and the OS camera privacy settings. Run agentvision help cameras for troubleshooting.

Saving a Picture

agentvision snap takes one picture and saves it:

agentvision snap --camera 0 --output frame.png

The tool opens the camera, discards the frames of the warm-up (1 second by default, because most cameras deliver dark frames at first), saves the next frame, closes the camera, prints one line such as Saved frame.png (1280x720) from Integrated Webcam; frame 1280x720, region 0,0,1280,720; camera opened for this snap (the size of the saved picture, the size of the full frame, the part of the frame that the picture shows, and, when the snap had to open the camera, which is slow, that it did), and exits with code 0. Warnings follow the result lines. When a daemon runs (see the Running the Daemon section), the command asks the daemon for the picture instead, and the camera stays open for the next one. The camera is the index that agentvision cameras prints, its name, or the Id of one of its backend entries; the name or the Id is the stable choice for scripts. The extension of the output file chooses the format: .png, .jpg, .jpeg, or .bmp. An existing file is overwritten, and its folder must exist.

Option Description
--camera <camera> Required. The index, name, or Id of a backend entry; all for every camera. Once
--output <file> Required, repeatable. A picture file (.png, .jpg, .jpeg, .bmp); options below set it
--crop <x,y,w,h> Keep only this region: left edge, top edge, width, and height, in pixels of the frame; quote it
--region <x,y,w,h> Keep only this region, as fractions of the frame from 0 to 1, such as "0.25,0.25,0.5,0.5"
--cell <c>, --cell <c>:<c> Keep one grid cell such as C3, or the block between two corners such as C3:D4
--max-size <px> Shrink the picture so that its longer side is at most this many pixels (1 to 8192)
--scale <factor> Shrink both sides by this factor, above 0 and at most 1
--grid Draw the grid lines and the cell names over the picture
--grid-size <cols>x<rows> The grid, up to 26 by 26 (default 8x6); needs --grid or --cell
--capture-width <px>, --capture-height <px> Capture at this size; the closest format is used; give each once
--fps <n> Prefer this capture frame rate; give it once
--warmup <ms> Discard the frames of the first milliseconds, 0 to 60000 (default: 1000); give it once
--json Write one JSON object instead of text (see JSON Output)

Quote the comma lists. Write --crop "100,50,400,300" and --region "0.25,0.25,0.5,0.5" with quotes (PowerShell splits an unquoted comma list into separate arguments; the quoted form is right in every shell, and a value that arrives as a single number gets an error that says so).

Glance, Then Focus

A large frame costs time and tokens that a first look does not need. Look at the whole frame first, small and with a grid, and then ask for only the part that matters:

# Glance: the whole frame, at most 640 pixels on the long side, with grid lines and cell names (A1 at the top left),
# and focus: only cells C3 to D4, at most 800 pixels on the long side, both from the same frame
agentvision snap --camera 1 --output glance.png --max-size 640 --grid --output focus.png --cell C3:D4 --max-size 800

Several pictures, one frame. --output can be given up to 16 times, with different files. The options --crop, --region, --cell, --max-size, --scale, --grid, and --grid-size belong to the --output before them, so the example above reads as "the glance, then the focus". An option of this kind before the first --output is an error. --camera, the capture options, and --json belong to the whole command: give each once, anywhere. Every file is made from the same captured frame, decoded once, and the command prints one result line per file, in order. It works the same with and without the daemon.

All cameras. --camera all composes the latest frame of every camera into one picture, laid out in a grid of ceil(sqrt(n)) columns, each tile labeled with the number that cameras shows and the name of the camera (white text with a dark outline on a translucent plate, so it reads on light and dark scenes). --max-size and --scale apply to the whole picture (without them the longer side is at most 1920 pixels, and a picture is never enlarged); a region (--crop, --region, --cell) and a grid are refused. With the daemon the picture shows the cameras that are open in it (agentvision open --camera <n>; with none open the command fails and says so); without the daemon snap opens every camera one after the other, which costs the start-up of each, several seconds per camera, and one camera that fails fails the command.

What size do I get? With no region, scale, or grid option (--output is always required), the picture is the whole capture frame, such as 3840x2160 on a 4K camera. --cell, --region, and --crop without --max-size or --scale return full-resolution pixels. The cells follow the full-frame grid: on a 3840x2160 frame with the default 8x6 grid every cell is 480x360 pixels, so C3:E5 (3x3 cells) is 1440x1080. Add --max-size or --scale to shrink the result.

The grid always covers the full frame, whichever region and scale are chosen, so a cell has the same name and the same pixels in the glance and in the focus. Use the same --grid-size for both. Columns are letters from A at the left, rows are numbers from 1 at the top, and either corner order works in C3:D4.

The steps always run in the same order: select the region, scale it, then draw the grid. At most one of --crop, --region, and --cell may be given, and at most one of --max-size and --scale; a picture is never enlarged. The line that snap prints names the region in pixels of the full frame in the syntax of --crop, for example Saved focus.png (480x360) from Webcam; frame 1920x1080, region 480,360,480,360, so the same part of the frame can be taken again with --crop "480,360,480,360". The options work the same with and without the daemon. Run agentvision help snap-output for the examples.

Choosing the Capture Format

The capture format is an open-time decision: it is chosen when a camera is opened and stays the same for as long as the camera is open. With no capture option, the camera opens at the highest resolution that it offers at 15 frames per second or more (at the same resolution the higher frame rate wins, then compressed JPEG; a camera that cannot reach 15 frames per second opens in its fastest format). There is no upper limit, so a 4K camera opens at 4K.

A high default resolution has a cost: several high-resolution cameras on one USB hub may not open together, because the hub cannot carry all of their data. When a camera fails to open and no capture option was given, the error message says so. Ask for a smaller capture format to fix it, for example agentvision snap --camera 1 --output frame.png --capture-width 1280 --capture-height 720.

When a daemon holds a camera open, snap and open cannot change its format: the capture options of a snap for an open camera in another format do not apply. The picture is still taken, in the open format, and the tool prints a warning on standard error (the exit code stays 0) that names the open format and how to change it: run agentvision close --camera <camera>, then agentvision open --camera <camera> with the capture options.

A problem, such as an unknown camera, a camera that another program holds, a camera that delivers no frame within 5 seconds after the warm-up, an unsupported extension, a missing folder, a crop outside the picture, or a cell outside the grid, prints Error: ... with the reason on standard error, writes no file, and exits with code 1. The camera is always closed. Run agentvision help snap for the examples.

The same list is available to any .NET application through the library:

using DemaConsulting.AgentVision.Core.Cameras;

var enumerator = new CameraEnumerator();
foreach (var camera in enumerator.Enumerate())
{
    // ToString shows the name, the backends that report the camera, and the number of formats
    Console.WriteLine(camera);
}

// Find resolves an index, a name, or the Id of one backend entry
var first = enumerator.Find("0");

An application or a test can supply its own ICameraSource to new CameraEnumerator(source) instead, so that enumeration runs without camera hardware. Each CameraInfo is one physical camera: its Id and Backend are those of the preferred backend, and Alternatives holds the other backends that report the same camera. EnumerateBackends() lists every raw backend entry. A CameraFormat reads as 1920x1080 JPEG 30 fps, and a camera as Integrated Webcam (MediaFoundation + DirectShow, 17 formats).

Running the Daemon

Opening a camera takes several seconds. An AI agent that wants many pictures should therefore not open the camera for every one. The daemon is a background process of your account that keeps cameras open ("hot"); every agentvision snap then asks it for the newest frame, which is already in memory. A typical agent session looks like this:

# Once, at the beginning: start the daemon (returns when it answers; safe to repeat)
agentvision start

# As often as needed: the first snap of a camera opens it, every later snap is fast
agentvision snap --camera 1 --output first.png
agentvision snap --camera 1 --output second.png
agentvision snap --camera 1 --output detail.jpg --crop "100,50,400,300"
agentvision snap --camera 1 --output glance.png --max-size 640 --grid

# See what the daemon holds open: instance, process, protocol, and per camera the format, frame count, and last frame age
agentvision status

# Once, at the end: close the cameras and end the daemon (safe to repeat)
agentvision stop

On the development machine used for this documentation, the first snap of a camera took about 4 to 5 seconds because it opens the camera, and each later snap about half a second, of which most is the start-up of the .NET process of the command; your numbers depend on the camera and the machine.

Command Description
start Start the daemon and wait until it answers; reports the daemon that already runs, so it is safe to repeat
stop Close all cameras and end the daemon; exits 0 also when no daemon runs
status Show the daemon and the cameras it holds open; exits 0 also when no daemon runs
open --camera <camera> Open a camera in the daemon ahead of time, so that the first snap is fast
close --camera <camera> or close --all Close one camera, or every camera, and keep the daemon running

open also takes --capture-width, --capture-height, --fps, and --warmup. These options (and the same options of snap) apply only when the daemon opens the camera; a camera that is already open keeps its format until you close it, and a snap that asks for another format prints a warning (see the Choosing the Capture Format section). The daemon writes the picture files, so snap turns a relative --output into an absolute path first. When a daemon exists but does not answer, snap fails with a message and does not open the camera behind its back. There is no idle time-out: the daemon runs until agentvision stop, until you sign out, or until the machine restarts. A running daemon locks the program files of the tool, so run agentvision stop before you update or rebuild it.

Security and IPC

The daemon is reached through a local named pipe (a Unix domain socket on Linux), and only your own account can use it:

  • The pipe name contains the user name (agentvision-<user>), so two users of one machine never reach each other's daemon, and both the daemon and its clients use PipeOptions.CurrentUserOnly, so that other accounts are refused.
  • Nothing listens on a network port. The daemon runs with your rights and writes the files that you name, so it can write any path that you could write yourself; treat it like the tool itself.
  • The messages are versioned JSON lines (protocol version 3). A daemon that speaks another protocol version, for example one that was started before an update, is reported with the advice to run agentvision stop and then agentvision start.
  • A lock file in the AgentVision folder of your local application data folder makes sure that only one daemon runs per user and instance, and lets start recognize and replace the stale endpoint of a daemon that crashed. The daemon writes its problems to daemon.log in the same folder.
  • The environment variable AGENTVISION_INSTANCE (letters, digits, -, and _, up to 32 characters) selects a separate, independent daemon; give every command the same value to reach it. The daemon is per user, so agents that share a machine each set it to their own name, and agentvision status prints the instance in use (default when the variable is not set), whether or not a daemon runs:
export AGENTVISION_INSTANCE=lab
agentvision start
agentvision snap --camera 1 --output lab.png
agentvision stop
$env:AGENTVISION_INSTANCE = 'lab'

Camera Quirks

  • Placeholder picture. Some integrated webcams (for example an "Integrated Webcam") deliver real frames for about the first second of streaming and then a "camera off" placeholder picture, such as a dark blue screen with a crossed camera icon, when a privacy shutter or switch, or a setting of the operating system, turns the camera off. Every picture is then the placeholder, with or without the daemon: turn the camera on, or choose another camera.
  • The Default camera of Video for Windows. On Windows one physical camera can be reported through several backends. The VideoForWindows entry (usually named Default) cannot be opened by FlashCap, so it is not listed; agentvision cameras --all-backends still shows it. The daemon keeps one open camera for each physical camera, so the number, the name, and the Id of an entry all reach it, and asking for the Id of another backend while it is open is an error that says to close it first.
  • One program per camera. A camera can be open in one program at a time. While the daemon holds a camera, other programs cannot use it; agentvision close or agentvision stop frees it.

Run agentvision help daemon for the same information in the built-in help.

Capturing Frames with the Library

The library keeps a camera open ("hot"): opening takes a second or more, but every snapshot after the first is a read of the newest frame that is already in memory, so it is safe and cheap to take snapshots from many threads.

The public API is in five namespaces, and the natural entry point is DemaConsulting.AgentVision.Core.Capture (CameraOpener, CameraSession, CameraFrame, and CameraSnapper). Cameras lists the cameras and defines the ICameraSource seam for your own cameras, Imaging turns a frame into a picture (region, scale, grid, and save), Daemon hosts or calls the background daemon, and Daemon.Protocol holds the answers of the daemon client. Every namespace is documented with when to use it, thread safety, disposal, and a getting-started example. The wire format of the daemon is not public; DaemonClient.ProtocolVersion is the version number that a program can show.

using DemaConsulting.AgentVision.Core.Capture;
using DemaConsulting.AgentVision.Core.Imaging;

var opener = new CameraOpener();

// Open by the index in the list that CameraEnumerator.Enumerate returns (the number that `agentvision cameras` prints),
// by name, or by the Id of one backend entry; open as many cameras as you like.
// The capture format is decided here: without Width, Height, and FramesPerSecond the camera opens at its highest
// resolution that offers at least 15 frames per second
using var session = opener.Open("0", new CameraOpenOptions { Width = 1280, Height = 720 });

// The first snapshot waits for the warm-up (1 s by default); later ones return at once
var frame = session.Snapshot();

// Save decodes the frame and writes it; the extension (.png, .jpg, .jpeg, .bmp) chooses the format
frame.Save("frame.png");

// Options keep a region, scale it down, and draw the labeled grid, and the result describes the picture
var saved = frame.Save("detail.png", new ImageOutputOptions { Region = ImageRegion.FromPixels(new CropRectangle(100, 50, 320, 240)) });
Console.WriteLine($"{saved.Width}x{saved.Height} of {saved.SourceWidth}x{saved.SourceHeight}");

A frame is the bytes of a JPEG, PNG, or BMP file (a JPEG or PNG as the camera delivers it, every other pixel format converted to a BMP), so CameraFrame.EncodedData can be forwarded as it is. CameraFrame.Age is the time since the library received the frame, and it keeps growing while your code works on the frame: read it right after Snapshot() to judge freshness. Save and ToImage() decode the frame, which takes roughly 0.1 to 0.4 seconds for a 1080p JPEG and up to about a second for 4K, depending on the machine and its load; call ToImage() once and use ImageOutputOptions.Apply when several pictures are made from one frame.

For one picture with one call, new CameraSnapper().Snap(new SnapRequest("0", "picture.jpg")) opens the camera, saves a frame, and closes the camera again, also when something fails. A request can list several outputs, each with its own options (region, scale, grid, in the same order as on the command line), and they are all made from one frame; the camera "all" composes every camera into one labeled picture (see ImageMontage). The result lists the saved files (size, region of the frame, brightness) and the frame or frames that they came from:

using DemaConsulting.AgentVision.Core.Capture;
using DemaConsulting.AgentVision.Core.Imaging;

// Glance (the whole frame, at most 640 pixels on the long side, with the labeled grid) and focus (cells C3 to D4 of the
// same grid, at their own size) from one frame
var request = new SnapRequest("0",
[
    new SnapOutput("glance.png", new ImageOutputOptions { Scale = ImageScale.FromMaxSize(640), ShowGrid = true }),
    new SnapOutput("focus.png", new ImageOutputOptions { Region = ImageRegion.FromCells("C3:D4") })
]);

var result = new CameraSnapper().Snap(request);
var focus = result.Outputs[1];
Console.WriteLine($"{focus.Width}x{focus.Height} of the {focus.SourceWidth}x{focus.SourceHeight} frame, region {focus.Region}");

ImageRegion.FromPixels, FromFractions, and FromCells name a region, ImageScale.FromMaxSize and FromFactor a scale, and ImageGrid the grid (default 8 columns by 6 rows); DaemonClient.Snap accepts the same request and gives the same result. CameraFrame.Save(path, options) does the same for a frame of an open camera in one call, and CameraFrame.SaveAll saves several pictures of one frame (each with its own options) from a single decode; the SavedImageInfo that they return has an IsDark flag.

Disposing a session stops the camera deterministically. Failures are reported with documented exceptions (CameraNotFoundException, CameraOpenException, CameraTimeoutException, and CameraDisconnectedException, all derived from CameraException) whose messages say what happened and what to do. Camera features can be tested without hardware by giving CameraOpener an ICameraSource of your own. The User Guide describes the options (size, frame rate, warm-up, timeouts), the exceptions, and several cameras at once in detail.

Hardware Tests

The standard test run (pwsh ./build.ps1 -All) needs no camera. To also run the smoke tests against the real cameras of your machine, add the opt-in switch. The smoke tests (including the ones that start a real daemon and take pictures through it) of the two target frameworks run one after another (they queue on a lock file in the temporary folder), because a camera can be open in one program at a time; close other programs that use the cameras first:

pwsh ./build.ps1 -All -Hardware

Command-Line Options

Command Description
start Start the background daemon that keeps cameras open; see the Running the Daemon section
stop Stop the daemon and close its cameras
status Show the daemon and the cameras it holds open
open Open a camera in the daemon (--camera, and optionally the capture options and --warmup)
close Close one camera (--camera) or every camera (--all) in the daemon
snap Save one picture of a camera to a file; see the Saving a Picture section
cameras List the available cameras (compact; --formats lists every format of each)
help [topic] Display the built-in help topics
Option Description
-v, --version Display version information
-?, -h, --help Display help message
--silent Suppress console output
--validate Run self-validation
--results <file>, --result <file> Write results to .trx (TRX) or .xml (JUnit XML) file.
--depth <#> Set heading depth for markdown output (default: 1)
--log <file> Write output to log file

The command options are an error without a command that accepts them: snap takes --camera, --output, --crop, --region, --cell, --max-size, --scale, --grid, --grid-size, --capture-width, --capture-height, --fps, and --warmup; open takes --camera, --capture-width, --capture-height, --fps, and --warmup; and close takes --camera or --all; cameras takes --all-backends and --formats. Every command takes --json (once). The environment variable AGENTVISION_INSTANCE selects a separate daemon for every command that uses one.

JSON Output

--json makes cameras, snap, start, stop, status, open, and close write exactly one JSON object on one line of standard output, with camel-case names, instead of text. The exit code stays the same (0, or 1 for an error), and nothing is written to standard error: an error is an object too, with a stable kind and the message, and so are the warnings. A mistake in the arguments is reported the same way when --json is among them.

agentvision snap --camera 1 --json --output overview.png --max-size 640 --grid --output detail.png --cell C3:D4
{"ok":true,"command":"snap","cameras":[{"index":1,"name":"Integrated Webcam","id":"...","backend":"MediaFoundation","format":{"width":1920,"height":1080,"pixelFormat":"JPEG","framesPerSecond":30},"openedNow":false,"frame":{"width":1920,"height":1080,"sequence":34,"capturedAt":"2026-12-01T15:01:26.2917628+00:00"}}],"outputs":[{"path":"overview.png","fullPath":"C:\\work\\overview.png","width":640,"height":360,"region":{"x":0,"y":0,"width":1920,"height":1080},"composite":false,"meanBrightness":0.6005,"dark":false},{"path":"detail.png","fullPath":"C:\\work\\detail.png","width":960,"height":720,"region":{"x":480,"y":360,"width":960,"height":720},"composite":false,"meanBrightness":0.5023,"dark":false}],"warnings":[]}

Every object has ok, command, and warnings ({kind, message, output?}, for example darkPicture). A failure is {"ok":false,"command":"snap","error":{"kind":"cameraNotFound","message":"..."},"warnings":[]}; the kinds are invalidArguments, cameraNotFound, cameraOpen, cameraDisconnected, cameraTimeout, noCameraOpen, daemonNotRunning, protocolVersion, daemon, io, image, and internal. For snap, cameras lists the camera or cameras that were used and outputs the files in the order of --output; all outputs of one camera come from the frame in cameras[0].frame (compare sequence). cameras lists cameras[] (index, name, id, backend, formats, backends), and status reports running, instance, processId, protocol, startedAt, and the open cameras. agentvision help json-output documents every member.

Error Handling

Unrecognized arguments, a command that is given twice, two different commands together, a command option without the command that accepts it, and a missing or invalid option value cause the tool to print an error message to standard error and exit with a non-zero exit code. For example:

Error: Unsupported argument '--unknown'

This behavior enables CI/CD pipelines to detect and surface misconfiguration failures automatically.

Self Validation

Running self-validation produces a report containing the following information:

# DEMA Consulting AgentVision Tool

| Information         | Value                                              |
| :------------------ | :------------------------------------------------- |
| Tool Version        | <version>                                          |
| Machine Name        | <machine-name>                                     |
| OS Version          | <os-version>                                       |
| DotNet Runtime      | <dotnet-runtime-version>                           |
| Time Stamp          | <timestamp> UTC                                    |

✓ AgentVisionTool_VersionDisplay - Passed
✓ AgentVisionTool_HelpDisplay - Passed
✓ AgentVisionTool_CamerasList - Passed

Total Tests: 3
Passed: 3
Failed: 0

Each test in the report proves:

  • AgentVisionTool_VersionDisplay - --version outputs a valid version string.
  • AgentVisionTool_HelpDisplay - --help outputs usage and options information.
  • AgentVisionTool_CamerasList - cameras exits with code 0 and reports the cameras or that none were found. It passes on a machine without a camera.

Use --depth <#> to control the heading level of the validation output (default: 1). This is useful when embedding validation output into a larger markdown document:

# Embed validation at heading level 2
agentvision --validate --depth 2

See the User Guide for more details on the self-validation tests.

On validation failure the tool will exit with a non-zero exit code.

Documentation

Generated documentation includes:

  • Build Notes: Release information and changes
  • User Guide: Comprehensive usage documentation
  • Code Quality Report: CodeQL and SonarCloud analysis results
  • Requirements: Functional and non-functional requirements
  • Requirements Justifications: Detailed requirement rationale
  • Trace Matrix: Requirements to test traceability

Contributing

See CONTRIBUTING.md for guidelines on reporting bugs, suggesting features, and submitting pull requests.

License

Copyright (c) DEMA Consulting. Licensed under the MIT License. See LICENSE for details.

By contributing to this project, you agree that your contributions will be licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-beta.1 0 12/1/2026