Computer vision algorithm to tell if the camera is moving?

Use the background detection algorithm, such as background detection based on Gaussian mixing (present in OpenCv), then hypothesize (say that the background takes more than 60% of the background the image).
Then, convert frames to a color model that keeps luminance as a separate component. Compare consecutive images with low color and pixel tolerance and higher light tolerance (to account for shadows). If your camera is not really still, check with the moving algorithm if the image is shifted by a certain distance (the camera can move slightly even if it is still), this case, compare it with the offset image after detecting the offset.

Now gather the images with a certain tolerance, for example, 95% of the images correspond to the background on at least 60% of the pixels with slight offsets (it depends on the distance between the camera and the camera). background).
If that fits, the camera was still, otherwise the settings were too big or moving.
Adjust the settings, it's done.