Continuous Shooting Auto Focus, and continuous shooting live view? - Feature Requests - CHDK Forum  

Continuous Shooting Auto Focus, and continuous shooting live view?

  • 21 Replies
  • 8228 Views
Advertisements
These features are available on some models (e.g. S5) but not others (A720IS)... well i'm just asking if it's only a hidden thing like the video optical zoom which can be enabled someway :)

Thanks!

*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Continuous Shooting Auto Focus, and continuous shooting live view?
« Reply #1 on: 23 / July / 2008, 07:37:26 »
I'm not sure what continuous shooting auto focus is... you mean like re-focusing before each exposure when using the continuous drive?

Or do you simply mean continuous autofocus, as in the camera constantly trying to focus...? I've been trying to implement this, without very much success, but I'll try again.

If you mean the former, I have no idea, although it doesn't sound like something incredibly difficult to achieve... but then keep in mind that it would slow continuous drive down quite a bit.


I have even less of a clue about continuous shooting live view... would that be seeing the live view during the time after a shot while the JPEG is being saved, before the next shot is taken?
« Last Edit: 23 / July / 2008, 07:42:00 by LjL »

Re: Continuous Shooting Auto Focus, and continuous shooting live view?
« Reply #2 on: 23 / July / 2008, 14:14:45 »
Exactly what you meant!

"Continuous shooting AF" is refocus after each shot when using the continuous drive. Sure it'll slow down shoot rate.
"Continuous Autofocus" (which is usually known as AF-C, i think?) would also be a great thing, as it would enable you to "lock" the focus on a moving subject.
"Continuous shoot live view" is seeing the live view between shots in continuous drive (you actually get the preview of the photo just taken in some models, while you can get the live view on other models such as the S5). This is useful to track moving subject... without it you'll have ot use the eye viewfinder, but if you use an extension tube you just have to forget it.

Any of these things would be very useful. I really don't know if they can be implemented with chdk... but maybe it's just to unlock something as they're available in other camera models.

*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Continuous Shooting Auto Focus, and continuous shooting live view?
« Reply #3 on: 24 / July / 2008, 07:18:12 »
Well, in any case, all those features (except continuous AF) should be easily simulated using a script: just tell it to keep shooting single frames as long as the shutter release is kept pressed. You'd get re-focusing before each shot, as well as seeing a brief preview between shots.

Now, the following doesn't work (crashes my camera), but I'm sure someone who knows the intricacies of uBASIC better than me can fix it:

Code: [Select]
@title Slow Continuous Drive
while is_pressed "shoot_full"
  shoot
wend
end


*

Offline dzsemx

  • ****
  • 302
  • [SX40HS][A650][A630]
Re: Continuous Shooting Auto Focus, and continuous shooting live view?
« Reply #4 on: 10 / August / 2008, 08:53:00 »
ljl: how did you try to implement continuous AF mode?
do you share with us?
btw
i'd like to suggest a custom AF area to reduce/enlarge AIAF focusing field

*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Continuous Shooting Auto Focus, and continuous shooting live view?
« Reply #5 on: 12 / August / 2008, 09:48:22 »
I tried, and had a modest amount of success. I've implemented a simple focus evaluation algorithm that merely takes the horizontal derivative of the live view's center and then computes its standard deviation (the higher, the more pronounced are the edges, thus the more the subject is in focus).

The harder part, where I had far less success, was to actually change the focus continuously.

There are two problems here: what algorithm to use to scan given the current and previous images' standard deviations (scan back and forward? binary search? integrating over several frames to decide the direction to focus?), and how, practically, to set focus on the camera.

The second, practical problem is what's frustrated me the most: I can surely simulate left/right button presses to change focus (like the AF-using-zoom routine does), but that's inefficient and problematic.
I've tried using shooting_set_focus(), but for some reason that I haven't been able to ascertain, that makes my camera crash (although CHDK uses it all the time successfully; maybe it's only a problem when using it in rapid succession, although that's similar to what focus-in-ALT-mode does, and it doesn't crash).

I'd be grateful if someone had tips about shooting_set_focus(), and I'd probably manage to make this feature into something actually working, but for now it isn't.

*

Offline brainwash

  • **
  • 95
  • Nikon D40x & A460
Re: Continuous Shooting Auto Focus, and continuous shooting live view?
« Reply #6 on: 15 / August / 2008, 19:50:15 »
I've saved my searches on auto-focus algorithms here: http://chdk.setepontos.com/index.php/topic,395.msg16137.html#msg16137
What the camera does, I think, is count the number of high-frequency components - the more, the sharper the image. It then focuses closer, checks sharpness again. If new sharpness is higher then this is the direction in which the focus should move. Otherwise focus farther, check sharpness. If sharpness does not increase then the current focus position is the winner.
There is a threshold of sharpness, if the current position doesn't meet it then the camera enters a hunt-mode, focusing through the entire available distance back and forth (two times) then gives out (at half focus distance I think).
For S2 at least the increments for focus distance hunting are adaptive, it starts slow then gains speed. While approaching optimum focus it slows again (actually backs up). So this is in essence the binary search you have described.

My theory above could explain the dreadful focus-hunting at full tele range - there aren't enough contrasting components to consider a focus lock.

The focus algorithm is a challenge to optimize, camera makers are trying for years and this is what the have come up with - faster motors, faster display, but no real software improvement.

DSLR cameras have dedicated focusing elements, horizontal or vertical. I doubt P&S have that, I think they compute focus through the display.

*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Continuous Shooting Auto Focus, and continuous shooting live view?
« Reply #7 on: 16 / August / 2008, 14:09:06 »
P&S cameras certainly use the CCD without any specialized sensors (it only makes sense, since a DSLR simply cannot use the normal CCD while in viewfinder mode, so it has specialized sensors; on the other hand, some DSLRs that feature "live view" can't focus in this mode, as the software is only programmed to use the special sensors).

But the principle is the same in both cases: use a CCD (linear in DSLRs, two-dimensional in P&S's), and somehow assess contrast.
I do believe that Canon's focusing system only takes into account the viewport data (or, rather, the 2x magnified data), and not the full CCD array.

The algorithm you have described, based on Fourier transforms to determine frequency components, is almost certainly among the most robust; I'd prefer to implement something simpler, however, and it does seem feasible to measure standard deviation from a simple edge-detected version of the image (currently, a 1D derivative as I've said).

The problems I've experienced are more related to the part when you try to determine which direction you should focus. The method you have described (forget the threshold for a moment) seems reasonable, but what happens when 1) noise makes measured sharpness change in the wrong direction, or 2) the user focuses on a different subject (something pretty important for C-AF)?

So I should probably introduce some arbitrary threshold like you mentioned, although I don't like arbitrary threshold.

But then, anyway, the main problem becomes physically changing focus in arbitrary steps: simulated keypresses can't be used for that, and shooting_set_focus() crashes... :|


*

Offline brainwash

  • **
  • 95
  • Nikon D40x & A460
Re: Continuous Shooting Auto Focus, and continuous shooting live view?
« Reply #8 on: 18 / August / 2008, 06:26:33 »
Arbitrary threshold = magic number -> bad code :)
CCD noise is thermally random so it cannot affect edges. Other than that, a calculated threshold might be useful to ignore noise for different ISO ratings, this might enable you to focus sharper at lower ISO, where it really matters and also focus quicker. Higher ISO means viewport is updated faster so again a faster focusing is possible with this trade-off.

I'd say edge detection could be an alternative to FFT components focusing - edge detection is already built in CHDK so I'd say for a given scene the more edges per constant threshold equals sharper image, but I think that's not safe enough.

Ok, while I was writing this I looked for a method of detecting sharpness based on histogram and I found this: http://guppy.mpe.nus.edu.sg/~mpeangh/publications/f0544.pdf
The document describes the amplitude/variance method, the edge detection method, the FFT method, sum-modulus method (might be what canon is using since it lends itself to zones) and two histogram methods. Conveniently, the document presents autofocus methods with tests :)

I guess that first, the fastest (not most accurate) algorithm should be tried and benchmarked against canon. The current problem is focus hunting (perhaps if no focus is obtained the camera should fall back to a slower but more precise algorithm) and repeated lens positions - the algorithm should not try a focus position if it has been tried.
Also, a path of least lens travel should be chosen to focus - that is, depending on whether the algorithm is faster than moving the lens or viceversa.
The document described tests running on PII-300 but Canon is DSP-dedicated so perhaps FFT would not be so slow. Again, it all boils down to the speed of algorithms and the time required to move between focusing positions, if we have those then perhaps we can better the design.

L.E. I just thought of something. At wide-end the required precision and the number of steps that matter is lower than at full-tele. I don't know if that is taken into consideration right now.
« Last Edit: 18 / August / 2008, 06:32:47 by brainwash »

*

Offline dzsemx

  • ****
  • 302
  • [SX40HS][A650][A630]
Re: Continuous Shooting Auto Focus, and continuous shooting live view?
« Reply #9 on: 18 / August / 2008, 14:25:36 »
just a notice, we should not work with viewfinder data, we should acces the liveview rawbuffer (same as the normal image buffer? ), so here we have horizontally the full resolution due sensor readout method...  and sync with every frame.. so we need fast code :(...
isn't possible that an external circuit/controller is responsable for AF?

 

Related Topics