Improvements to press, click, release for shooting keys - page 2 - General Discussion and Assistance - CHDK Forum supplierdeeply

Improvements to press, click, release for shooting keys

  • 48 Replies
  • 8331 Views
*

Offline lapser

  • *****
  • 1093
Re: Improvements to press, click, release for shooting keys
« Reply #10 on: 28 / December / 2012, 16:12:21 »
Advertisements
@lapser,
How about a new set of functions (different names) like
waterwingz says, and they can be conditionally compiled
for the sx260 where they can be tested for a while
Another good idea. For testing, I was thinking of adding a function that activates the new shoot_full_only changes. That way, it could be tested on any camera by adding the activate call at the top of any script, and then see if the script still works.
Quote
I find your C functions and scripts very interesting. Thanks
for putting time on them. I hope you continue experimenting with these functions.
Thanks. I'll eventually get this shot interval thing working, with everyone's help. My time lapse test last night produced some pretty nice video, and some new insights on how to get it to work better:
http://chdk.setepontos.com/index.php?topic=8997.msg94890#msg94890
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline philmoz

  • *****
  • 3128
    • Photos
Re: Improvements to press, click, release for shooting keys
« Reply #11 on: 28 / December / 2012, 17:35:41 »
When I think of it, though, the only problem that really needs fixing is with press("shoot_full_only"), or more specifically:

action_push_press(key) //when key==KEY_SHOOT_FULL_ONLY

I think everything would work right if I save shutter_open_tick_count when you press shoot_full_only, and then wait until it changes before continuing. I can back this up with a check for raw_save_file being called, possibly with a state_shooting check if I can find one... and also a check for video mode.

shoot_full_only isn't really a button, it's the way you press a button. You can't use it by itself to stop/start video, so that shouldn't be a problem. But the change would allow this:

Here is the original thread that gave rise to the 'shoot_full_only' option which may help clarify why this seemingly useless function exists - http://chdk.setepontos.com/index.php?topic=1444.msg13111#msg13111

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)

*

Offline reyalp

  • ******
  • 12148
Re: Improvements to press, click, release for shooting keys
« Reply #12 on: 28 / December / 2012, 17:45:16 »
edit:
The following response is a bit flamey. I don't mean to cause personal offense. I certainly appreciate that lapser has put a lot of effort into digging into the shooting code, and I hope useful improvements will result.
--

The key press/click/release functions have a simple, easily understood and well defined behavior. They simulate physical manipulation of the keys, as closely as possible.

Changing this to have some other special behavior for some keys is not acceptable. I will reject any patch which does this. I strongly urge the everyone with commit access to do the same.

I hope this is clear.
Quote
That's a good point that "shoot_full" in video mode doesn't take a photo. There's already a test for that:
This is an *example* of why pressing a button should not be tied to shooting specific behavior. I specifically stated that I didn't consider adding yet more special cases to be an appropriate solution

Quote
Moving the wait loop to C can give a significant improvement in how fast the shot is taken. I've been doing some timing experiments as part of my shot histogram research.
If this is the case, then the script interface should be improved rather than adding spaghetti to the keyboard code. This bug may be relevant http://chdk.setepontos.com/index.php?topic=7611.msg81072#msg81072

http://chdk.wikia.com/wiki/Script_commands#set_yield may also be relevant, although if you are in a sleep loop that sleeps I don't think it should be significant.

Quote
Simplifying scripts isn't the major reason for these changes, but I don't think it's a trivial accomplishment. Reducing script code and moving it to C code saves memory and speeds execution
No, moving script logic to core code takes away memory from everyone who doesn't need that particular bit of logic. Raw execution speed should not be a concern with lua, it's very fast. If script is actually too slow, that likely indicates a problem somewhere rather raw execution speed being too slow.
Quote
It also makes script writing easier to learn. click("shoot_full" and "shoot_full_only") should take a shot as quickly as possible every time, not require a lot of extra code and delays to get it to work most of the time.
I disagree with this completely. Making keyboard functions not actually keyboard functions makes them substantially more confusing. click("shoot_full") is not the equivalent of shoot, it's the equivalent of clicking the shutter button, which does not always successfully shoot.
« Last Edit: 28 / December / 2012, 18:09:37 by reyalp »
Don't forget what the H stands for.

*

Offline lapser

  • *****
  • 1093
Re: Improvements to press, click, release for shooting keys
« Reply #13 on: 28 / December / 2012, 18:07:30 »
Here is the original thread that gave rise to the 'shoot_full_only' option which may help clarify why this seemingly useless function exists - http://chdk.setepontos.com/index.php?topic=1444.msg13111#msg13111
I didn't meant it was useless! I meant it's not used for video, so modifying it shouldn't break any scripts. In fact, it's my favorite button, since it allows fast shooting without releasing shoot_half.

The only problem with it is that there's no way to tell when the camera is ready to accept a press("shoot_full_only") so that it always takes a picture. You can't wait for get_shooting() because it's always true when shoot_half is pressed. But if you wait until the shutter opens after you press("shoot_full_only"), then it always takes a picture. So anytime in shoot_half that you want to take a picture, you just click("shoot_full_only") and it works. My current diff file already does this, which is why this works:

Code: (lua) [Select]
press("shoot_half")
repeat sleep(10) until get_shooting()
repeat
  click("shoot_full_only")
until false
So if I modify my changes so they only affect shoot_full_only, it should make everyone happy. It would fix the missed shots problem you identified in the thread you referred to:

On the G12 if I set Interval (Seconds) to 1 I only get every 2nd image - is this normal (set to 2 it's fine).
Phil.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


*

Offline lapser

  • *****
  • 1093
Re: Improvements to press, click, release for shooting keys
« Reply #14 on: 28 / December / 2012, 19:16:53 »
For example there are 4 capt_seq.c files that don't call capt_seq_hook_set_nr and 6 where the call is commented out. So for at least 10 cameras your AS_WAIT_SHUTTER code will never exit and the action_stack will hang.
Here's the perfect solution to this problem:
Code: (C) [Select]
extern int shutter_open_tick_count;  // changes when shutter opens
  //stays 0 for cameras without capt_seq_hook_set_nr()

static int shutter_open_tick_count0=1; // to detect the change

// Can only be called from an action stack
void action_push_press(long key)
{
    // WARNING stack program flow is reversed
    if((key==KEY_SHOOT_FULL_ONLY)&&(shutter_open_tick_count)) //always false for unsupported cameras
    {
      action_push(AS_WAIT_SHUTTER); //wait for shutter
      shutter_open_tick_count0=shutter_open_tick_count;//to detect change
    }
    else action_push_delay(CAM_KEY_PRESS_DELAY); //cameras without capt_seq_hook_set_nr() do this
    action_push(key);
    action_push(AS_PRESS);
}
    case AS_WAIT_SHUTTER:
        if ((shutter_open_tick_count0!=shutter_open_tick_count)
         || MODE_IS_VIDEO(mode_get()))
            action_pop();
        break;
You don't need to wait for the shutter to open for the first picture. This way, AS_WAIT only waits on cameras that update shutter_open_tick_count, so cameras without the hook won't hang (but they'll work the old way).
« Last Edit: 28 / December / 2012, 20:59:57 by lapser »
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: Improvements to press, click, release for shooting keys
« Reply #15 on: 28 / December / 2012, 19:25:42 »
@lapser :   We need to find a better way to package what you are working on.  Something like a ""fast intervalometer" lua module added to the standard distribution (props to reyalp for that suggestion).    It should capture what you've done without changing existing simple well defined functionality.  It could make the spot exposure readings / modified histogram readings / ready for next full_press logic etc available to a Lua script so that others can do clever things with it too.  You are on the right track - it just needs to get integrated a little bit differently once you've sorted out what can be done.  People here can help.


(they can help better if they can track all the threads you've spread this across of course .. I think that I mentioned that earlier ??)


« Last Edit: 28 / December / 2012, 19:28:38 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: Improvements to press, click, release for shooting keys
« Reply #16 on: 28 / December / 2012, 20:01:11 »
@lapser :   We need to find a better way to package what you are working on. 
(they can help better if they can track all the threads you've spread this across of course .. I think that I mentioned that earlier ??)
OK, when (if?) I get something working right with the time lapse and shot histo meters, we can figure out if and how to integrate it. You're the experts there. I'm not familiar with putting code into modules, so I'll have to figure that out after it's working.

This shoot_full_only fix is separate from the shot metering and time lapse stuff. I think it could be added to the trunk soon, without breaking anything. That's why it's in a different thread.  It's a simple, well-defined change, and complements the addition of the "shoot_full_only" button a year ago. I think I've addressed all the problems brought up here so far, including the unsupported camera problem (see my last post). I'm not changing anything but press("shoot_full_only") and shoot() now, so all the buttons should work the same as before. I'll do some tests and report back.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline reyalp

  • ******
  • 12148
Re: Improvements to press, click, release for shooting keys
« Reply #17 on: 28 / December / 2012, 20:07:00 »
Something like a ""fast intervalometer" lua module added to the standard distribution (props to reyalp for that suggestion).
To hopefully clarify a bit what I had in mind:
I would prefer changes in the core to be as simple and isolated as possible, exposing relatively low level building blocks to script. If additional logic is need to provide a friendly interface, this can be done as a Lua module and included in the distribution.
Don't forget what the H stands for.


Re: Improvements to press, click, release for shooting keys
« Reply #18 on: 28 / December / 2012, 20:07:50 »
I think I've addressed all the problems brought up here so far, including the unsupported camera problem (see my last post).

When philmoz said this :

The main problem with a change like this is it's impossible to test across every camera. For example there are 4 capt_seq.c files that don't call capt_seq_hook_set_nr and 6 where the call is commented out. So for at least 10 cameras your AS_WAIT_SHUTTER code will never exit and the action_stack will hang.

he was just giving one example of the problem with the change you are suggesting.  What other problems are out there ?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 12148
Re: Improvements to press, click, release for shooting keys
« Reply #19 on: 28 / December / 2012, 20:36:57 »
This shoot_full_only fix is separate from the shot metering and time lapse stuff. I think it could be added to the trunk soon, without breaking anything.
The key functions should manipulate key state, period. As I explained in my earlier post, I am extremely unlikely to accept a patch that makes them do something else or change their behavior based on shooting state.

At the moment, I not entirely clear on what problems your change is supposed to solve. If you can clearly set out what you are trying to accomplish, that may help us suggest more appropriate solutions.

If I've understood correctly, the basic idea is that you want to know when you can press shoot_full_only again to start the next exposure. If this is the case, then the solution should be:
1) Identify state available to CHDK which actually reflects this. This may vary by camera model, shooting mode or other settings, so there is no guarantee this state is actually available in a reliable way. Note that the remote capture project will provide some additional possibilities when it is complete.
2) Find the simplest way to either make this available to script, or expose a function that uses it to the desired effect. As explained in my previous post, I greatly prefer the former.

In several posts you have mentioned "the" shoot bug, but I'm not clear what this actually refers to. If you can describe the specific bug you are referring to (or link to previous reports) that would be helpful.
Don't forget what the H stands for.

 

Related Topics