Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 13
  • Members: 0
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
No birthdays today

Next birthdays
05/04 Matthew T. (35)
05/04 Amrit Deshmukh (60)
05/05 Alexandre (32)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: Computer Science
« Previous topic | Next topic »   

Reverse engineer eyeglass prescription from photograph, computer vision

Move Thread LAN_403
Dr. Slack
Wed Jan 14 2015, 07:58AM Print
Dr. Slack Registered Member #72 Joined: Thu Feb 09 2006, 08:29AM
Location: UK St. Albans
Posts: 1659
As my astigmatism gets stronger over the years, I have increasing difficulty adapting to new glasses. My paranoia of course is that the manufacturers are not making them correctly. There are several ways to check what glasses are doing. I have shone a laser pointer through them, using a Technic Lego frame to index the movement repeatably, and used Lego and a cylindrical chrome tube to make a fan beam to make lining up the astigmatism easier. However, they require constructing something like an optical bench and running figures through a spreadsheet, so it's not something that is easy to do.

It then occured to me that a photograph of a sheet of graph paper, seen through a lens, plus knowing the graph paper pitch, and the camera-lens-object distances, contains all the information one needs to analyse the lens, with a minimum of equipment and setup. It just needs a CV program writing to find the distortion of the background in the lens. I did spend 10 minutes on google with CV, analysis, glasses prescription to see if anything like this was out there already, but with no joy, but then my google foo tends not to be strong.

Does anybody know of anything like this freely available?

It may be the case that this sort of thing is not even commercially available, as the little magic thing they use at the opticians has hardware, lenses, is smaller than a toaster, and a program like this would render that hardware without a market.

If is not available, maybe it's time it was. While I could program everything myself, and I've been wanting to find an interesting CV application to play with, things like this usually work better with a collaboration, two heads and all that. Would anybody like to collobarate with me on this as a project? My prefererence would be to go for python, openCV, matplotlib, scipy etc, anything else would involve a steep learning curve, but I'm open to suggestions.
Back to top
Shrad
Wed Jan 14 2015, 10:41AM
Shrad Registered Member #3215 Joined: Sun Sept 19 2010, 08:42PM
Location:
Posts: 780
I think you must look for matrix calculations there... that's what they use to compute lens geometrics for laser cavities, and I guess it could be of use

real-time google-fu for "matricial lens analysis" led me to this link : Link2

which is the idea of my first lines... but I guess you need a good deal of physics-fu to get through it... simple for a small box with embedded processing, harder for the rest of us humans
Back to top
Uspring
Wed Jan 14 2015, 12:09PM
Uspring Registered Member #3988 Joined: Thu Jul 07 2011, 03:25PM
Location:
Posts: 711
If it is a convex lens, likely for older people smile , then a point source of light at a large distance will provide a beam you can focus on a piece of paper behind the glasses. For astigmatic lenses you'll get 2 distances, where you'll see a line, each one corresponding to one of the 2 focal lengths.

Back to top
Dr. Slack
Wed Jan 14 2015, 02:04PM
Dr. Slack Registered Member #72 Joined: Thu Feb 09 2006, 08:29AM
Location: UK St. Albans
Posts: 1659
The sums are relatively straightforward, it's getting a reasonably usable gui, and auto-alignment of the though-lens and past-lens images that needs the discussion.
Back to top
Uspring
Fri Jan 16 2015, 10:43AM
Uspring Registered Member #3988 Joined: Thu Jul 07 2011, 03:25PM
Location:
Posts: 711
Perhaps auto alignment is not a big issue. The effect of a lens is a magnification or reduction of the graph paper grid. In the case of an astigmatic lens, there are 2 magnification factors. In the special case, where the astigmatic axes are parallel to the grid lines, the result will be a non square rectangular grid. For non aligned axes, there also will be a rotation. In total it is a 2x2 matrix operation on the x and y coordinates of the grid paper or the image taken. For eyeglasses not aligned to the camera optical axis, there will also be an position offset.

An automated system would have to establish magnification factors and rotation angles. (seems to me the hardest part). A perfect alignment of the eyeglasses along the optical axis of the camera doesn't seem necessary. Probably it is best to take 2 images, one without eyeglasses and one with.

The camera to eyeglass to grid paper distances affect the scale of magnification, particularly the eyeglass to paper distance. Also there will be a defocussing effect, so the 2 images should not be taken with autofocus in order to preserve geometrical parameters between the images.

Back to top
Dr. Slack
Fri Jan 16 2015, 01:48PM
Dr. Slack Registered Member #72 Joined: Thu Feb 09 2006, 08:29AM
Location: UK St. Albans
Posts: 1659
This is the benefit of discussion, I had forgotten about autofocus.

I had already considered the possibility that I would not know where the effective pinhole was in a compound camera lens, so had anticipated taking two photos with different distances between camera and glasses, to solve for the constant unknown lens offset. But, if AF is different between shots, then the offset need no longer be constant. With a 'proper' camera, you can manually focus, however I have a $50 point'n'shoot. You can muck about with focussing zones, and half-press with a target which you then remove for the shot, but it's a bit tedious.

I suspect that a short distance glasses to graph paper, and a long distance to the camera will minimise the contribution of any lens position error.
Back to top
Uspring
Fri Jan 16 2015, 03:44PM
Uspring Registered Member #3988 Joined: Thu Jul 07 2011, 03:25PM
Location:
Posts: 711
To measure magnifications and rotation you don't need to establish the offset. Moving the glasses too close to the paper will reduce the amount of magnification so it will become difficult to measure.

If you can't disable autofocus moving the camera away will probably help.

Back to top

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.