PixelDiff class
Two frames compared as pixels.
Raw rgba8888 in, never PNG: the comparison reads pixels rather than files, so a PNG here would be encoded on the way out and decoded straight back in. Only the handful of pictures that reach a screen are ever encoded.
Measured, the encode is ~7.5ms a picture out and the decode ~0.75ms back,
against bytes that cost about nothing to write (489MB at ~70ms, page
cache). And fw compare is a CLI command, so the decode would have no
engine codec to use: it would fall to package:image, in pure Dart, on
every frame of both sides. This used to say encoding was "~80% of a
capture's cost", which was never measured and is not true.
The output is three things at once, computed in one pass, because they are three readings of the same fact: a percentage for the row, clusters for the eye and for an agent's coordinates, and — when the two frames are not the same height — a band saying where content was inserted or removed, which is the difference between "the card grew" and "everything below the card changed".
Constructors
Properties
- changed → bool
-
Whether this counts as a change at all.
no setter
- changedPixels → int
-
final
-
clusters
→ List<
DiffRect> -
Where the changes are, as rects, largest first.
final
- comparedPixels → int
-
How many pixels were in the compared region. The denominator, kept
because fraction hides it and both are worth having.
final
- fraction → double
-
Changed pixels over compared pixels, 0..1.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → int
-
final
- mask → Uint8List?
-
One byte per compared pixel, 1 where it changed. Kept only when asked
for — it is the whole frame again, and nothing but a visualiser wants it.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sizeChanged → bool
-
Whether the two frames were different sizes.
final
- width → int
-
The compared region — the smaller of the two frames in each dimension.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
Constants
- channelEpsilon → const int
- A pixel counts as changed when a channel moves by more than this.
- clusterThreshold → const int
- A cluster this big is a change however small the frame's fraction. 8×8 is roughly the smallest thing a person notices moving.
- fractionThreshold → const double
- Below this fraction of the frame, the change has to earn its place with a cluster instead.
- groupedRegions → const int
- What grouping aims for once it is needed.
- readableRegions → const int
-
How many boxes a reader can take in at once — above this, and only above
this, the boxes are grouped. See
_grouped.