Hacker News new | past | comments | ask | show | jobs | submit | mzucker's comments login

It's actually easy to keep the lines out -- my challenge was to try to keep them in! Just a matter of shifting thresholds around.


Hence the tagline on the blog: "Why do it by hand if you can code it in just quadruple the time?" :)


More work up front, less work afterwards.


I really enjoyed the various random thoughts in the wrapping up section of this post, thank you a good read!


Pretty sure focal length would affect things as you say, but also physical dimensions matter too. My program assumes fixed focal length and then picks the page dimensions that work with the assumed focal length -- almost certainly not the correct ones.


Yep, might just work out of the box -- give it a shot!


The main rationale is removing redundant degrees of freedom -- since the page is allowed to rotate freely, the edges of the page can still move around plenty.


I see, so basically assume the two end points are at zero and there is some rotation accounting for the endpoint offset in real space.

It still doesn't seem fully accurate as I can imagine a non-rotated cubic curve with endpoints at an offset, but I assume your simplification works well enough.


That sounds like a good idea and pretty straightforward to implement -- now I almost wanna try it...


Thanks for the feedback, everyone -- happy to answer questions here or in the Disqus comments on my blog.


This is really interesting, thanks!

If you decide to try to make this faster, check out ceres[0] a non-linear least squares optimisation framework that does automatic differentiation using a clever C++ template hack.

I've used it a few times to solve these kind of problems and found it to be very good!

[0] http://ceres-solver.org/


Yep, I'm still waiting to use ceres for something - I didn't end up using it on my image approximation project https://mzucker.github.io/2016/08/01/gabor-2.html because it doesn't work well with inequality constraints.


Ah yes, only supporting constraints on the parameters can be annoying if your problem requires that.


I really enjoyed the article!

By the way, you mentioned using word boundaries in regexes to replace variable names. GNU Emacs regexes can actually include "symbol boundaries" (which are a little better for variable names than word boundaries), represented as "\_<symbol\_>". Personally, I like using the "highlight-symbol" package, which provides the "highlight-symbol-query-replace" command to basically execute M-% for the symbol at point.


Cool - will check it out!


Author here - woke up this morning and saw a big bump in site traffic which led me back to HN -- nice to see folks are reading! Happy to answer any questions here or in the Disqus comments on my blog.


Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: