Author Topic: Assign lens focal length and name for non cpu lenses  (Read 36974 times)

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3212
  • 60Da / 1100D / EOSM
Re: Assign lens focal length and name for non cpu lenses
« Reply #275 on: December 30, 2017, 02:12:17 PM »
Someone can explain to me why can't get it working? I have also tried to merge into lua_fix to get latest fixes, but nothing usefull happened.

Question: Should I include also 1/3 stop values to Fnumbers? Currently if an aperture value of the lens isn't found in Fnumbers when opening Manual Lens submenu, it get set to first index (ex. aperture 4.5 not found -> set by script to 1.0)

[EDIT]
It's a problem of floating points rapresentation in lua:
Code: [Select]
1.4 -> 1.399999
2.8 -> 2.799999
4.5 -> 4.5 (ok)
5.6 -> 5.59999

Check the ftoa function in ml_lua_shim.c, it could probably be improved (maybe there's a usable implementation in dietlibc that's better). The sprintf in Canon firmware doesn't support floats at all, and we don't have a complete, standards compliant libc implementation available in ML. So for now there are hacky implementations here and there of stuff we need (space in the compiled binary is at a premium).

As a workaround you could store lens.manual_aperture as string and then when you need to use it as a number, convert it to number with tonumber().

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 10716
  • 5D Mark Free
Re: Assign lens focal length and name for non cpu lenses
« Reply #276 on: December 30, 2017, 11:13:36 PM »
Knowing where to look makes things really easy - fix committed.

Sorry, didn't test further yet.

dfort

  • Hero Member
  • *****
  • Posts: 2321
Re: Assign lens focal length and name for non cpu lenses
« Reply #277 on: December 31, 2017, 06:01:34 AM »
Lots of nice additions here but we still have a rather basic issue with the 32 character limit for the lens name. It would be great if this could be addressed.

Using @aprofiti pull request version and the latest mlv_dump from the crop_rec_4k branch.

Code: [Select]
{ name = "Zeiss Makro-Planar T* 2/100 ZF.2",     focal_length = 100, manual_aperture = 2   },
Code: [Select]
Block: LENS
  Offset: 0x00000184
  Number: 5
    Size: 96
    Time: 0.956000 ms
     Name:        'Zeiss Makro-Planar T* 2/100 ZF.'
     Serial:      '' (no valid S/N)
     Focal Len:   100 mm
     Focus Dist:  0 mm
     Aperture:    f/2.00
     IS Mode:     0
     AF Mode:     3
     Lens ID:     0x00000000
     Flags:       0x00000000

I also tried another lens with a long name and this time the Aperture isn't listed properly (float issue?): [EDIT] Merged in lua_fix with the "round to our precision" fix and the Aperture is now being displayed properly. Thanks a1ex!

Code: [Select]
{ name = "Samyang 12mm f/2.8 ED AS NCS Fisheye", focal_length =  12, manual_aperture = 2.8 }, --  12mm T3.1 Cine
Code: [Select]
Block: LENS
  Offset: 0x0000016c
  Number: 6
    Size: 96
    Time: 0.003000 ms
     Name:        'Samyang 12mm f/2.8 ED AS NCS Fi'
     Serial:      '' (no valid S/N)
     Focal Len:   12 mm
     Focus Dist:  0 mm
     Aperture:    f/2.80
     IS Mode:     0
     AF Mode:     3
     Lens ID:     0x00000000
     Flags:       0x00000000
5D3.* 7D.* 700D.115 EOSM.* EOSM2.103

aprofiti

  • New to the forum
  • *
  • Posts: 19
Re: Assign lens focal length and name for non cpu lenses
« Reply #278 on: December 31, 2017, 05:15:39 PM »
Knowing where to look makes things really easy - fix committed.

Sorry, didn't test further yet.
Really thank you a1ex! At the moment I am unable to test it, I'll try in next days.

I also tried another lens with a long name and this time the Aperture isn't listed properly (float issue?):

Code: [Select]
{ name = "Samyang 12mm f/2.8 ED AS NCS Fisheye", focal_length =  12, manual_aperture = 2.8 }, --  12mm T3.1 Cine
Code: [Select]
Block: LENS
  Offset: 0x00000184
  Number: 5
    Size: 96
    Time: 0.881000 ms
     Name:        'Samyang 12mm f/2.8 ED AS NCS Fi'
     Serial:      '' (no valid S/N)
     Focal Len:   12 mm
     Focus Dist:  0 mm
     Aperture:    f/1.00
     IS Mode:     0
     AF Mode:     3
     Lens ID:     0x00000000
     Flags:       0x00000000
Yes, It's from floating point issue. Value 1.0 is selected by Ml (first index in Fnumbers) because Aperture wasn't found in submenu choices.

Can you try with a1ex commit or by merging PR into lua_fix (use lastest lual_lens.c changes to resolve conflict)?

dfort

  • Hero Member
  • *****
  • Posts: 2321
Re: Assign lens focal length and name for non cpu lenses
« Reply #279 on: December 31, 2017, 05:45:42 PM »
Can you try with a1ex commit or by merging PR into lua_fix (use lastest lual_lens.c changes to resolve conflict)?

Just did and it is working fine now. Edited Reply #277.

I'm sounding like a broken record asking for more characters in the lens name but the main developers agreed that it should be fixed. Not that I'm complaining--just bringing @aprofiti up to speed on this. Maybe this could be incorporated into all the great changes he's making to this branch. It is after all an "Experimental" branch.  :D
5D3.* 7D.* 700D.115 EOSM.* EOSM2.103

aprofiti

  • New to the forum
  • *
  • Posts: 19
Re: Assign lens focal length and name for non cpu lenses
« Reply #280 on: January 03, 2018, 01:56:24 AM »
Updated PR with autoload functionality and made some tests to solve aperture with AF Chip.

Here is some ideas to solve issue no.2:
1. Make HALF_SHUTTER handler to works outside live view and update aperture from here (appear to be the easiest, any Hints?)
2. Change camera aperture by make it works from camera.aperture API (At the moment camera will freeze)
3. "Emulating" MPU or EF protocol messages

I'm sounding like a broken record asking for more characters in the lens name but the main developers agreed that it should be fixed. Not that I'm complaining--just bringing @aprofiti up to speed on this. Maybe this could be incorporated into all the great changes he's making to this branch. It is after all an "Experimental" branch.  :D
How many characters in lens_info.name? I think a minimum of 48-64 should be addressed to cover most lenses.
Some lenses use a very long name, especially Carl Zeiss (ex. Carl Zeiss Vario-Sonnar T* 100-300 mm f/ 4.5-5.6 C/Y -> 52 characters).

I tried with 64 byte in lens.h and after updating lua_lens.c wrapper to avoid weird aperture values, I have got full name in .xmp file but Silent Pictures wasn't working anymore (error: "Manual exposure is required."). I wasn't able to test .mlv

dfort

  • Hero Member
  • *****
  • Posts: 2321
Re: Assign lens focal length and name for non cpu lenses
« Reply #281 on: January 03, 2018, 05:09:58 AM »
How many characters in lens_info.name? I think a minimum of 48-64 should be addressed to cover most lenses.

I ran some tests a while back to see how characters are allowed in Adobe Camera Raw and I never reached a limit. The 32 character limit in MLV is too short for a lens that should work fine in ACR: "Zeiss Makro-Planar T* 2/100 ZF.2" If it could be doubled to 64 characters that should cover 99.99% of the lens names.

I tried with 64 byte in lens.h and after updating lua_lens.c wrapper to avoid weird aperture values, I have got full name in .xmp file but Silent Pictures wasn't working anymore (error: "Manual exposure is required."). I wasn't able to test .mlv

That's a common user error. Silent Pictures only works in manual exposure mode and you need to setup back button focus.

The problem with extending the lens name in MLV is that it will break some (most?) of the MLV processing apps.
5D3.* 7D.* 700D.115 EOSM.* EOSM2.103

aprofiti

  • New to the forum
  • *
  • Posts: 19
Re: Assign lens focal length and name for non cpu lenses
« Reply #282 on: January 03, 2018, 11:55:07 AM »
That's a common user error. Silent Pictures only works in manual exposure mode and you need to setup back button focus.

The problem with extending the lens name in MLV is that it will break some (most?) of the MLV processing apps.
I was in M Mode and checked Iso and Shutter time, but wasn't able to take pictures. It's first time I see this error, maybe is related to lens_info.name length? What about back button focus?

As name is internal to ML my general idea was to change his length, then check MLV should return lens name as before in LENS Block (because it copies only the first 32 characters) and then experimenting by adding ELNS Block to get a working export of full name's length. Could it works?

I'll be a little busy in next days. I don't know if I can work on it  :-\

aprofiti

  • New to the forum
  • *
  • Posts: 19
Re: Assign lens focal length and name for non cpu lenses
« Reply #283 on: January 05, 2018, 07:00:18 PM »
Got it!

Was a problem with missing '\0' in mlv.c when strncpy() of legacy lensName.
I made some tests with mlv_rec and mlv_dump and I can find "ELNS" Block and extended name using a Hex Editor, but i need to figure out why mlv_dump prints an empty name in ELNS Block.

Note: I get Black screen in LV when entering again after a raw recording. Need to test if it's a bug from those changes or not.

Also found what was the problem with Silent Pictures: I was using .mo compiled from lua_fix because in manual_lens_info branch it won't compile. I updated src and compiled it from scratch and now it's working with 64 byte lensName.

Should I commit to this branch or maybe it's better to merge PR first and then experiment with longer Lens Name?

Lars Steenhoff

  • Senior
  • ****
  • Posts: 310
Re: Assign lens focal length and name for non cpu lenses
« Reply #284 on: January 08, 2018, 11:55:53 AM »
experimenting sounds like a good way to go forward

aprofiti

  • New to the forum
  • *
  • Posts: 19
Re: Assign lens focal length and name for non cpu lenses
« Reply #285 on: January 10, 2018, 11:34:40 PM »
experimenting sounds like a good way to go forward

I still can't figure out why I get a black LV and no Ml menu when switching in and out from LV after a raw video...
LV works good when using Silent Pictures.

@a1ex or @g3gg0 Can you review this Patch to see if I missed something or there is something wrong with my camera? Problem will occur also when changing only the length of lens_info.name without implementing ELNS Block, this let me think there is something related to update.

Also I get wrong prefix for .xmp files like "NIL0185.xmp". I tried to reset Canon's config but It didn't solved the issue

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 10716
  • 5D Mark Free
Re: Assign lens focal length and name for non cpu lenses
« Reply #286 on: January 11, 2018, 12:11:35 AM »
One caveat: after changing a structure in ML core, you have to recompile all modules; otherwise, they will no longer be compatible, binary-wise. I should include this change in lua_fix before merging into unified, as that branch has the module API version already bumped (a mechanism used to prevent undefined behavior from situations like this).

Sorry, unable to test more right now; maybe over the weekend. Overall I like where this is heading.

aprofiti

  • New to the forum
  • *
  • Posts: 19
Re: Assign lens focal length and name for non cpu lenses
« Reply #287 on: January 12, 2018, 12:14:14 AM »
Sorry, unable to test more right now; maybe over the weekend. Overall I like where this is heading.

While testing again I noticed that when LV is black, pressing info button will let you switch to Canon overlay and pressing again will let you see ML overlay (it's frozen), but again on both screens no image from sensor... Like if LV wasn't correctly enabled again.

This happens also with mlv_lite which is still unmodified. Tracing lens_info.name usage in code will not help finding more functions to be updated to make they work with extended length.

Hope those infos are useful for debugging.. Let me know if you had time to check