Remote photography - How can I send control scripts

  • 2 Replies
  • 1465 Views
Remote photography - How can I send control scripts
« on: 24 / April / 2014, 17:45:58 »
Advertisements
Longtime lurker, first time poster.

I have been able to control my TX-1 and my Elph cameras remotely using CHDKptp software on my computer and the CHDK on my cameras.

Can I send commands from my computer to the camera to do the following:
  • Turn on (I already know the answer is no but that would have been cool
  • Zoom the lens to a certain distance
  • Set the focus to a certain value
  • Adjust the aperture or change the ISO to a certain value
  • Possibly set the white balance (not very important though)
  • Keep the flash off
  • Take a photo and transfer it to the computer
  • Turn the camera off

Currently, it looks like I'll have to supply external power and semi-permanently hold the power button down (possibly damaging the power button in the process but that's something I can live with) to turn the device on.
Can someone step me through some handholding on this? I imagine that I should write a lua script on the computer and send it to the camera and then execute it. Is that the best way? I can't even figure out how to send a script from the chdkptp software to the camera. Ideally, settings would stay the same every time I power the camera on until I decide to change something. This suggests leaving the lua script on the camera and setting it to run at startup. I guess that when I want to change a setting, I rewrite the script and I send over the new one.

The whole point of this is to put it in a remote place (without mains power). Currently I am using my computer as the control unit but I will probably try to build it on a beagle bone or something like that.

Also, I saw some notes on power savings by turning off the screen. That is definitely something I would like to do so I will attempt that after figuring all this out.

So, I know that I am asking a lot of the community to help a noob out with such detailed questions  :-[ but any help is certainly appreciated. If you don't have time to spell it out for me, can you let me know where I may be going wrong? Thank you.

*

Offline reyalp

  • ******
  • 11436
Re: Remote photography - How can I send control scripts
« Reply #1 on: 24 / April / 2014, 23:13:37 »
Turn on (I already know the answer is no but that would have been cool
Correct. Some very old cameras can power on when USB power is applied, but even for that, you would need software control of the USB power on your PC.
Quote
Zoom the lens to a certain distance
set_zoom(number) or click('zoom_in')  a certain number of times.

Quote
Set the focus to a certain value
Use the set_focus() function, but be warned this has issues and behaves differently on different cameras. It also behaves differently between CHDK 1.2 (the stable builds) and 1.3 (the development branch) See this thread: http://chdk.setepontos.com/index.php?topic=11078.0

I don't think we have test data for TX1, so it would be very helpful if you can run the test script on that camera.

Quote
Adjust the aperture or change the ISO to a certain value
Can be done with normal script functions, found in the scripting cross reference below. However, as noted in the PTP scripting page, these will not take effect if set in separate PTP calls. This may also apply to set_focus depending on the CHDK version and whether the camera is in MF, aflock or auto mode.

Quote
Possibly set the white balance (not very important though)
We don't have a way to set arbitrary whitebalance values.
Quote
Keep the flash off
If you turn it off using the canon settings, I think it should stay off.

Quote
Take a photo and transfer it to the computer
There are several ways to do this. chdkptp has two commands, shoot and remoteshoot.

remoteshoot shoots and transfers over USB without saving to the SD card, but this is currently not supported on all cameras (the ones with YES in the FWT column of http://chdk.wikia.com/wiki/CameraFeatureTable) If your camera isn't supported, it's possible someone here can add support.

shoot just shoots normally, saving on the card, but you can use the -dl and -rm options to download the file and delete it from the card.

Both these commands let you set the tv, av and ISO. Use help shoot in chdkptp for more info. Setting focus is currently not supported, but it could be set beforehand, at least on some cameras. I will try to add a focus distance option soon, but as mentioned above focus overrides have issues that can be camera dependent.

You can also send script to shoot and then download separately.
Quote
Turn the camera off
use the shut_down() function.

There is a list of script functions at
http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page
and some information about scripting with PTP at http://chdk.wikia.com/wiki/Lua/PTP_Scripting

Quote
I imagine that I should write a lua script on the computer and send it to the camera and then execute it. Is that the best way? I can't even figure out how to send a script from the chdkptp software to the camera.
In chdkptp, you send lua code with the lua (.) or luar (=) commands. The difference is the second one waits for the code to finish. These just send code, they don't directly run a file, but your code can run a file that is on the camera, as in the example in the PTP scripting page:

Code: [Select]
.loadfile('A/CHDK/SCRIPTS/yourscript.lua')()
If you want to change settings, you wouldn't have to upload the script, you could set them as variables before the loadfile, like
Code: [Select]
.a=1 b=2 loadfile('A/CHDK/SCRIPTS/yourscript.lua')()
and then use and a and b to do things like set your shutter speed and iso or whatever.

If you shoot using this approach, you will need to use separate chdkptp commands later to download the files. You can use the mdownload command to download files matching specific patterns, and rm to delete.

There are other approaches you could take:
Just run a sequence of commands in chdkptp. You can run the commands from a file (using the chdkptp source command) or pipe the output of another program to chdkptp. So you could do something like

chdkptp -c -e"source myfile"
where myfile contains
Code: [Select]
rec
=set_zoom(3)
shoot -dl -tv=1/200 -iso=100
Since shoot doesn't currently have a focus option, setting focus with this approach may be tricky. The best bet would probably be to set the camera to manual focus or afflock (using 1.3) and call set_focus() before the shoot command.

Quote
The whole point of this is to put it in a remote place (without mains power). Currently I am using my computer as the control unit but I will probably try to build it on a beagle bone or something like that.
I provide chdkptp builds for raspberry pi. Building similar platforms should not be terribly hard, if you don't require the GUI.

Quote
Also, I saw some notes on power savings by turning off the screen. That is definitely something I would like to do so I will attempt that after figuring all this out.
This is another complicate topic I'll leave for another post...
Don't forget what the H stands for.

*

Offline jules

  • **
  • 73
Re: Remote photography - How can I send control scripts
« Reply #2 on: 24 / April / 2014, 23:19:26 »
Hopefully you can run your computer control as you want with the expert advice from reyalp above.

Maybe I've not understood your requirements properly, but just wondering if you considered a less complex way of running your remote camera? 

The simple way: install ultimate intervalometer script (or another intervalometer) on your CHDK camera. The  script lets you set when (periods of the day, days of the week) and how often photos are taken, and some shooting parameters. It offers various methods of turning off the screen for power saving.

Then you only need to connect external power (e.g. SLA battery with voltage adaptor to suit your camera) and you can leave the camera to run unattended in a remote location for days/weeks. No external controller and no need to hold down the power button.
 
How long it will run unattended of course depends on your shooting schedule, memory card, battery capacity. If feasible for you to go to your remote site at suitable intervals (say, weekly) to change the battery and download/replace memory card, then this could be a reasonable option.

Good luck with your project and maybe you can say more about the requirements.
« Last Edit: 24 / April / 2014, 23:40:00 by jules »

 

Related Topics