Implementing a focus sweep / depth map - Script Writing - CHDK Forum

Implementing a focus sweep / depth map

  • 9 Replies
  • 7280 Views
Implementing a focus sweep / depth map
« on: 18 / November / 2011, 00:38:22 »
Advertisements
Hi all

I am totally new to CHDK and wondering if CHDK can help me perform a particular task with my canon S95

What I want to do is to programmatically sweep the focus box position to all allowed screen locations one by one, and then invoke the autofocus function at each location to get the focus distance at each point. And then read this array of focus distances. In short, I am trying to get a crude depth map of the scene using the AF mechanism in the camera.

Of course I am ready to delve into CHDK to implement this but before I dive in, I want to get an idea from experienced users if something like this is theoretically possible using CHDK's capabilities.

Will appreciate any feedback about this!

Re: Implementing a focus sweep / depth map
« Reply #1 on: 18 / November / 2011, 09:34:18 »
Hello and welcome.

Problem is, small sensor cameras with their large depth of field are not really suitable for this.

You have to use the wide angle very close up or telephoto at greater distances with limited field-of-view.

What distance range are your subjects and what is the field-of-view ?


David

Re: Implementing a focus sweep / depth map
« Reply #2 on: 18 / November / 2011, 19:14:20 »
Thanks david for your response. You are right that I am not going to get a very accurate depth map but thats OK. A rough figure is all I need.

My range can be anywhere from 0.5m to infinity, however the accuracy requirement goes down as we move farther. For example if something is in 1000m range then it does not really matter if it is 1000m or 10000m.  On the other hand in the close range I would want to know if something is say 5m or 15m. But again it does not matter if it is say 4m or 6m instead of 5m. Basically You can say that I need an estimate at the level of what a human observer can guess by looking at the scene.

From playing around with my s95 at 6mm (Horiz FOV = around 65 degrees, Vert FOV = ~51 degrees), and looking at the focus distance info from EXIF file, I think the resolution of information should be good enough for my purposes.

So basically my main issue now is to automate the process  instead of having to select each focus location one-by-one, taking a picture at each point and then parsing the EXIF for each file.
« Last Edit: 18 / November / 2011, 19:18:57 by rhameed »

Re: Implementing a focus sweep / depth map
« Reply #3 on: 19 / November / 2011, 09:41:24 »
I would want to know if something is say 5m or 15m. But again it does not matter if it is say 4m or 6m instead of 5m.

Before we discuss this further, I suggest you test that by placing some patterned object at those distances.

At 6mm focal length, both of those distances are essentially infinity (65m).

I do not think you will detect them even with that poor degree of accuracy.

Re: Implementing a focus sweep / depth map
« Reply #4 on: 29 / November / 2011, 17:21:54 »
So when I went back and did more experiments and found out that indeed at distance higher than a few meters everything became infinity (reported as around 9.3m in my s95). The accuracy was fine for distances up to 5, 6 meters only.

Then I looked up canon DSLR setups. However it turned out that most canon DSLR lenses also report distances in very coarse steps (possibly worse than s95). So now I am at a point where I have two options. I can either use a canon DLSR with the EF-S 17-55mm lens, which is reported to have a decent enough resolution in focus steps for my needs. Or I can use one of the olympus PEN's (E-PL3 etc) which seem to report the focus distance at a much finer granularity - though I have yet to verify the accuracy. The main drawback of the PEN is that I will have to basically take one picture for each focus location and then extract the distances from this set.

So that brings me to my new question. Is the CHDK support for canon DSLRs strong enough to allow me to do such a task of programmatically varying the focus box (in live view mode), do the focus at each point and note the distance. If yes then I think I can use a canon DLSR + the EF-S 17-55mm for my project - otherwise I should go for a PEN for its finer resolution in reported distance (and lower cost) - though this will be considerable pain and will substantially limit the number of experiments that I can do.

Thanks again for all the helpful responses
« Last Edit: 29 / November / 2011, 17:24:09 by rhameed »

Re: Implementing a focus sweep / depth map
« Reply #5 on: 29 / November / 2011, 19:54:36 »
The usual way of making a depth map is to use two cameras.

Lots of references on the Net.

Re: Implementing a focus sweep / depth map
« Reply #6 on: 29 / November / 2011, 21:44:49 »
Yes I am aware of the usual methods used for creating depth maps using multiple cameras. However for my particular project I need to use this method of determining approximate depth from focus distance. This infromation will work with a number of other oberservations to extract useful information about the scene from a single camera.

So the goal here is to try and come up with a way to do this in an automated way instead of having to do this manually.

Re: Implementing a focus sweep / depth map
« Reply #7 on: 29 / November / 2011, 22:26:26 »
This is an optical problem that no CHDK-supported  camera can help with.

Depth-of-field depends on subject distance, aperture, focal length and sensor size.

You want a wide field-of-view but  that increases DOF.

The largest sensor size you can do is normally 36x24mm and as far as I know those cameras have not been hacked to measure distance.

Ask in the DSLR section of the forum.


Re: Implementing a focus sweep / depth map
« Reply #8 on: 30 / November / 2011, 03:36:27 »
Thanks again for your response. However I think we are debating a different aspect of the problem than the one that I am asking help about. My main question is whether on a CHDK-enabled DSLR I can implement the logic of programmatically selecting a focus point, performing autofocus and then reading the distance information sent back by the lens.

I will check in the DSLR forum as well. And thanks for bearing with my inquiries :)

Re: Implementing a focus sweep / depth map
« Reply #9 on: 01 / February / 2012, 15:14:37 »
Any luck with this project?

 

Related Topics


SimplePortal © 2008-2014, SimplePortal