Lua Scripting (lua.mo)

Started by dmilligan, March 29, 2015, 04:44:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dmilligan

the Lua bindings are in these files:
modules/lua/lua.c
modules/lua/lua_battery.c
modules/lua/lua_camera.c
modules/lua/lua_common.h
modules/lua/lua_console.c
modules/lua/lua_constants.c
modules/lua/lua_display.c
modules/lua/lua_dryos.c
modules/lua/lua_globals.c
modules/lua/lua_interval.c
modules/lua/lua_key.c
modules/lua/lua_lens.c
modules/lua/lua_lv.c
modules/lua/lua_menu.c
modules/lua/lua_movie.c
modules/lua/lua_property.c
modules/lua/lua_task.c

You can also use bitbucket to look at a diff of the branch:
https://bitbucket.org/hudson/magic-lantern/branch/lua#diff

garry23

Sorry, I still can't find the source.

I've looked everywhere.

For example, I can't find this file: modules/lua/lua_lens.c

Sorry to be a pain and thick, but can you give me an explicit link to: modules/lua/lua_lens.c

Cheers

dmilligan


garry23


[email protected]

Hi

Is it possible to trigger video on the 5D mark2 for time lapse purposes using lua scripting?

Thanks
Katrina

dmilligan


[email protected]

Thanks for your reply Dave

I had a look at the link

What is meant to go between the brackets in the lines

Start () and stop ()

Is that a video duration or a time interval?

I have not installed, reviewed, scripted or done anything before with Magic Lantern and I'm a bit uncertain that I can write a script

Is there a script already written which will trigger record for 20 seconds every day - with an interval of 24 hours?

Thanks again
Katrina

dmilligan

movie.start() and movie.stop() don't take any parameters. To record a 20s movie you can do something like this:


movie.start()
msleep(20000)
movie.stop()


For more info see this example: http://davidmilligan.github.io/ml-lua/examples/recdelay.lua.html

Taking a video once a day may be some trouble, as you can't really keep LiveView on that long (even if you could it probably wouldn't be a good idea).

[email protected]

Thanks again

if LiveView needs to be on for the script to run, this solution probably won't work for me then.

Can Live view not be switched on by the script?

Sorrry, as I said, I have no experience in this?

I believe that there is a light sensor interveralometer available - which might work better

Thanks again
Katrina

dmilligan

You can turn on and off photo LV, but there's no way to switch to movie mode/LV. Programmatically switching Canon modes is possible (there was an old feature called movie mode remap), but it is dangerous and has caused cameras to be temporarily bricked, so all such capability has been removed from ML.

You can pause LV though. I suppose this works in movie LV. I don't know if this will prevent the camera from shutting off LV after 30 mins or not (there is a way that's been implemented for raw recording, but it is not currently exposed for scripts).

[email protected]

Thanks again for letting me know the limitations and functions...

However, I'm sorry but I am still not sure if I should proceed in getting ML and trying to create this script - perhaps there is somebody else who is doing this or has tried it?

If not - what's your advice - do you think I should try the script or not?

Thanks
Katrina

Walter Schulz

What are your requirements?

As far as I could find out right now:
- You have a cam, 5D2. Unattended. No one is looking after it for quite some days/weeks/months ...
- All 24 hours there is a 20 second video shot to be taken.

Corrections and more details, if necessary, please.
Do you have an external power supply?

[email protected]

Hi

All the above mentioned is correct, the camera is locked in place and powered by the AC adapter, the scene is an old house in ruin which is slowly being taken over by vegetation.

I have a series of these type of shoots to perform for a film, which is still in development. (lots of ruin, decay and renewal)

I have never used ML, but I met an Italian in the Azores last week who was very certain ML would work 8)...

I tried firstly doing time lapse photos with an intervalometer - taking a pic every 5 minutes for several weeks and trying to bracket and select only the pics in similar light  - but the light here in Ireland is way too sporadic... no two days are ever the same and with natural shadows changing on the door frames etc - it just didn't work.

Currently I am visiting the house frequently and shooting video myself, which is then taken into the adobe premiere and dissolves into each other to see the transition - but this is not a good long term solution.

I have no other information - only if you think it will work and can support me I would love to try it.

Thank you again
Katrina

Walter Schulz

Tried to find another solution but failed. Problem with 5D2 is - as dmilligan pointed out - you have to enable Liveview in movie mode. There are cams not having this problem. 7D for instance has a movie mode switch and with switch set will startup in movie mode.

You tried Auto-ETTR to solve exposure problem using stills?

[email protected]

Thanks Walter

NO, I didn't try  Auto-ETTR - I have never used ML at all.

I will look into it - but, from a quick scan I don;t know if that will even work... bearing in mind the sun's position, height, cloud cover etc - I used can't see photo solution working - even though it would be nice... maybe if I get the correct funding decision this month I might buy the 7D and keep it for time lapse - are you confident it will work with the 7D? - is there a cheaper camera that it would work on?

Thanks again for your help
Katrina

a1ex

The easiest - and portable - way to shut down LiveView in movie mode is to go to play mode (and then turn the display off).

On 5D2, there's no dedicated hardware switch for movie mode. So, on the contrary - on this camera, enabling and disabling movie mode can be done without problems, since the only way to do it is from the menus. The 50D is very similar. All the other cameras have a hardware switch, so you can't safely switch between photo and movie mode from ML (that switch is handled by a secondary processor, which we don't fully understand yet - the MPU - so faking the mode dial position on the main CPU is not enough, though it seems to work at first sight).

Walter Schulz

Thanks, a1ex, for correction!

Setup in mind:
----
Timer for AC adapter, cam switched to ON. Timer will startup cam. ML + modules will run (Debug tab -> Modules debug -> Load modules after crash ON). Loading script
- Wait short time
- Start movie recording
- After 20 seconds stop movie recording

Wait some minute and timer will cut power.

----
Any errors within this concept?


rambler

@Katrina
It seems you intend to run a very long timelapse. I doubt anyone has tested this with a DSLR. Note that cameras are not designed to run for months on end, so it is probable, or almost certain, that it will fail after some days or weeks. And since it is possible to damage a DSLR programmatically, you may not want to try. It may be possible to use a trick long since known for P&S Canons in the CHDK community: if the power switch is set to "on" and power is applied, the camera will go "on". Thus, with a programmable power supply, the camera can be switched on for only the duration required to take a couple of shots or a short video. This works on 550D, but I have no idea if it works on the others. And I have a gut feeling that it a dangerous practice with a DSLR.

May I suggest you consider another, far cheaper alternative: rather than use a Canon DSLR with ML, think of a Canon P&S with CHDK, where long timelapses is a proven and well tested concept. For the price of a DSLR you can get half a dozen of decent P&S. Video quality will probably be not as good, unless you pick one of the high-end models, which are expensive though. But then, are you sure you need video, 20s every day? Why not a still shot, or a few of them, which can then be combined into a nice hi-res timelapse video? If you need further advice on this, ask nicely at the CHDK forum, explaining your project and needs, and a few nice people out there will surely be more than happy to provide you with any general or practical advice.

garry23

Just to add my input to rambler's; having used CHDK with scripting (S95 and G11), I have to agree that it a very serious option for those doing 'unusual' things, ie away from 'normal' timelapse sequences. Especially if money is an issue ;-)

I found the CHDK scripting environment very accessible.

As I say: just my humble view.

Cheers

Garry

Totte

OK, finally time to play with this: I've checked out the LUA branch and compiled it for the 5D2 on my Linux machine. I end up with an empty doc folder but I've assumed that I can ignore that for now.

I copy everything from the zip file to my ML card and after enabling the LUA module I find the LUA Menu Test under Debug, but I don't see a separate LUA menu. After copying the scripts/lib folder from the source to the CF card I also see the Sokoban game with its own menu. I guess the make file will eventually be updated to include this folder in the zip target?

So where am I supposed to select which of the other scripts in the scripts folder to run, like how to invoke editor.lua? Is it just me being stupid, or am I still missing some vital LUA component on the CF card, or should I be investigating my build environment and make output?

Thanks for any help!

Licaon_Kter

See my reply to dmilligan here ( modify your ML and rerun make ): https://bitbucket.org/hudson/magic-lantern/issue/2297/shoot-mode-ca-and-hdr-backlight-control#comment-18586259


I guess you are missing the /scripts/LIB folder maybe?

Totte

Yes I was missing the /scripts/lib folder but like I said I copied it manually and then got to the point where I can play Sokoban ;D

Now trying to figure out where/how to run the rest of the LUA scripts in the scripts folder. Being all new to LUA I wouldn't be able to tell how this is supposed to work.

Licaon_Kter

Those scripts that make a menu are visible ( sokoban, copy2m ).
I actually cloned copy2m and use it's framework to do something else, but a word of warning, if you do that either remove the original script from the card/folder or rename the menu/functions if not it will loop and eventually freeze/crash ( it did on my M so your results may vary ).

Totte

That makes sense, except that I don't see any trace of copy2m. Only Games is added to the top menu, with Sokoban as a sub-item. I guess I can make a copy of Sokoban and see how that goes. Thanks for the warning about the naming!

Does anyone have another precompiled LUA-compatible binary for the 5D2 that behaves better? If so I would gladly jump to learning and running LUA scripts ASAP.

dmilligan

All scripts are run immediately on startup. They may or may not have menu items, and their menus can show up anywhere. copy2m shows up in the 'Prefs' menu, several of the other scripts show up in the Debug menu, some scripts may not even have a menu item

I would suggest turning the 'console' on (Debug >Modules debug > Show Console), any errors are going to be logged there. There should also be messages about scripts being loaded and other informational things.

I've also greatly expanded the general lua documentation so see http://davidmilligan.github.io/ml-lua/