LumiGuide / haskell-opencv

Haskell binding to OpenCV-3.x
Other
154 stars 44 forks source link

warpAffine hides the destination size parameter #74

Closed amigalemming closed 5 years ago

amigalemming commented 7 years ago

Currently warpAffine sets the size of the output image simply to the size of the input image. Unfortunately, this way transformed images are clipped. In order to avoid clipping one has to choose a larger destination image size and has to adjust the translation part of the transformation. How about adding the destination size parameter to the Haskell wrapper?

roelvandijk commented 6 years ago

Hi, sorry for the late reply.

Good point! Adding the destination size parameter is a good idea. I'll try to fix this and work it into the example.

davetapley commented 6 years ago

Well that's reassuring: I just came here to report the same thing! To be sure we're on the same page, this is the offending line, correct? https://github.com/LumiGuide/haskell-opencv/blob/dd51d7cfb1513e03516706465c246164e33fb589/opencv/src/OpenCV/ImgProc/GeometricImgTransform.hsc#L223

And the problem it creates is that you can't pass a different size, e.g. as show in this SO answer?


If ⬆️ is correct, then should we:

  1. Change warpAffine to take a Size (API breaking), or:

  2. Can we do something clever with the type system use this [height, width] for the size? https://github.com/LumiGuide/haskell-opencv/blob/dd51d7cfb1513e03516706465c246164e33fb589/opencv/src/OpenCV/ImgProc/GeometricImgTransform.hsc#L208