public void Update(SensorSnapshot oldSnap, SensorSnapshot newSnap) { if (_values == null) { _xdim = oldSnap.Xdim; _ydim = oldSnap.Ydim; System.Diagnostics.Debug.Assert(oldSnap.Xdim == newSnap.Xdim); System.Diagnostics.Debug.Assert(oldSnap.Ydim == newSnap.Ydim); _values = new long[_xdim, _ydim]; } long marker = DateTime.Now.Ticks; for (int x = 0; x < _xdim; x++) { for (int y = 0; y < _ydim; y++) { int delta = oldSnap.SnapshotValues[x, y] - newSnap.SnapshotValues[x, y]; if (delta != 0) { _values[x, y] = marker; } } } }
public override async Task <bool> DoWork(WorkItem triggeredWorkItem) { Logger.Info("Generate the snapshot matrix"); Bitmap i = RenderImage.BitmapFromBmpByteArray((byte[])triggeredWorkItem.WorkItemContext); _thisSnapshot = new SensorSnapshot(SENSOR_HORIZONTAL, SENSOR_VERTICAL); _thisSnapshot.TakeSnapshot(i); if (_lastSnapshot != null) { _delta.Update(_lastSnapshot, _thisSnapshot); } //Do stuff _lastSnapshot = _thisSnapshot; _thisSnapshot = null; return(true); }