This is neat! I played around with a Julia implementation of the idea: https://observablehq.com/@yurivish/makeshift-camera-phone-scanner-in-julia
Instead of a full perspective transform I computed the slope of the line along the top of the card and used that to rotate the card back to straight, which is simpler but assumes that the card isn't fully warped (ie. the camera is top-down).
Thanks!
Yeah, I was doing that with the original rotated rectangle bounding box I was calculating, which is also an interesting algorithm, but realized it was consistently off for a bunch of cards I had because I had photographed them at a slight vertical angle. I'm decently happy with this polygonal hull to small quadrilateral process.
I also noticed there might be a consistent lens barrel distortion on my camera... https://en.wikipedia.org/wiki/Distortion_(optics) Either that or I'm consistently picking a offset left corners?