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
ndarrayis, why a packed typed buffer beats a Pythonlistfor 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 likemean(), and selection helpers likewhere().Linear algebra –
dot()for matrix multiply,inv()/det()for the inverse, and the decompositions and solvers undernumpy.linalgandscipy.linalgfor problems with more structure.Signal processing –
fft(),sosfilt()for digital filtering, andspectrogram()for allocation-free magnitude spectra in a streaming loop.Curves and integration –
interp(),polyfit()/polyval(),convolve()for short FIR filters,trapz()for trapezoidal integration of sampled data.Solvers and random numbers –
scipy.integratefor quadrature of a Python callable,scipy.optimizefor root finding and minimisation,scipy.specialfor statistical special functions, andGeneratorfor pseudo-random sampling.Images – the
to_ndarray()andimage.Imagebridge 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.