Is there any function in OpenCV to calculate per block motion vectors for two images?
Your comment on another answer

This contains a dense (per-pixel) motion estimation, and a per feature estimation. Nothing for a per-block estimation

makes me (perhaps mistakenly) think that you're looking for a function whose existence wouldn't really make sense: assuming you pre-define your blocks with some desired granularity, how are you going to compute the flow for each of the blocks? There are two possibilities:

Compute sparse (cv.calcOpticalFlowPyrLK()) or dense (cv.calcOpticalFlowFarneback()) flow over the entire image, and average/downsample the result over each block (with  some smoothing afterwards).

Compute some sort of "block flow" (which seems to be what you had in mind), where you define higher level blocks or super-pixels that you express using some statistics (or features) and compute the flow over them. In that case you'll probably violate the brightness constancy assumptions that most flow methods rely on, and even if you don't, this will very probably be similar to computing dense flow on a very low-resolution image, which in this case, again, could be achieved with cv.calcOpticalFlowFarneback().
Using higher-level blocks would make sense if you were learning them in a flow estimation pipline, though, but that is not the case here as they're predefined.


The second solution doesn't make much sense here, and the first solution is just a simple post-processing that depends on the user's needs.
I am looking for an Opencv method or a way to calculate a per-block motion vectors for two consecutive images.