focus in multilapse.lua (was Re: Setting focus from scripts or menus) - General Discussion and Assistance - CHDK Forum supplierdeeply

focus in multilapse.lua (was Re: Setting focus from scripts or menus)

  • 26 Replies
  • 14372 Views
*

Offline Sdack

  • ***
  • 195
Advertisements
Hey Reyalp,

The Sun has changed position in the sky over the last few months, to the point where late in the afternoon, it's highlighting the specs of dust on the glass in front of my extended time lapse rig and causing the camera to refocus, blurring the main focus of the images from this


to this


I would like to adjust the focusing part of the multilapse.lua script to force the camera to infinite focus.

Better still would be to add this as an option in the multilapse-config.lua file
I looked hard and long at it but couldn't figure out how to extract the focus loop from the nest of BV loops.
Thanks for any help
Cheers
Sdack
« Last Edit: 18 / April / 2018, 15:14:41 by reyalp »

*

Offline reyalp

  • ******
  • 14079
Re: focus in multilapse.lua (was Re: Setting focus from scripts or menus)
« Reply #1 on: 18 / April / 2018, 15:24:36 »
Hey Reyalp,

I would like to adjust the focusing part of the multilapse.lua script to force the camera to infinite focus.

Better still would be to add this as an option in the multilapse-config.lua file
I looked hard and long at it but couldn't figure out how to extract the focus loop from the nest of BV loops.
Thanks for any help
Cheers
Sdack
I split this from the SD override thread https://chdk.setepontos.com/index.php?topic=11078.550 since it's really specifically about multilapse and not the CHDK functions in general.

Despite the name, the try_focus stuff doesn't have anything to do with the focus of the shot. It's just waiting for halfpress to be ready to get the Bv. Since half press is released, whatever happens in that loop will have no impact on the focus of the following shot.

The shots are taken with -sd=100000 which should be the focus distance in meters. Whether -sd= works on your camera depends on the specifics of the port. I think the conclusion in thread was that it does work on ixus160, but if you need to set MF or AF lock to get focus override to work, you will need to call set_mf(true) or set_aflock(true) somewhere, like the commented example in camera_init.

To set the focus distance in the config file, you'd just need to insert the value in the  -sd= commands.
Don't forget what the H stands for.

*

Offline Sdack

  • ***
  • 195
Re: focus in multilapse.lua (was Re: Setting focus from scripts or menus)
« Reply #2 on: 13 / August / 2018, 21:41:53 »
Hi @manoweb and @reyalp
I am configuring a new Multilapse rig for extended deployment and I'm trying to achieve 1 image every half hour.

So I've created a bunch of cron jobs which kick off Multilapse every half hour, followed two minutes later by a killall command to kill the Multilapse process, then after another minute, a killall for the chdkptp process.

I've also set the image interval in multilapse-config.lua to a very high number (980 seconds if I remember correctly), expecting this interval to be sufficient for the killall commands to happen and shut the camera down before a second image gets taken.

However this only seems to work for part of the time.  Sometimes I'm getting two images shot within the three minutes as follows

 Aug  9 06:43 ecolapse-2018-08-09-06.43.54.jpg
 Aug  9 07:00 ecolapse-2018-08-09-07.00.19.jpg
 Aug  9 07:30 ecolapse-2018-08-09-07.30.18.jpg
 Aug  9 08:00 ecolapse-2018-08-09-08.00.19.jpg
 Aug  9 08:30 ecolapse-2018-08-09-08.30.19.jpg
Aug  9 08:32 ecolapse-2018-08-09-08.32.05.jpg
 Aug  9 09:00 ecolapse-2018-08-09-09.00.19.jpg
 Aug  9 09:30 ecolapse-2018-08-09-09.30.19.jpg
 Aug  9 10:00 ecolapse-2018-08-09-10.00.18.jpg
 Aug  9 10:30 ecolapse-2018-08-09-10.30.19.jpg
Aug  9 10:32 ecolapse-2018-08-09-10.32.04.jpg
 Aug  9 11:00 ecolapse-2018-08-09-11.00.36.jpg
 Aug  9 11:30 ecolapse-2018-08-09-11.30.36.jpg
 Aug  9 12:00 ecolapse-2018-08-09-12.00.36.jpg
 Aug  9 12:30 ecolapse-2018-08-09-12.30.19.jpg
 Aug  9 13:00 ecolapse-2018-08-09-13.00.18.jpg
 Aug  9 13:30 ecolapse-2018-08-09-13.30.19.jpg
 Aug  9 14:00 ecolapse-2018-08-09-14.00.19.jpg
 Aug  9 14:30 ecolapse-2018-08-09-14.30.18.jpg
Aug  9 14:32 ecolapse-2018-08-09-14.32.04.jpg
 Aug  9 15:00 ecolapse-2018-08-09-15.00.36.jpg
 Aug  9 15:30 ecolapse-2018-08-09-15.30.19.jpg
 Aug  9 16:00 ecolapse-2018-08-09-16.00.35.jpg
 Aug  9 16:30 ecolapse-2018-08-09-16.30.18.jpg
 Aug  9 17:00 ecolapse-2018-08-09-17.00.19.jpg
 Aug  9 17:30 ecolapse-2018-08-09-17.30.37.jpg
 Aug  9 18:00 ecolapse-2018-08-09-18.00.23.jpg

It makes me wonder if the interval is somehow remembering elapsed time, such that a fraction of 980 seconds is eaten away each half hour until there's a short enough time (ie. less than three minutes when the killall chdkptp command kicks in) that the camera takes a second shot.

I understand that the Raspberry Pi lacks a real time clock but still it's pretty accurate in my experience.  Certainly it wouldn't count 980 seconds in less than 3 minutes

Any insights would be appreciated.

Cheers
Sdack
« Last Edit: 13 / August / 2018, 21:57:50 by Sdack »

Re: focus in multilapse.lua (was Re: Setting focus from scripts or menus)
« Reply #3 on: 13 / August / 2018, 22:05:37 »
So I've created a bunch of cron jobs which kick off Multilapse every half hour, followed two minutes later by a killall command to kill the Multilapse process, then after another minute, a killall for the chdkptp process.
So I just have to ask.  Would it not be a lot cleaner to simply modify the script to shoot once and then shut itself down?  Or shoot every half hour?  What am I missing here?
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline Sdack

  • ***
  • 195
Re: focus in multilapse.lua (was Re: Setting focus from scripts or menus)
« Reply #4 on: 13 / August / 2018, 22:18:07 »
Hi Waterwingz,
Thanks for taking notice.
It would certainly be cleaner but, as a total novice in lua, I'm hesitant because to be honest, I'm concerned I'll stuff it up.

Due the long interval, I like the lens being retracted for most of the time in between shots, which killing the process achieves.

I also suspect the interval may be subject to change, so being more comfortable in cron, I thought my solution was simple enough to work.  It's ugly, undoubtably but it should at least work and, if I'm wrong headed about the way Raspberry Pi handles intervals, it'd be good to find out.
Sdack
PS. Regarding my other query. I've done a few tests on power draw with miser2 but I'm going to repeat them.  My new AliExpress wattmeter arrived this morning.

Re: focus in multilapse.lua (was Re: Setting focus from scripts or menus)
« Reply #5 on: 13 / August / 2018, 22:23:46 »
Due the long interval, I like the lens being retracted for most of the time in between shots, which killing the process achieves.
The Canon firmware will do that automatically for you if switched to playback mode between shots.

Quote
PS. Regarding my other query. I've done a few tests on power draw with miser2 but I'm going to repeat them.  My new AliExpress wattmeter arrived this morning.
I have a newer version of the script that lets you more easily setup the various power saving combinations.  If you are planning on doing some testing, I'll take some time to finish testing it.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14079
Re: focus in multilapse.lua (was Re: Setting focus from scripts or menus)
« Reply #6 on: 13 / August / 2018, 23:27:31 »
I've created a bunch of cron jobs which kick off Multilapse every half hour, followed two minutes later by a killall command to kill the Multilapse process, then after another minute, a killall for the chdkptp process.
I would highly recommend not doing it this way. Modify the script to do what you want. You just need to ensure the main loops in the shell script and lua file only run once. There are two levels of loop in the lua file, because it tries to restart the camera if there's an error.

You should be able to make the loops run exactly once by putting a break before each loops end statement.
Quote
It makes me wonder if the interval is somehow remembering elapsed time, such that a fraction of 980 seconds is eaten away each half hour until there's a short enough time (ie. less than three minutes when the killall chdkptp command kicks in) that the camera takes a second shot.
I don't know off hand what is causing the problem, but I very much doubt it has anything to do with the pi time keeping. The lack of RTC mainly just means it doesn't keep time across reboots.

The multilapse interval is done in the lua code. If you kill off the instance of chdkptp running the lua code, there's really no way it can influence the next instance of chdkptp. Any clock drift will apply to both your cron jobs and chdkptp.

The multilapse shell script will try to kick off the chdkptp process again if chdkptp dies, but you say you are killing it first so in theory that shouldn't be the problem.
Don't forget what the H stands for.

*

Offline Sdack

  • ***
  • 195
Re: focus in multilapse.lua (was Re: Setting focus from scripts or menus)
« Reply #7 on: 14 / August / 2018, 00:09:58 »
OK guys,
I'm rolling up my sleeves now.
Thanks for the pointers.
backs up scripts and draws a deep breath...
Sdack


*

Offline Sdack

  • ***
  • 195
Re: focus in multilapse.lua (was Re: Setting focus from scripts or menus)
« Reply #8 on: 14 / August / 2018, 00:40:09 »
Quote
I have a newer version of the script that lets you more easily setup the various power saving combinations.  If you are planning on doing some testing, I'll take some time to finish testing it.
That sounds great.. just so you know, the Enable AF Lock setting wouldn't work with my IXUS160.  It just didn't take any pictures at all.

It took me a while to figure it out, then i found the script autorun ONCE setting which meant I could proceed a lot quicker.  Previously I'd been setting autorun to 'on' then having to pull the SD card out, set it to writeable, pop it into my PC then rename the script, to prevent it from running every time I powered the camera on.  It was like wading through mud.

I'm hacking into this Multilapse now and hoping to find a way to switch to record mode inbetween shots as you suggested.

My fingers are crossed but I'm not too hopeful.  I struggle to even understand the documents when I'm trying to figure stuff out.
Sdack

*

Offline reyalp

  • ******
  • 14079
Re: focus in multilapse.lua (was Re: Setting focus from scripts or menus)
« Reply #9 on: 14 / August / 2018, 01:33:29 »
I'm hacking into this Multilapse now and hoping to find a way to switch to record mode inbetween shots as you suggested.
I'm not following this. I thought what you were trying to do was make multilapse take one shot, do you can schedule your shots with cron. I suggest tackling one piece at a time.

If you have things setup so the turnon and turnoff commands control power to the camera, multilapse will power it up at startup and shut it down when it ends.

If you don't have software control of power to the camera, multilapse should still switch to rec mode at the start, but you will need to replace the code that tells the camera to shut down
Code: [Select]
cli_cmd([[. sleep(1000) post_levent_to_ui('PressPowerButton')]])
with something that switches it to playback
Code: [Select]
cli_cmd('play')
Don't forget what the H stands for.

 

Related Topics