package producer import ( "image" log "github.com/sirupsen/logrus" "gocv.io/x/gocv" ) type PhaseShiftM struct { dx float32 dy float32 response float64 Block Block } type Block struct { width int height int coord image.Point // top-left corner of the block in the original image } func (r *Registrator) calculateBlockPhaseShift(panBlock, mssBlock gocv.Mat) (gocv.Point2f, float64) { pan := gocv.NewMat() mss := gocv.NewMat() panBlock.ConvertTo(&pan, gocv.MatTypeCV32FC1) defer pan.Close() mssBlock.ConvertTo(&mss, gocv.MatTypeCV32FC1) defer mss.Close() hann := gocv.NewMat() defer hann.Close() shift, response := gocv.PhaseCorrelate(pan, mss, hann) dx := shift.X dy := shift.Y log.Debugf("Block shift: dx = %f, dy = %f. response = %f", dx, dy, response) return shift, response }