Just a thought-Anyone tried to mod a thermal camera core to auto focus? - Page 1
Forum section: electronics / general

author: joe46726
author_rank: Newbie
timestamp: November 08, 2019, 07:25:31 am
content: As I know, most affordable thermal cameras don't offer auto focus, but it shouldn't be that difficult to add an external servo system to a camera core which is manual focus.It can function like the AF system in a low end camera: move the focus, compare the contrast, find the focus point with highest contrast, and move to that point.This is just a personal thinking, welcome to discuss.

author: bap2703
author_rank: Regular Contributor
timestamp: November 08, 2019, 08:07:17 am
content: And re do a NUC

author: Ultrapurple
author_rank: Super Contributor
timestamp: November 08, 2019, 08:58:26 am
content: Auto focus is a feature of some (?many) higher-end thermal cameras, particularly general purpose scientific types. My FLIR SC-660 camcorder-style will autofocus at the press of a button (manual works fine, too) and I suspect it's done by contrast detect. The camera kindly marks its ?fixed region of interest on the screen whilst it's doing the AF adjustment so you can be certain it'll focus on the right thing. As with all contrast detect systems it isn't infallible - particularly in low contrast scenes - but I use it far more than manual focus on that camera.I agree with the OP's original comment that it "shouldn't" be difficult, using the methods suggested. The software side would be essentially free, but the servo system would add mechanical complexity and hence cost. There are lots of professional grade thermal imaging lenses that have focus (and even zoom and iris) servo systems.Have a look at this threadfor some examples.I guess one has to ask why one wants auto focus. Most of our hobbyist-budget LWIR cameras are the thermal equivalent of the now-cheap fixed focus, fixed focal length security cameras that are everywhere. They do the job they are intended for: observe a specific area. On the visible light cameras the bulk manufacturers have got the hyperfocal distance sorted out and chosen a suitable aperture and FoV lens that works well pretty much all of the time. Yes, you can adjust the focus if you really need a close-up of your ant colony, but they are really intended for fixed use. And they're cheap.In thermal imaging I suspect the numerical majority of cores also (now) go into observation systems of varying grades. I was surprised in York (UK) when I saw numerous small FLIR LWIR pan & tilt cameras on top of traffic lights and other street furniture; extrapolated across that small city there are possibly several hundred, along with perhaps ten or a hundred times more visible light cameras. All of these FLIR cameras I saw were fixed focus, probably 19mm lens, probably 320x240. This implies to me that LWIR cameras are becoming commodity items manufactured perhaps in their millions, which will in time drive the price down. As far as we can see at the moment they'll remain harder to manufacture and consequently more expensive than a CMOS visible light sensor but they are getting cheaper. But back to the original question about focus: all the surveillance cameras of this sort of grade work just fine, thank you, with a fixed focus lens. It's only when you get to more exotic systems, such as long-range border cameras and suchlike that (remotely) controllable focus becomes an issue. And by the time you're at the optical (and imager) performance that it becomes a significant issue, the incremental cost is trivial. If you're putting up a camera on a pole 25 miles from HQ and in the middle of nowhere then the costs of getting power out and data back, not to mention simply erecting the pole, make a 10% difference to the cost of the actual camera & lens assembly relatively trivial.But back to our world. There certainly are some consumer-grade cameras around that lend themselves to auto focus experiments. The Therm-App, Thermal Expert and many of the other interchangeable lens small cores all have a firm housing and adjustable focus lenses, so it would be relatively easy to contrive a method of adjusting the focus (maybe a 3D printed arm, for leverage, and a standard radio control type servo). The Seek dongles that have adjustable focus should also be pretty easy to use. The question then is how you derive the contrast. If there's a SDK then it should be relatively easy for someone software-savvy to write a bit of code; I'm not, but I can think of some easy ways of doing contrast detect on a live analogue video signal so that is a possibility too.Now of course after I've rambled for half an hour someone will come along and tell me there's a $10 widget on AliExpress that does it all for you...

author: Kleinstein
author_rank: Super Contributor
timestamp: November 08, 2019, 09:44:21 am
content: COntrast type auto-focus is looking for maximum contrast. So more the focus too look for maximum. This usually requires to move quite a bit, as it needs at least 3 point's to find a maximum. With usually relatively high noise and limited resolution this may be a little more difficult (slower) for IR than regular optics. It also needs a picture that has sufficient contrast / sharp edges.Because of limited resolution, there may be no need for auto focus for cheap IR cameras at longer distance. The fixed focus is just good enough for something like 2 m to infinite. Correspondingly the AF system would not see much difference anymore to find an optimum focus position. The relevant number is object distance divided by lens (aperture) diameter compared to the resolution (1 dimension).So an adjustable focus would be something for the short range only.Moving the focus a lot for the short range (e.g. less than some 10 cm) will change the effective aperture and this will effect the calibration, as more of the housing is seen and less of the actual picture. So this will effect the calibration / scales.

author: Ultrapurple
author_rank: Super Contributor
timestamp: November 08, 2019, 09:53:51 am
content: Good points. My SC-660 deliberately runs the focus from extreme closeup to infinity when it seeks, so it is (or should be) guaranteed to find a maximum high frequency contrastsomewhere. For the reasons you suggest I suspect follow-focus (like 3D tracking on Nikon DSLRs) is still some way off, at least with noisy uncooled systems.The large aperture of many uncooled LWIR optics means that the depth of field can be quite limited, particularly with large sensors: a 40mm f/0.7 driving a 17µm 640x480 sensor has a paper-thin DoF, particularly at short distances. (On my 35mm full frame DSLR I have a 50mm f/1.4 and at full aperture and portrait distance you have about 1mm or so in good focus; f/0.7 would be significantly more critical).

author: Vipitis
author_rank: Frequent Contributor
timestamp: November 08, 2019, 10:29:18 am
content: I am highly anticipating a post by Spirit who proposed this idea before. But instead of going of contrast of the actual signal, you would use an external sensor to sense depth. time of flight can probably do this fine enough for the resolving power of lwir. but you need to calibrate your lens and motor well enough and use a motor encoder, all of this can be solved by using an existing product.

author: Fraser
author_rank: Super Contributor
timestamp: November 08, 2019, 10:57:23 am
content: I have worked on early video camera auto focus systems that used time of flight and IR imaging techniques.The early Panasonic camera I dismantled used an ultrasonic transducer to measure the distance to the target. The optical lens has a large horn above it that contained the transducer. The system worked surprisingly well. It was basically working like the Polaroid camera focus systems and telling the camera system the distance to target that needed to be dialled into the focus motor system.Other systems I have worked on used infrared distance measurement to determine the distance to target for input to the focus system. Basically a more advanced version of the ultrasonic system.These systems had the advantage of still working in low light situations where image noise, or virtually no image would have rendered contrast based autofocus unreliable. They had the disadvantage of crude target selection so the camera would not always focus on what you wanted in a complex scene.Fraser

author: Ultrapurple
author_rank: Super Contributor
timestamp: November 08, 2019, 11:44:41 am
content: @Vipitis - I know it's not what you're saying but I rather like the idea of someone coming up with a fast-enough sensor to do LWIR time-of-flight measurements.@Fraser - I'm sure those systems would be amenable to adaptation for thermal imaging because they're essentially wavelength-independent and, as you note, don't require anything special about the target except a little reflectance.Looking at recent mirrorless full-frame and APS-C type visible light cameras, some use special-type pixels embedded within the normal imaging matrix to do phase detection for auto focus. I admit I'm not familiar with the technology (I use a good old-fashioned DSLR that uses contrast detection in mirror-up modes) but there is, as usual, aninteresting and informative article on auto focus on Wikipedia.Special pixels in the imaging array aren't unique to visible light cameras of course - I believe I'm right in saying that the SEEK sensors use blanked pixels as in-sensor temperature references, though these are not suitable for (or used for) autofocus.

author: frogg
author_rank: Regular Contributor
timestamp: November 08, 2019, 03:50:50 pm
content: What are you trying to do, Joe?Given the fact that IR optical elements totally dominate the cost of any autofocus assembly, and that autofocus for FPAs is an already-solved problem (and has been for decades), what are you trying to do that simple hyperfocal distance can't solve?

author: Spirit532
author_rank: Frequent Contributor
timestamp: November 20, 2019, 04:59:48 am
content: It's pretty easy to make an autofocus system with an external distance sensor, provided you have a reliable way to twiddle the camera's actual focus.On FLIR cameras with motorized lenses, all you have to do is set a single value and the camera will jump to that. The rest is bridging the gap in software.I'm working on... a thing() that I might make pluggable into my T440bx for funsies.

author: frenky
author_rank: Unknown
timestamp: November 20, 2019, 07:57:28 am
content: While I enjoy working with microcontrolers and steppers I would rather implement semi-autofocus.Just strap on mini distance meter like this one (6cm x 2.5cm):https://www.banggood.com/D30-30M-Mini-Handheld-Laser-Distance-Meter-Digital-USB-Rechargeable-Laser-Rangefinder-Distance-Area-Volume-Measurement-p-1422482.html?ID=46123&cur_warehouse=CNAnd add a bigger focus ring with distances engraved into it.So you can quicky measure distance with meter and set the ring to the right value...

author: bap2703
author_rank: Regular Contributor
timestamp: November 20, 2019, 02:36:44 pm
content: To be perfect you'd need the rangefinder to work at about the same wavelength as the thermal camera.Otherwise you could for example:- focus behind an infrared-opaque piece of glass- focus on an infrared-only mirror instead of on the reflected scene that is optically further away