| 1 | initial version |
You need to create a 2x3 (sic!) transformation matrix suited for cv::warpAffine():
| 1 0 tx |
| 0 1 ty |
You translation is then given as by the vector (tx, ty).
Note: warpAffine requires a 2x3 matrix although technically it is better to think in 3x3 matrices for 2-D homogenous coordinates (the third row would be set implicitly to 0 0 1 in this case).
| 2 | No.2 Revision |
You need to create a 2x3 (sic!) transformation matrix suited for cv::warpAffine():
| 1 0 tx |
| 0 1 ty |
You translation is then given as by the vector (tx, ty).
Note: warpAffine requires a 2x3 matrix although technically it is better to think in 3x3 matrices for 2-D homogenous coordinates (the third row would be set implicitly to 0 0 1 in this case).
Alternatively: If you only want a pure shift and nothing else you may simply shift the image within the corresponding cv::Mat object. Which is certainly faster but constrained to pure translations.