6.20. Wrap up

The chapter covered the parts of numpy and scipy an OpenMV application reaches for when an operation does not have a built-in image-library method:

  • Concepts – what an ndarray is, why a packed typed buffer beats a Python list for numerical work, and the dtype set the cam supports.

  • Shape and indexing – views vs. copies, slice assignment for allocation-free updates, transpose() as a descriptor edit.

  • Math – element-wise operators, universal functions like sin(), broadcasting rules, reductions like mean(), and selection helpers like where().

  • Linear algebradot() for matrix multiply, inv() / det() for the inverse, and the decompositions and solvers under numpy.linalg and scipy.linalg for problems with more structure.

  • Signal processingfft(), sosfilt() for digital filtering, and spectrogram() for allocation-free magnitude spectra in a streaming loop.

  • Curves and integrationinterp(), polyfit() / polyval(), convolve() for short FIR filters, trapz() for trapezoidal integration of sampled data.

  • Solvers and random numbersscipy.integrate for quadrature of a Python callable, scipy.optimize for root finding and minimisation, scipy.special for statistical special functions, and Generator for pseudo-random sampling.

  • Images – the to_ndarray() and image.Image bridge for the rare cases the image library does not cover.

  • Performance – small dtypes, pre-allocated buffers, in-place operators, out= keywords, and watching out for boolean-mask churn in streaming loops.

That covers the generic numerical work the rest of the camera leans on. numpy is the toolbox an application reaches into when an operation does not have a built-in method on Image – a custom pixel transform, a calibration solve, an FFT of buffered audio.