LiveText

Live Text: the text in the photo on screen, with where every character is, so it can be selected and copied. Text Reading keeps each photo's lines as it indexes (TextStore.lines), so an indexed photo has them straight away; others are read on demand at up to ReadSide, and kept the same way. The last few are also held in memory. The reader loads as the viewer opens (warm) and stays a little after it closes (release).

Types

Link copied to clipboard
class Result(val lines: List<TextReader.Line>, val width: Int, val height: Int)

lines with corners in pixels of a width×height image: the photo as displayed.

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Lines to bytes for TextStore: text, corners, and each character's span.

Link copied to clipboard
suspend fun read(context: Context, item: MediaRef): LiveText.Result?

The photo's text, or null when there's no text reader or it can't be read.

Link copied to clipboard
suspend fun readVideoFrame(context: Context, item: MediaRef, atMs: Long): LiveText.Result?

The text in item (a video) at atMs: the frame on screen while paused. Its positions aren't kept on disk (every moment is a different frame; the last few stay in memory), but lines the video's search index lacks are added to it: the indexer only samples frames.

Link copied to clipboard
fun release()

The viewer closed: frees the text models after KeepMs unless it opens again first.

Link copied to clipboard
suspend fun stored(context: Context, item: MediaRef): Pair<LiveText.Result?, TextStore.Known>

What's known without reading: the lines kept on disk (null when there are none), and whether the index found no words at all, so there's nothing to read.

Link copied to clipboard
fun warm(context: Context)

Loads the reader ahead of the first photo (the viewer opened).