IXUS160/ELPH160 Porting attempt - page 48 - DryOS Development - CHDK Forum
supplierdeeply

IXUS160/ELPH160 Porting attempt

  • 497 Replies
  • 185667 Views
Re: IXUS160/ELPH160 Porting attempt
« Reply #470 on: 10 / August / 2016, 15:49:34 »
Advertisements
No problem. Here's a test build with zoom delay 300

Big, huge, enormous thanks!!

I have been torturing my poor ixus with various scripts some hours now, zooming and focusing back and forth, taking pictures in between, etc. Not a single crash!

(excluding crash from "set_prop(221,1)", Differing from comment at PROPSET6.LUA, in ixus160 M1 pic size value seems to be  2, leaving 1 being something undefined...)

Increased delay seems also fix the aflock crash. Aflock behaviour seems to be a bit mystery in ixus160. It looks like aflock is not needed to achieve manual focus. However, with aflock focus behaves differently than without it. (With aflock there seems to be some kind of ceiling, focus does not change anymore after certain value)

Noticed also something which is very good news, at least for me: Zoom positioning accuracy in ixus160 is very good, totally at different level compared to A2500

*

Offline reyalp

  • ******
  • 13623
Re: IXUS160/ELPH160 Porting attempt
« Reply #471 on: 10 / August / 2016, 22:48:19 »
I have been torturing my poor ixus with various scripts some hours now, zooming and focusing back and forth, taking pictures in between, etc. Not a single crash!
Thanks for confirming, I've checked this in for both 1.4 and 1.5

Quote
(excluding crash from "set_prop(221,1)", Differing from comment at PROPSET6.LUA, in ixus160 M1 pic size value seems to be  2, leaving 1 being something undefined...)
Can you check what the value is for each resolution? In chdkptp, you can just use =get_prop(221) after highlighting the resolution in the func menu.

Quote
Aflock behaviour seems to be a bit mystery in ixus160. It looks like aflock is not needed to achieve manual focus. However, with aflock focus behaves differently than without it. (With aflock there seems to be some kind of ceiling, focus does not change anymore after certain value)
When you say "ceiling" you mean you can't set_focus beyond a certain distance unless you use aflock?

FWIW, CHDK behavior with AF is slightly different from aflock and MF. In AF, calling set_focus just stores a value, which is applied during shooting after the cameras normal AF process has finished. If aflock or MF is enabled, calling set_focus immediately sets the focus.
Don't forget what the H stands for.

Re: IXUS160/ELPH160 Porting attempt
« Reply #472 on: 11 / August / 2016, 08:41:02 »
Quote
FWIW, CHDK behavior with AF is slightly different from aflock and MF. In AF, calling set_focus just stores a value, which is applied during shooting after the cameras normal AF process has finished. If aflock or MF is enabled, calling set_focus immediately sets the focus.

So it seems. Thanks for clarification.

Quote
When you say "ceiling" you mean you can't set_focus beyond a certain distance unless you use aflock?

Yes. For example, if I locate object, say, at 1m distance and start increasing focus, the object becomes sharp at somewhere around 1000. If I increase the value beyond that, without aflock the object becomes blur again, with aflock it stays sharp or blurs only very little.

Quote
Can you check what the value is for each resolution? In chdkptp, you can just use =get_prop(221) after highlighting the resolution in the func menu.

Sure. The values are: L = 0, M1 = 2, M2 = 3, S = 5

There is also a "W" (wide) value, which sets prop 221 value to 0. Maybe "W" has effect on some other prop. I took a propdump with "L" and "W" setting, below is the diff.


$ diff  PROPDUMP.LOG_L PROPDUMP.LOG_W
67c67
< [65]=   0,
---
> [65]=   3100,
94c94
< [92]=   0,
---
> [92]=   5152,
106c106
< [104]=   0,
---
> [104]=   5152,
117c117
< [115]=   0,
---
> [115]=   1,
250c250
< [248]=   0,
---
> [248]=   3100,
274c274
< [272]=   1040,
---
> [272]=   897,


Re: IXUS160/ELPH160 Porting attempt
« Reply #473 on: 18 / August / 2016, 18:04:12 »
Now that zoom is working perfectly, I ran into focusing problems.

Example: Without chdk, I zoomed in to somewhere middle and took a photo of the camera box with autofocus. Crop of that picture attached.

Next, I booted into chdk and figured out the zoom used in previous step. Then took pictures with all possible focus settings.  Crop of the best picture attached.

As you see, there is quite a difference.

It looks like  the camera is not able to bring focus "close enough" . Lowest and highest possible focus number seems to change with the zoom. With example zoom (45) the best focus is 1014 and it is also the lowest.

Process before shoot was:
luar set_prop(143,2)
luar set_zoom()
luar set_aflock(1)
luar set_focus(1014)

I also tried to set focus mode (prop 6) into manual but it made no difference.

Any idea?


*

Offline reyalp

  • ******
  • 13623
Re: IXUS160/ELPH160 Porting attempt
« Reply #474 on: 19 / August / 2016, 16:53:53 »
Now that zoom is working perfectly, I ran into focusing problems.

Example: Without chdk, I zoomed in to somewhere middle and took a photo of the camera box with autofocus. Crop of that picture attached.

Next, I booted into chdk and figured out the zoom used in previous step. Then took pictures with all possible focus settings.  Crop of the best picture attached.
Does it happen if you just have chdk running, and do everything else the same as the no CHDK case? E.g. zoom manually and use auto focus? Or does it only happen when you use set_focus and/or set_zoom?
Quote
Any idea?
If your commands are in a script, you might need some delay in between some of them.

You can try using set_mf() instead of set_aflock()
Don't forget what the H stands for.

Re: IXUS160/ELPH160 Porting attempt
« Reply #475 on: 20 / August / 2016, 18:23:04 »
Quote
Does it happen if you just have chdk running, and do everything else the same as the no CHDK case? E.g. zoom manually and use auto focus? Or does it only happen when you use set_focus and/or set_zoom?

It looks like the autofocus behaves exactly same with or without CHDK. It works also from command line with press('shoot_half')

With no zoom or with very little zoom (under 10)  it is possible to reach correct focus with set_focus(). There is even some room, you do not have to set focus value as low as you could.

It looks like with higher zoom values the minimum focus value is too high. Thus set_focus() is not able to go  as low as autofocus is. For example, with full zoom (100) lowest possible focus value is 1300, which is still blur, and setting higher value only makes it worse. So the correct value is probably somewhere under 1300

Are these minimum values defined somewhere in CHDK?

Quote
You can try using set_mf() instead of set_aflock()

Tried that, no difference. Looks like the result is the same with set_aflock(), set_mf() or neither, only the timing of focus is changed.

Re: IXUS160/ELPH160 Porting attempt
« Reply #476 on: 20 / August / 2016, 19:09:36 »
With no zoom or with very little zoom (under 10)  it is possible to reach correct focus with set_focus(). There is even some room, you do not have to set focus value as low as you could.

It looks like with higher zoom values the minimum focus value is too high. Thus set_focus() is not able to go  as low as autofocus is. For example, with full zoom (100) lowest possible focus value is 1300, which is still blur, and setting higher value only makes it worse. So the correct value is probably somewhere under 1300
On the less expensive Powershots (which usually do not have Canon MF capability) the accuracy of set_focus() is usually pretty bad.  This is even the case with higher end camera and it actually varies from camera to camera.   I've written at length about this in other threads on this forum.

On my "roundtuit" list is some method of building a calibration table that would provide a calibrated set_focus() by determining MoveFocusLensWithPosition values for various actual focus settings at different zoom settings.  If possible, it will internally use the set mecha position functions rather than set_focus().  It would have to be calibrated for each person's camera manually but for those who care about having MF capability through CHDK, it would be a nice feature to have.

That's not to say the IXUS160 does not have it's own MF problems.  But it's far from perfect on most other Powershots.


Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 13623
Re: IXUS160/ELPH160 Porting attempt
« Reply #477 on: 20 / August / 2016, 20:12:17 »
It looks like with higher zoom values the minimum focus value is too high. Thus set_focus() is not able to go  as low as autofocus is. For example, with full zoom (100) lowest possible focus value is 1300, which is still blur, and setting higher value only makes it worse. So the correct value is probably somewhere under 1300

Are these minimum values defined somewhere in CHDK?
CHDK doesn't have a zoom dependent limit. It is possible to define hard limits, but they aren't defined for the ixus160 port.

A couple more questions:
When you tried zooming to 100, have you tried doing this manually with the camera buttons vs using set_zoom?
If you focus with AF at a distance you can focus with set_focus, what does get_focus return?

FWIW, my elph130 appears to be able to set_focus at about the same distance as minimum AF, around 1300 mm. It doesn't appear to be affected by zoom method used.

That's not to say the IXUS160 does not have it's own MF problems.  But it's far from perfect on most other Powershots.
I think what gaphill described is something quite different: The focus distance *range* accessible to set_focus is different from what the canon AF can do.
Don't forget what the H stands for.


Re: IXUS160/ELPH160 Porting attempt
« Reply #478 on: 20 / August / 2016, 20:32:16 »
I think what gaphill described is something quite different: The focus distance *range* accessible to set_focus is different from what the canon AF can do.
Could be different. 

But my ongoing theory is that Canon AF does a closed loop focus based on "rate of change" contrast that does not "know" the actual distance.  Our set_focus() hack invokes some sort of open loop setting of the lens mecha position - probably via a internal table lookup or linear function on Canon's part.  On the better cameras with actual MF,  Canon takes steps to calibrate this function but the low end Powershots just get a guesstimate. 

So MF accuracy involves a lot of luck.  And it would thus make sense that the "focus distance *range* accessible to set_focus is different from what the canon AF can do."

Or maybe I'm blowing smoke.  After a couple of years chasing this, I don't know.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: IXUS160/ELPH160 Porting attempt
« Reply #479 on: 21 / August / 2016, 05:29:50 »
When you tried zooming to 100, have you tried doing this manually with the camera buttons vs using set_zoom?
If you focus with AF at a distance you can focus with set_focus, what does get_focus return?

set_zoom() vs. manually behaves the same. Here's kind of "minimum session" of how to get focus confused:
___> c
connected: Canon IXUS 160, max packet size 512
con> rec                       # After this driving to max zoom manually
con 1> rs                      # Result: sharp image
con 4> luar return get_focus()
5:return:1300
con 5> luar set_focus(1300)
con 6> rs                      # Result: blur image
con 9> luar return get_focus()
10:return:1300


On the second question: I used zoom 0 where manual focus works. Located subject at to distance 300, 400 and 500 and half-pressed shutter until the focus indicator turned green. Then immediately red get_focus(). Here's what I got: 300 -> 260,  400 -> 320,  500 -> 380

It looks like values set by autofocus are somewhat constantly smaller than the actual distance. Probably not the source of the problem but might just make it worse.

Waterwingz theory matches with this test: I set zoom into 44. Lowest possible focus value seems to be 1014, which (assuming focus number equals subject distance) feels way too high. With half press, the camera is able to autofocus into subject at distance 400, producing nice sharp picture. And the camera still thinks the focus value is 1014 when queried by get_focus(). So it really looks like the camera has no clue about the actual distance, it just (intelligently) drives the focus motor back and forth until the centerpiece of the image is sharp enough.

So it looks like mf mecha positions (and more importantly the limits of it) might well be generated by some left-hand-crafted function or table.

Is it somehow possible to set/query mecha position from lua? (I'm willing to take the risk of damaging the camera) Or is there some not-extremely-hard way to overwrite camera-given limits of focus value? (of course if there is a table which just ends too early then it does not help)

 

Related Topics