Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - zLOST

#26
I don't want to mess with images, but prefer to give the lens details to the camera itself and let it do its job (if possible, of course), which should be the safe way, i suppose. Theoreticaly the point is to emulate chipped lenses with lua in a way, that there is no difference in those for the original camera firmware.

The other way is to write a script, which will use exiv2/exiftool to process existing xmp files and store/update corresponding exif keys of matching files.

But a si wrote before - having the camera do this automatically is preferable way for a lazy ass like me :)

Quote from: aprofiti on January 25, 2019, 06:57:17 PM
By the way, I would like to have aperture overridden in Photo menu... it would be useful to remember and check what value selected from the script.
You mean this one?




Prob is, that each adapter may behave in a different way depending on presence and version of the chip. And we'd have to override this behavior by giving the camera a list of available apertures to choose from. Which may technically be the same as setting the lens name and focal length.

For the serial number - i had no idea it can get this complicated :) And in this area i'm of sub-zero use as i don't have experience with C..
#27
At the moment i've got these:

-- predefined xmp properties
xmp.lens_make           = { name = {"exif:LensMake","exifEx:LensMake"},                         format = "%s" }         -- Exif.Photo.LensMake  Ascii  This tag records the lens manufactor as an ASCII string.
xmp.lens_name           = { name = {"exif:LensModel","exifEx:LensModel"},                       format = "%s" }         -- Exif.Photo.LensModel  Ascii  This tag records the lens's model name and model number as an ASCII string
xmp.lens                = { name = {"aux:Lens","exif:Lens"},                                    format = "%s" }
xmp.lens_serial         = { name = {"exif:LensSerialNumber","exifEx:LensSerialNumber"},         format = "%s" }         -- Exif.Photo.LensSerialNumber  Ascii  This tag records the serial number of the interchangeable lens that was used in photography as an ASCII string.
xmp.focal_length        = { name = "exif:FocalLength",                                          format = "%d/1" }       -- Exif.Image.FocalLength  Rational  The actual focal length of the lens, in mm.
xmp.FNumber             = { name = "exif:FNumber",                                              format = "%d/10" }      -- Exif.Image.FNumber  Rational  The F number.
xmp.apertureValue       = { name = "exif:ApertureValue",                                        format = "%d/10" }      -- Exif.Photo.ApertureValue  Rational  The lens aperture. The unit is the APEX value.
xmp.MinApertureValue    = { name = "exif:MinApertureValue",                                     format = "%s/10" }      -- Exif.Photo.MinApertureValue  Rational  The highest F number of the lens. The unit is the APEX value. Ordinarily it is given in the range of 00.00 to 99.99, but it is not limited to this range.
xmp.MaxApertureValue    = { name = "exif:MaxApertureValue",                                     format = "%s/10" }      -- Exif.Photo.MaxApertureValue  Rational  The smallest F number of the lens. The unit is the APEX value. Ordinarily it is given in the range of 00.00 to 99.99, but it is not limited to this range.
xmp.lens_specification  = { name = {"exif:LensInfo","exif:LensSpecification","exifEx:LensSpecification"},       format = "%s" }         -- Exif.Photo.LensSpecification  Rational  This tag notes minimum focal length, maximum focal length, minimum F number in the minimum focal length, and minimum F number in the maximum focal length, which are specification information for the lens that was used in photography. When the minimum F number is unknown, the notation is 0/0


And they are initialized with this:

function add_properties() -- {{{
        xmp:add_property(xmp.lens_make,                 function() return (lens.make or "-- unknown --") end)
        xmp:add_property(xmp.lens_name,                 function() return lens.name end)
        xmp:add_property(xmp.lens,                      function()
                        if lens.make ~= nil then
                                return lens.make.." "..lens.name
                        else
                                return lens.name
                        end
                end)
        xmp:add_property(xmp.focal_length,              function() return (lens.focal_length) end)
        xmp:add_property(xmp.apertureValue,             function() return (apex(lens.manual_aperture)*10) end)
        xmp:add_property(xmp.FNumber,                   function() return (lens.manual_aperture*10) end)
        xmp:add_property(xmp.MaxApertureValue,          function()
                        local max_aperture      = (lens.max_aperture or lens.manual_aperture)
                        if lens.f_values ~= nil then
                                local Fns       = lens.f_values
                                max_aperture    = Fns[1]
                        end
                        return (apex(max_aperture)*10)
                end)
        xmp:add_property(xmp.MinApertureValue,          function()
                        local min_aperture      = (lens.min_aperture or lens.manual_aperture)
                        if lens.f_values ~= nil then
                                local Fns       = lens.f_values
                                min_aperture    = Fns[#Fns]
                        end
                        return (apex(min_aperture)*10)
                end)
        xmp:add_property(xmp.lens_serial,               function() return lens.serialN end)
        xmp:add_property(xmp.lens_specification,        function()
                        local focal_min = (lens.focal_min or lens.focal_length)
                        local focal_max = (lens.focal_max or lens.focal_length)
                        local FminL     = (lens.FminL or lens.manual_aperture)
                        local FmaxL     = (lens.FmaxL or lens.manual_aperture)
                        return string.format("%s/1 %s/1 %s/1 %s/1", tostring(focal_min), tostring(focal_max), tostring(FminL), tostring(FmaxL))
                end)
end -- }}}
               
add_properties()


If we could generate more data in order to make the camera FW happy, i'll gladly do it :)

And as a bit of a motivation, here goes my beloved 50mm Trioplan...
#28
Quote from: aprofiti on January 22, 2019, 08:00:34 PM
Happy to hear this!
Please report any strange behaviour if you plan to use it in the next days.

Well, i'm using my camera only for shooting - no high-level magic, so i'm afraid i'm of no use when it comes to testing..

Quote from: aprofiti on January 22, 2019, 08:00:34 PM
Nice idea! May be useful to make code a little bit shorter if we add the new tags. Will look into it :)
Would like to know if inserting the same information but with different namespace can make any editing software angry or not, as what I understood from your post, each software looks at different tags in the xmp.
Is possible to make a short recap on which tags each software use?
We could fill .xmp using different namespace (aux, exif, exifEx ) for the same information (name, aperture...) If there aren't any problems.
Can't find this in exiftool's tag list. It may be this instead:

0xa432 LensInfo rational64u[4] ExifIFD (4 rational values giving focal and aperture ranges, called LensSpecification by the EXIF spec.)

Found other example in other forum which use "exifEx:"... Which one is to use?

I'm using http://www.exiv2.org/tags.html and http://www.exiv2.org/tags-xmp-exifEX.html as a reference.. And i've only noticed the exifEx:LensModel in darktable forums, hence i do not know which other keys we could use for other editors.

Quote from: aprofiti on January 22, 2019, 08:00:34 PM
What do you need exactly?

My aim is/was to "fake" as much data as possible and if there is a way we could make the camera believe, that these values came from the lenses directly instead, so they get saved with another exif data in the image header, then go for it. That would make them instantly available for all image editors at once..
#29
Quote from: zLOST on January 21, 2019, 11:02:21 PM
Not yet. This was like the second or third time i've run it so far. But it might be a nice feature to have the output format configurable for individual editors (including the filename, but in DT case it would require some troubleshooting why the heck io.* crashes when working on files with two suffixes).

Seems like we'd need completely different format.. But it might be doable as well ;) I'll play with it a bit tomorrow..
(this is a part of pp3 file used as meta storage by RT, which may be of some use for us)

[LensProfile]
LcMode=lfauto
LCPFile=
UseDistortion=true
UseVignette=true
UseCA=true
LFCameraMake=
LFCameraModel=
LFLens=


I've just tested it and the LCCamera and LFLens fields are used to store the data related to chosen correction profile, but i assume, that these are used after the profile is selected by user or when there is a profile matching Lens.Name from Exif.

So i'm afraid, that as long as we don't have the "faked" data in exif, this is a not going to help.
#30
Quote from: Walter Schulz on January 21, 2019, 10:56:17 PM
Have you contacted rawtherapee dev(s) about this? In the past we had some friendly contact with user heckflosse to solve some issues.

Not yet. This was like the second or third time i've run it so far. But it might be a nice feature to have the output format configurable for individual editors (including the filename, but in DT case it would require some troubleshooting why the heck io.* crashes when working on files with two suffixes).

Seems like we'd need completely different format.. But it might be doable as well ;) I'll play with it a bit tomorrow..
(this is a part of pp3 file used as meta storage by RT, which may be of some use for us)

[LensProfile]
LcMode=lfauto
LCPFile=
UseDistortion=true
UseVignette=true
UseCA=true
LFCameraMake=
LFCameraModel=
LFLens=

[MetaData]
Mode=1

[Exif]
Exif.UserComment=user comment. blabla

[IPTC]
Caption=iptc description...;
CaptionWriter=;
Category=;
City=;
Copyright=;
Country=;
Creator=;
CreatorJobTitle=;
Credit=;
DateCreated=;
Headline=;
Instructions=;
Province=;
Source=;
Title=;
TransReference=;
#31
Thanks for the non-crashing build, Alessandro. It's perfect!




Unfortunately the focal length and aperture values come from exif data embeded in cr2, so it shows the defaul values from the adapter. i haven't tried the non-chipped version yet.

At the moment i'm using this xmp output (the exifEX:LensModel is the right field for DarkTable...):

<?xml version="1.0" encoding="UTF-8"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="MagicLantern">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
   xmlns:exif="http://ns.adobe.com/exif/1.0/"
   xmlns:exifEX="http://cipa.jp/exif/1.0/"
   xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
   exif:ExifVersion="0230"
   exif:FNumber="20/10"
   exif:ApertureValue="20/10"
   exif:LensModel="44-2 58mm f/2"
   exif:Lens="Helios 44-2 58mm f/2"
   exif:MaxApertureValue="2./1"
   exif:LensSerialNumber="7765411"
   aux:Lens="Helios 44-2 58mm f/2"
   exif:LensSpecification="1/1 65535/1 2./1 2./1"
   exif:FocalLength="580/10"
   exif:LensMake="Helios"
   exif:MinApertureValue="16/1"
   exifEX:LensModel="Helios 44-2 58mm f/2">
  </rdf:Description>
</rdf:RDF>
</x:xmpmeta>


Funny thing is, that when i use gimp to open cr2, it calls darktable, which then passes the processed photo back to gimp and save it as jpg, this jpeg has correct focal length and aperture in Exif.Photo. Unfortunately the Exif.Canon* fields contain 50/1.4 as reported by the adapter.


[zlost@nb-zimmermann2 ~]$ exiv2 -g Exif /media/zlost/EOS_6D/DCIM/101CANON/test.jpg |grep -i -e focal -e FNumber -e aperture|sort
Exif.CanonCs.DisplayAperture                 Short       1  0
Exif.CanonCs.MaxAperture                     Short       1  F1.4
Exif.CanonCs.MinAperture                     Short       1  F1.4
Exif.Canon.FocalLength                       Short       4  50.0 mm
Exif.CanonSi.ApertureValue                   Short       1  F1.4
Exif.CanonSi.TargetAperture                  Short       1  F1.4
Exif.Photo.ApertureValue                     Rational    1  F2
Exif.Photo.FNumber                           Rational    1  F2
Exif.Photo.FocalLength                       Rational    1  58.0 mm
Exif.Photo.FocalPlaneResolutionUnit          Short       1  inch
Exif.Photo.FocalPlaneXResolution             Rational    1  3810.58
Exif.Photo.FocalPlaneYResolution             Rational    1  3815.9
[zlost@nb-zimmermann2 ~]$


To ease my struggle with finding the right field to use for lens name, which will be accepted by darktable, i've modded xmp.lua, so the properties name can be a string and table/array as well to generate three lines with a single call to add_property() (feel free to call me lazy ;) )


xmp.lens_make           = { name = "exif:LensMake",             format = "%s" } -- Exif.Photo.LensMake  Ascii  This tag records the lens manufactor as an ASCII string.
xmp.lens_name           = { name = "exif:LensModel",            format = "%s" } -- Exif.Photo.LensModel  Ascii  This tag records the lens's model name and model number as an ASCII string
xmp.lens                = { name = {"aux:Lens","exif:Lens","exifEX:LensModel"},         format = "%s" }
xmp.lens_serial         = { name = "exif:LensSerialNumber",     format = "%s" } -- Exif.Photo.LensSerialNumber  Ascii  This tag records the serial number of the interchangeable lens that was used in photography as an ASCII string.
xmp.focal_length        = { name = "exif:FocalLength",          format = "%d/10" }
xmp.FNumber             = { name = "exif:FNumber",              format = "%d/10" }
xmp.apertureValue       = { name = "exif:ApertureValue",        format = "%d/10" } -- Exif.Photo.ApertureValue  Rational  The lens aperture. The unit is the APEX value.
xmp.MinApertureValue    = { name = "exif:MinApertureValue",     format = "%s/1" }
xmp.MaxApertureValue    = { name = "exif:MaxApertureValue",     format = "%s/1" } -- Exif.Photo.MaxApertureValue  Rational  The smallest F number of the lens. The unit is the APEX value. Ordinarily it is given in the range of 00.00 to 99.99, but it is not limited to this range.
xmp.lens_specification  = { name = "exif:LensSpecification",    format = "%s" } -- Exif.Photo.LensSpecification  Rational  This tag notes minimum focal length, maximum focal length, minimum F number in the minimum focal length, and minimum F number in the maximum focal length, which are specification information for the lens that was used in photography. When the minimum F number is unknown, the notation is 0/0


and the way of generating these got a bit more complicated as well..

function add_properties() -- {{{
        xmp:add_property(xmp.lens_make,                 function() return (lens.make or "-- unknown --") end)
        xmp:add_property(xmp.lens_name,                 function() return lens.name end)
        xmp:add_property(xmp.lens,                      function()
                        if lens.make ~= nil then
                                return lens.make.." "..lens.name
                        else
                                return lens.name
                        end
                end)
        xmp:add_property(xmp.focal_length,              function() return (lens.focal_length*10) end)
        xmp:add_property(xmp.apertureValue,             function() return (lens.manual_aperture*10) end)
        xmp:add_property(xmp.FNumber,                   function() return (lens.manual_aperture*10) end)
        xmp:add_property(xmp.MaxApertureValue,          function()
                        local max_aperture      = (lens.max_aperture or lens.manual_aperture)
                        if lens.f_values ~= nil then
                                local Fns       = lens.f_values
                                max_aperture    = Fns[1]
                        end
                        return max_aperture
                end)
        xmp:add_property(xmp.MinApertureValue,          function()
                        local min_aperture      = (lens.min_aperture or lens.manual_aperture)
                        if lens.f_values ~= nil then
                                local Fns       = lens.f_values
                                min_aperture    = Fns[#Fns]
                        end
                        return min_aperture
                end)
        xmp:add_property(xmp.lens_serial,               function() return lens.serialN end)
        xmp:add_property(xmp.lens_specification,        function()
                        local focal_min = (lens.focal_min or lens.focal_length)
                        local focal_max = (lens.focal_max or lens.focal_length)
                        local FminL     = (lens.FminL or lens.manual_aperture)
                        local FmaxL     = (lens.FmaxL or lens.manual_aperture)
                        return string.format("%s/1 %s/1 %s/1 %s/1", tostring(focal_min), tostring(focal_max), tostring(FminL), tostring(FmaxL))
                end)
end -- }}}

add_properties()


The unfortunate fact is, that the min/max aperture values and lens_specs don't work the way i want them to. But technically those are not important at all for normal people..
#32
Quote from: aprofiti on January 21, 2019, 02:38:38 PM
You can find the build I have in local at this download page (for 5D3,5D2,7D,6D,50D)
Should also avoid camera freezes while recording raw videos.

Awesome, thank you. I'll give it a shot when i'm back home.

In the meantime i've moved a bit forward with getting the lens model accepted by darktable and found some strange behavior of other exif metadata in dt->gimp process.
#33
Quote from: zLOST on January 20, 2019, 11:15:06 PM
Of course :) But the more stuff can be done automatically by the camera, the better for me.. I'll give it a shot with rawtherapee, but i haven't used it before, so i may fail (again).

Well, rawtherapee seems to ignore the xmp file altogether :) And the saga continues..

Btw: is there any chance to get rid of those memory-related crashes after each shot?
#34
Quote from: Lars Steenhoff on January 20, 2019, 10:54:34 PM
you can always batch rename them on the computer right ?
As long as the fie has the info you need

Of course :) But the more stuff can be done automatically by the camera, the better for me.. I'll give it a shot with rawtherapee, but i haven't used it before, so i may fail (again).
#35
It seems, that guys grom darktable insist on using originalfilename.suffix.xmp naming for xmp sidecar files :( (there is a bug opened eight years ago about this - https://redmine.darktable.org/issues/8403)

And canon/ml/lua refuses to write a file with two suffixes (at least in my case).

-- test

f = io.open("test.XMP", "a")
f:write("bleble")
f:close()

The above works fine, but when i try io.open("test.CR2.XMP") to make darktable happy, the io operation fails and subsequent f:write() crashes with "attempt to index a nil value (global 'f')".

and dryos.rename("TEST.XMP", "TEST.CR2.XMP") does not work either.

looks like i gotta slam my head against the wall a little more :)
#36
I did couple more facepalms in past few hours and it seems, that io.open() crashes when there is a CR2 as a part of the filename. I have no idea why - the debug console gets wiped out by assert crash before i can notice anything :(

So, with your code, i am able to write the xmp file to dcim...

function xmp.get_sidecar_filename() -- {{{
        local path = dryos.shooting_card.dcim_dir.path ..  dryos.image_prefix .. string.format("%04d", dryos.shooting_card.file_number) .. ".XMP"
        xmplog:write("Path:"..path)
        return path
end -- }}}


I'm using this page as a reference for exif data and the LensSerialNumber should be just a plain ascii string:
http://www.exiv2.org/tags.html

My sidecar now looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="MagicLantern">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
   xmlns:exif="http://ns.adobe.com/exif/1.0/"
   xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
   exif:ExifVersion="0230"
   aux:Lens="Helios 44-2 58mm f/2"
   exif:LensSerialNumber="7765411"
   exif:LensSpecification="1/1 65535/1 0/1 0/1"
   exif:LensMake="Helios"
   exif:MinApertureValue="97/1"
   exif:LensModel="Helios 44-2 58mm f/2"
   exif:FNumber="14/10"
   exif:MaxApertureValue="97/1"
   exif:FocalLength="58/1">
  </rdf:Description>
</rdf:RDF>
</x:xmpmeta>


Unfortunately darktable completely ignores the provided lens name and shows some default Canon set lenses.
#37
Those are the default values from the adapter/camera, which are stored in exif. So the xmp file was not processed at all.

Can you rename the xmp file to test.xmp and try it again, please?
#38
cr2+corresponding xml can be downloaded at https://www.zlej.net/sample.zip

It still seems to me, that during/after the exposure some lens{} parameters are being overwritten with defaults either from camera or the chipped adapter..

Quote from: Lars Steenhoff on January 19, 2019, 01:48:25 PM
Interesting finds!

I can test in adobe camera raw if you can share a sample of the footage with the lens data you captured.
#39
I've just found what was wrong when setting params for my Samyang - lens.serial is expected to be integer, but this lens has string..




(two hours and numerous edits of lens.lua+xmp.lua later)
I'm finally able to write the xmp file. Unfortunately only to the root of SD card - for some reason it still crashes when i try to use the dryos path, even when it looks fine.
Could someone with LR/PS/anything else verify that this format is acceptable by software other than darktable&gimp? ;)
<?xml version="1.0" encoding="UTF-8"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="MagicLantern">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:exif="http://ns.adobe.com/exif/1.0/"
    xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
    exif:ExifVersion="0230">
   <exif:LensModel>Samyang 85mm f/1.4 AS IF UMC</exif:LensModel>
   <exif:FocalLength>85/1</exif:FocalLength>
   <exif:MaxApertureValue>F1.4</exif:MaxApertureValue>
   <exif:FNumber>14/10</exif:FNumber>
   <exif:LensSpecification>10/10 655350/10 0/1 0/1</exif:LensSpecification>
   <exif:LensSerialNumber>A217D0264</exif:LensSerialNumber>
   <exif:LensMake>Samyang</exif:LensMake>
   <exif:MinApertureValue>F22</exif:MinApertureValue>
  </rdf:Description>
</rdf:RDF>
</x:xmpmeta>


LensSpecification is still showing wrong string (it should be "min_focal max_focal Fmax@min_focal Fmax@max_focal"), but i'll polish that one out, plus it's absolutely unimportant for anyone but me.

As a workaround for the serial number i've renamed "serial" in lenses{} to serialN, which is handled as string() by default, so i'm able to access it in xmp() and save. I suppose, that the serial==number() limitation is hardcoded somewhere in ML sources, right?

I've added four more params to lenses{}:
1] max_aperture and min_aperture, which are used to trim down the list of available Fnumbers plus they'll end up in the <exif:M[in|ax]ApertureValue>F22</exif:M[in|ax]ApertureValue> elements

2] FminL, FmaxL - apertures on wide/long ends of zoom lenses if they differ. Used in LensSpecification field.

Btw: i've checked exif data of my pics and the Exif.Photo.LensModel is really just a model without the lens brand (pics taken with trioplan were labeled by my old bash script):

exiv2 -g Exif.Photo.LensModel *.CR2|sed -e "s/^.*Ascii *.*  //"|sort|uniq -c|sed -e "s/^ *//" -e "s/ /x /"
2x EF17-40mm f/4L USM
435x EF-S10-18mm f/4.5-5.6 IS STM
102x Meyer-Optik Görlitz Trioplan 50mm f/2.9
7x MP-E65mm f/2.8 1-5x Macro Photo
#40
So, i wrote a simple dumper script and tested all the adapters i found with it:


-- Lens properties dump

require("config")
require("logger")

local log = logger("adapter.log")

for k,v in pairs(lens) do
        if k ~= "focus" then
                if type(v) == "string" then
                        log:write("lens."..k.."="..v)
                elseif type(v) == "boolean" or type(v) == "number" then
                        log:write("lens."..k.."()="..tostring(v))
                elseif type(v) == "function" then
                        r = v()
                        if type(r) == "string" then
                                log:write("lens."..k.."()="..r)
                        elseif type(r) == "boolean" or type(r) == "number" then
                                log:write("lens."..k.."()="..tostring(r))
                        end
                elseif type(v) == "table" then
                        for a,b in pairs(v) do
                                log:write("lens. "..k.."."..a.."="..b)
                        end
                end
        end
end


There was a little hope in finding some way to differentiate between each one of them (some should be "programmable" and of different versions as i bought each separately in past few years).
Unfortunately with no luck:


===============================================================================
ML/SCRIPTS/ADAPTE~1.LUA - 2019-1-18 23:51:36 ----> no chip at all (Samyang 85/1.4)
===============================================================================

ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:51:37 - lens.name=
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:51:37 - lens.focal_length()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:51:37 - lens.focus_distance()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:51:37 - lens.hyperfocal()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:51:38 - lens.dof_near()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:51:38 - lens.dof_far()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:51:38 - lens.af()=false
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:51:38 - lens.af_mode()=3
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:51:38 - lens.autofocus()=false

===============================================================================
ML/SCRIPTS/ADAPTE~1.LUA - 2019-1-18 23:52:55 ----> with AF chip (M42 -> EOS)
===============================================================================

ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:52:55 - lens.name=1-65535mm
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:52:55 - lens.focal_length()=50
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:52:55 - lens.focus_distance()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:52:55 - lens.hyperfocal()=61676
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:52:55 - lens.dof_near()=561148697
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:52:55 - lens.dof_far()=1000000
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:52:55 - lens.af()=false
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:52:55 - lens.af_mode()=3
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:52:56 - lens.autofocus()=false

===============================================================================
ML/SCRIPTS/ADAPTE~1.LUA - 2019-1-18 23:53:16 ----> with AF chip (M42 -> EOS)
===============================================================================

ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:16 - lens.name=1-65535mm
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:16 - lens.focal_length()=50
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:16 - lens.focus_distance()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:16 - lens.hyperfocal()=61676
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:16 - lens.dof_near()=561148697
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:16 - lens.dof_far()=1000000
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:16 - lens.af()=false
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:16 - lens.af_mode()=3
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:16 - lens.autofocus()=false

===============================================================================
ML/SCRIPTS/ADAPTE~1.LUA - 2019-1-18 23:53:42 ----> Sigma 50/2.8 DG Macro (AF turned on)
===============================================================================

ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:42 - lens.name=EF50mm f/2.5 Compact Macro
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:42 - lens.focal_length()=50
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:42 - lens.focus_distance()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:42 - lens.hyperfocal()=30888
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:42 - lens.dof_near()=-340372800
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:42 - lens.dof_far()=1000000
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:42 - lens.af()=true
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:42 - lens.af_mode()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:53:45 - lens.autofocus()=false

===============================================================================
ML/SCRIPTS/ADAPTE~1.LUA - 2019-1-18 23:54:29 ----> with AF chip (praktica B -> EOS)
===============================================================================

ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:29 - lens.name=1-65535mm
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:29 - lens.focal_length()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:29 - lens.focus_distance()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:29 - lens.hyperfocal()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:29 - lens.dof_near()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:29 - lens.dof_far()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:29 - lens.af()=false
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:29 - lens.af_mode()=3
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:29 - lens.autofocus()=false

===============================================================================
ML/SCRIPTS/ADAPTE~1.LUA - 2019-1-18 23:54:53 ----> with AF chip (another M42 -> EOS)
===============================================================================

ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:53 - lens.name=1-65535mm
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:53 - lens.focal_length()=50
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:54 - lens.focus_distance()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:54 - lens.hyperfocal()=61676
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:54 - lens.dof_near()=561148697
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:54 - lens.dof_far()=1000000
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:54 - lens.af()=false
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:54 - lens.af_mode()=3
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-18 23:54:54 - lens.autofocus()=false


lens.focus was crashing and i was too lazy to search for a way to dump it correctly, so it's omitted from the output :)

@aprofiti] my "deep dive" is more of an endless circle of "hack->save->start the camera->facepalm->hack..." :)

So far i've "tweaked" a bit the xmp.lua, logger.lua and lens.lua.

------

Selecting a lens from the list results in this to be logged:

===============================================================================
ML/SCRIPTS/LENS.LUA - 2019-1-19 00:20:22
===============================================================================

ML/SCRIPTS/LENS.LUA: 2019-01-19 00:20:30 - selector_instance:8
ML/SCRIPTS/LENS.LUA: 2019-01-19 00:20:30 - Update_lens: focal_length: 29
ML/SCRIPTS/LENS.LUA: 2019-01-19 00:20:30 - Update_lens: manual_aperture: 2.8
ML/SCRIPTS/LENS.LUA: 2019-01-19 00:20:30 - Update_lens: name: auto 29mm f/2.8
ML/SCRIPTS/LENS.LUA: 2019-01-19 00:20:30 - Update_lens: serial: 6308110
ML/SCRIPTS/LENS.LUA: 2019-01-19 00:20:30 - Update_lens: make: Pentacon


Lens.* dumper shows:

===============================================================================
ML/SCRIPTS/ADAPTE~1.LUA - 2019-1-19 00:33:20
===============================================================================

ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-19 00:33:20 - lens.name=auto 29mm f/2.8
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-19 00:33:20 - lens.focal_length()=29
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-19 00:33:20 - lens.focus_distance()=0
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-19 00:33:20 - lens.hyperfocal()=30888
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-19 00:33:20 - lens.dof_near()=-340372800
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-19 00:33:20 - lens.dof_far()=1000000
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-19 00:33:20 - lens.af()=false
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-19 00:33:20 - lens.af_mode()=3
ML/SCRIPTS/ADAPTE~1.LUA: 2019-01-19 00:33:20 - lens.autofocus()=false


And xmp.lua with write() modified to only log what it should be writing to xmp file logs:

===============================================================================
ML/SCRIPTS/LIB/xmp.lua - 2019-1-19 00:33:06
===============================================================================

ML/SCRIPTS/LIB/xmp.lua: 2019-01-19 00:33:37 - Writing xmp file...
ML/SCRIPTS/LIB/xmp.lua: 2019-01-19 00:33:37 - key: exif:LensSpecification=0/10 0/10 0/1 0/1
ML/SCRIPTS/LIB/xmp.lua: 2019-01-19 00:33:37 - key: exif:LensSerialNumber=0
ML/SCRIPTS/LIB/xmp.lua: 2019-01-19 00:33:37 - key: exif:FNumber=14/10
ML/SCRIPTS/LIB/xmp.lua: 2019-01-19 00:33:37 - key: exif:MaxApertureValue=F1.4
ML/SCRIPTS/LIB/xmp.lua: 2019-01-19 00:33:37 - key: exif:MinApertureValue=Fnil
ML/SCRIPTS/LIB/xmp.lua: 2019-01-19 00:33:38 - key: exif:LensModel=Pentacon auto 29mm f/2.8
ML/SCRIPTS/LIB/xmp.lua: 2019-01-19 00:33:38 - key: exif:LensMake=Pentacon
ML/SCRIPTS/LIB/xmp.lua: 2019-01-19 00:33:38 - key: exif:FocalLength=29/1


The modified write() looks like this:

--[[---------------------------------------------------------------------------
Writes the xmp metdata to file
@param filename optional - the filename to write to, leave blank to use the sidecar filename for the most recently taken photo
@function write
]]
function xmp:write(filename) -- {{{
--      local f = assert(io.open(filename or self.get_sidecar_filename(), "w+"))
--      assert(f:write(self.header, "\n"))

        xmplog:write("Writing xmp file...")
        for k,v in pairs(self.properties) do
                if type(v) == "function" then
                        xmplog:write("key: "..k.."="..v())
--                      assert(f:write(string.format(self.property_format, k, v(), k), "\n"))
                elseif type(v) == "boolean" or type(v) == "number" then
                        xmplog:write("key2: "..k.."="..tostring(v))
--                      assert(f:write(string.format(self.property_format, k, tostring(v), k), "\n"))
                else
                        xmplog:write("key2: "..k.."="..v)
                end
        end
        --f:write(string.format(self.template, str))
--      assert(f:write(self.footer))
--      assert(f:close())
end --- }}}


Unfortunately xmp.write() crashes when i try to let it write the xmp file and the error console is immediately wiped out by subsequent assert() crash..



#41
My point of splitting lens name to brand+type was to keep the lens.name shorter than 32 chars. We can always concatenate these two fields in UI and when exporting the xmp, where it should not matter and should be used by LR/DT/anything to detect the used lens.

Plus i'd like to add few more exif fields to the xmp output (i wrote a simple bash script to "label" my pics - https://www.zlej.net/tmp/exif.txt and it would be great to see this done automatically by ML as i tend to forget what i had attached two weeks ago when shooting some pics..)

Is there any way to scroll within the debug console? Scripts may complain about something usefull, but when the screen gets wiped out due to the assert crash, i'm lost :(

I thought, that when we "fake" the lens.[name|aperture|whatever], the canon FW will use those values when saving the exif data in cr2 or jpeg, but apparently it does not bother. Plus they use Exif.Photo and Exif.Canon* sections for similar data
#42
btw: even during those bright moments when i had the xmp file written correctly, the exif data in cr2 and jpg (when i've switched to shooting to both formats) were showing the original unaltered data.

If you'd need any help with testing, let me know - i have 650D+6D and couple of non-chipped and chipped adapters to play with.



I've also split the lens name to brand+model, so the lens name is shorter (MOG would eat 20 bytes off the name :) )

lenses = -- {{{
{
    { make = "Carl Zeiss Jena DDR",     name = "Tessar 50mm f/2.8",             focal_length = 50,      manual_aperture = 2.8,  serial = "8333263" },
    { make = "E. Ludwig",               name = "Meritar 50mm f/2.9",            focal_length = 50,      manual_aperture = 2.9,  serial = "1610554" },
    { make = "Helios",                  name = "44-2 58mm f/2",                 focal_length = 58,      manual_aperture = 2,    serial = "7765411" },
    { make = "Industar",                name = "50-2 50mm f/3.5",               focal_length = 50,      manual_aperture = 3.5,  serial = "7149595" },
    { make = "Industar",                name = "61 L/Z (MC) 50mm f/2.8",        focal_length = 50,      manual_aperture = 2.8,  serial = "8707286" },
    { make = "Meyer-Optik Gorlitz",     name = "Telemegor 180mm f/5.5",         focal_length = 180,     manual_aperture = 5.5,  serial = "1728275" },
    { make = "Meyer-Optik Gorlitz",     name = "Trioplan 50mm f/2.9",           focal_length = 50,      manual_aperture = 2.8,  serial = "2224344" },
    { make = "Pentacon",                name = "auto 29mm f/2.8",               focal_length = 29,      manual_aperture = 2.8,  serial = "6308110" },
    { make = "Pentacon",                name = "Prakticar 50mm f/1.8 MC",       focal_length = 50,      manual_aperture = 1.8,  serial = "7710425" },
    { make = "Samyang",                 name = "85mm f/1.4 AS IF UMC",          focal_length = 85,      manual_aperture = 1.4} --       serial = "A217D0264" }
--    { make = "", name = "", focal_length = , manual_aperture = , serial = "" },
} -- }}}


I also had an issue where the lens.lua had crashed when i've selected the last lens in the list - 85mm Samyang. With something like "invalid parameter #3 for __nextval(", i can't remember now and since i'm procrastinating at work, i don't have my camera with me now to replicate it at the moment ;)

and one more thing - the serial number was written as "0" even when it was set cirrectly in xmp.properties.. no idea why..
#43
Hi,

For couple of evenings I'm playing with the latest nightly build on my 6D (damned i need some sleep) and noticed some issues.

Some of the recent changes in lua library had changed contents of dryos variables and the dryos.dcim_dir.path (used in get_sidecar_filename() @ xmp.lib) does not  work anymore.
Being on linux and using daktable+gimp i have to use IMG_1234.[CR2|JPG].xmp name to have it recognized and used by DT, so i've modified the get_sidecar to:

function xmp.get_sidecar_filename() -- {{{
    return dryos.shooting_card:image_path(1) .. ".xmp"
end -- }}}


I made some changes in the XMP file format (to use the same as exiftool) and tried to save the xmp file line by line to lower the memory consumption..
Unfortunately now it crashes immediately after taking a picture (for a split of a second i can see an error with wiritng to the xmp file (which was working for me for a while, but apparently i broke something a bit later)) and all i end up with is a picture and an assert log


ML ASSERT:
0
at ../../src/mem.c:799 (__mem_malloc), task PropMgr
lv:0 mode:3

PropMgr stack: 170dc0 [170f68-16ff68]
0xUNKNOWN  @ 468a88:170e70
0x00BFD44C @ bf8b8c:170e50
0x00BFCC88 @ bfd484:170e40
0x0044F5E0 @ bfcca8:170e30
0x0044C9F4 @ 44f61c:170df0
0x0044C478 @ 44ca50:170dc0

Magic Lantern version : manual_lens_info.2018Dec23.6D116
Mercurial changeset   : 0de7b671c52c (manual_lens_info) tip
Built on 2018-12-23 22:39:23 UTC by jenkins@nightly.
Free Memory  : 384K + 1935K


At the moment my xmp stuff looks like this:


xmp.header= [[<?xml version="1.0" encoding="UTF-8"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="MagicLantern">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:exif="http://ns.adobe.com/exif/1.0/"
    xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
    exif:ExifVersion="0230">]]

xmp.footer      = [[  </rdf:Description>
</rdf:RDF>     
</x:xmpmeta>
]]

xmp.property_format = [[   <%s>%s</%s>]]

-- predefined xmp properties
xmp.lens_make           = { name = "exif:LensMake",             format = "%s" }
xmp.lens_name           = { name = "exif:LensModel",            format = "%s" }
xmp.lens_serial         = { name = "exif:LensSerialNumber",     format = "%s" }
xmp.focal_length        = { name = "exif:FocalLength",          format = "%d/1"}
xmp.aperture            = { name = "exif:FNumber",              format = "%d/10" }
xmp.apertureMin         = { name = "exif:MinApertureValue",     format = "F%s" }
xmp.apertureMax         = { name = "exif:MaxApertureValue",     format = "F%s" }

function xmp.get_sidecar_filename() -- {{{
    return dryos.shooting_card:image_path(1) .. ".xmp"
end -- }}}

....

function xmp:write(filename) -- {{{
        local f = assert(io.open(filename or self.get_sidecar_filename(), "w+"))
        assert(f:write(self.header, "\n"))

        for k,v in pairs(self.properties) do
                if type(v) == "function" then
                        self.log:write("klic:"..k.."="..v())
                        assert(f:write(string.format(self.property_format, k, v(), k), "\n"))
                else   
                        self.log:write("klic:"..k.."="..v)
                        assert(f:write(string.format(self.property_format, k, v, k), "\n"))
                end     
        end     
        --f:write(string.format(self.template, str))
        assert(f:write(self.footer))
        assert(f:close())
end --- }}}


Btw: is there a way i could test these scripts in qemu on my own? restarting the camera, mounting the sdcard, copying scripts, unmounting sdcard, starting camera is pretty exhausting and annoying especially when all i find is yet another bug in my own code :)