Auto Focus with Live View Button

Started by benpascoe, March 05, 2013, 11:04:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

benpascoe

I originally posted about this in the General Help Q&A section but yesterday I got around to making a PicoC script and could do with some help to make it work a little better.

My Issue: I shoot surf photo's in the water with a fisheye (Tokina 10-17mm), the housing I have for my Canon 60D gives me access to the following controls: top scroll wheel, shutter button (manually and via a cable release on a pistol grip) and the live view button.

To focus above water I just set it to infinity and disable half press for auto focus, for below water I need to auto focus temporarily to get the virtual image from the dome port in focus, so shooting above and below in one session is not possible with my housing as it is.

The script uses the Live View button to auto focus for a certain period (I think 1 second will be enough but I haven't tried it out in the sea yet):


Here is my code, it does what I want it to but I don't really understand the important bits, I've just copied and pasted from the examples and tested it in the camera until it worked the way I wanted.

I'm actually amazed I got it to work, all down to the excellent examples in this forum, so a huge thanks for taking the time to write them and make them available.



/*
@title Focus With LV Button
@param n Focus duration in seconds
@range n 1 5
@default n 1
*/

while(1)
{
    int key = wait_key();

    if (key == LV) // when Live View button is pressed
{
console_hide(); // hide the script console

set_af(1); // enable AF for half-shutter press

press(SHOOT_HALF); // emulate half shutter being pressed
sleep(n); // hold button for n seconds
unpress(SHOOT_HALF); // emulate releasing half shutter

set_af(0); // disable AF for half-shutter press
}

    sleep(0.1);

}


The problem is, now the script runs until I switch the camera off, this isn't really an issue for me as I intend to leave it running until I finish shooting and take the camera out of the housing, but I assume there's a simple way to make it end the script

I've also written another script that allows me to use the Live view button to give me access to change the Aperture and ISO as well as the shutter speed which is something that I never thought I'd be able to do with my basic water housing, but I have the same problem as this script: not being able to exit.

I tried a couple of things to make it quit when I pressed a different button but I couldn't get it to work without an error message, is there some easy way to exit the script when I press the SET button?

Kent

I have not tested it but maybe this can be used,, while (wait_key() != SET);
5D3 , EF 100 2.8L Macro, EF 24-105 4L, EF 70-200 2.8L IS, EF 400 5.6L, 580 EX II's, RRS BH-55, Gitzo GT5532LS, Pixel King's, ZOOM H4N

benpascoe

Thanks for the suggestion, I have just tried it, I didn't know where to put it in the script so I tried it at the very end and inside the last set of brackets but both times it caused the script to work weird and still didn't allow me to exit the script when pressing the SET button.

I am going to stick with this bit which I put inside the last set of brackets:

    if (key == SET)
{
return(1);
}


That at least lets me end the script, even if it is with an error message, and allows the rest of it to work fine until I press SET.

Kent

Try to replace    while(1)    with    while (wait_key() != SET);
tried it and it seems to work.
5D3 , EF 100 2.8L Macro, EF 24-105 4L, EF 70-200 2.8L IS, EF 400 5.6L, 580 EX II's, RRS BH-55, Gitzo GT5532LS, Pixel King's, ZOOM H4N

benpascoe

Thanks, just tried it, it ends the script when I press the SET key with no error, but I have to press it twice, and it doesn't focus when I press the LV button any more.

I will try it in a different script later to see if I can get it working.

EDIT: I have now fixed it so it exits the script when the SET button is pressed with no error, and the LV button works as it should too, here's the finished code in case anyone's interested:


// Select duration of auto focus when live view button is pressed, default is 1 second

/*
@title Focus With LV Button
@param n Focus duration in seconds
@range n 1 5
@default n 1
*/

while(1)
{
    int key = wait_key();

    if (key == LV) // when Live View button is pressed
{
console_hide(); // hide the script console

set_af(1); // disable AF for half-shutter press

press(SHOOT_HALF); // emulate half shutter being pressed
sleep(n); // hold button for n seconds
unpress(SHOOT_HALF); // emulate releasing half shutter

set_af(0); // enable AF for half-shutter press
}

    sleep(0.1);

    if (key == SET)
{
break;
}
}