Observed since 20 Oct, 19:07 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Adaptive motion preprocessing: video frames in, encoded motion images out.
Turn video into motion images your neural network can read.
While something moves, each window of frames becomes one grayscale picture: older frames dim, newer ones bright, so a single image shows where the subject went and how fast. Every image has the same shape, so your model never gets a surprise.
pip install adaptive-motion-preprocessing
Then import amprep.
You bring the frames (any iterable of uint8 BGR arrays) and the package
does the rest:
import cv2
from amprep import AdaptiveMotionPreprocessor
def frames_from(path):
capture = cv2.VideoCapture(path)
try:
if not capture.isOpened():
raise OSError(f"cannot open video: {path}")
while True:
ok, frame = capture.read()
if not ok:
return
yield frame
finally:
capture.release()
for image in AdaptiveMotionPreprocessor().process(frames_from("clip.mp4")):
print(image.data.shape)
See your camera and the motion images side by side, live:
git clone https://github.com/sdrfsh/adaptive-motion-preprocessing
cd adaptive-motion-preprocessing
pip install -e .
python examples/live_camera.py
Stay out of shot for a second while it learns the background, then move.
Press q or Esc to quit. Add --camera 1 for an external webcam, or
--threshold 0.03 if it triggers when nothing is moving.
All optional keyword arguments of AdaptiveMotionPreprocessor(...):
| Setting | Default | What it does |
|---|---|---|
motion_threshold | 0.01 | Share of the frame that must be moving before frames are collected |
window_frames | 10 | Frames per window, and one image per full window |
sample_frames | 4 | Frames painted into each image (at most window_frames) |
width, height | None | Output size; leave unset to keep the frame size, or set both |
noise_reducer | median filter | Your own NoiseReducer subclass |
background_subtractor | KNN | Your own BackgroundSubtractor subclass |
window_frames frames. A half-full window is dropped when motion stops.KNNBackgroundSubtractor(warmup_frames=...).reset(). It forgets the background, any half-built
window and the frame size. Otherwise state carries over between
process() calls.ValueError. Call reset() first if the change is on purpose.Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.0 | 14 Sept 2026 | 4 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 19:07 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:1a5d164c749fb33501fadf524a1198eeec885ce4315102503a90089f6816bc63