supplierdeeply

need to detect when the camera is done taking the picture

  • 20 Replies
  • 3357 Views
need to detect when the camera is done taking the picture
« on: 12 / January / 2015, 18:04:08 »
Advertisements
Hi all..

i have a Spherical panorama robot.  using a 110HS  camera running CHDK.
currently i use a simple script to "shoot_half"  and thus hold the AE lock, focus etc.
to get consistent exposures

and i trigger the "full press"  when detecting the USB Trigger signal  for each exposure
based on a delay routine in the robot.

like so
repeat
press "shoot_half"
if is_pressed("remote") then    
   press("shoot_full_only")
     release("shoot_full_only")
sleep(300)
   end

pretty bare bones...  but it does the job.


But now experimenting with HDR's and longer exposures.  I'm wanting to update the script
so the camera can tell the robot  when it is done taking the picture.
instead of relying on delays


i can not get  "get_shooting" to work when I'm locking the exposure etc. with "shoot_half"

Wiki:get_shooting  return boolean true if half_press active and focus+exposure is set , false otherwise

basically i need to lock the exposure to have consistent pictures. with "shoot_half"
have the camera take one or more exposures 
and when done with the image(s).  have it flash the Auto focus LED

is there any way to tell when the exposure is done.  While still using  "shoot_half" ?


Thanks

Kyndal









« Last Edit: 12 / January / 2015, 18:07:20 by kyndal »
SD1100IS 101a,  homebuilt 0.9.9-866

Re: need to detect when the camera is done taking the picture
« Reply #1 on: 12 / January / 2015, 18:19:15 »
Take a look at how this script handles what you want :

http://chdk.wikia.com/wiki/Fast_Shooter_Intervalometer

using get_exp_count() to tell when the shot has been saved to SD card.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: need to detect when the camera is done taking the picture
« Reply #2 on: 12 / January / 2015, 18:42:17 »
The Exposure counter.. 
that's Brilliant..

and it works!!
Code: [Select]

--[[
@title Pano_robot
--]]

print("Panorama robot script")
press("shoot_half")
repeat
    sleep(50)
until get_shooting() == true
set_aflock(1)

repeat
  if is_pressed("remote") then
    ecnt=get_exp_count()
press("shoot_full_only")
    release("shoot_full_only")
repeat
      sleep(20)
until(get_exp_count()~=ecnt)

status = poke(0xC0220164, 0x46, 1)  --Turn LED ON
status = poke(0xC022C028, 0x46, 1)  --Turn LED ON
sleep(300)
status = poke(0xC0220164, 0x44, 1)  --Turn LED OFF
status = poke(0xC022C028, 0x44, 1)  --Turn LED OFF
end

until ( false )



thanks a lot

/Kyndal


« Last Edit: 12 / January / 2015, 18:57:45 by kyndal »
SD1100IS 101a,  homebuilt 0.9.9-866

*

Offline reyalp

  • ******
  • 11090
Re: need to detect when the camera is done taking the picture
« Reply #3 on: 12 / January / 2015, 23:08:12 »
I'm not sure if this matters to you, but FWIW, that the exposure counter incrementing happens slightly before the jpeg is actually saved. There isn't really a good way to detect when the jpeg save is finished.

Also, sometimes
Code: [Select]
    press("shoot_full_only")
    release("shoot_full_only")
might not be enough to trigger a shot, depending on the camera and how fast you try to do it after the previous shot. If you run into that problem, you can do something like:
Code: [Select]
    press("shoot_full_only")
    repeat
       sleep(20)
    until(get_exp_count()~=ecnt)
    release("shoot_full_only")
Don't forget what the H stands for.


Re: need to detect when the camera is done taking the picture
« Reply #4 on: 13 / January / 2015, 00:02:43 »
thanks reyalp

i did have a short delay between     press("shoot_full_only")   and     release("shoot_full_only")
but while optimizing my codes.  it turns out no delay is needed.. it triggers the camera just fine like this.  (my 110hs  anyway)

my camera / card is fast enough to do continuous shooting..   relying on pictures being buffered
and processing while the robot moves..   
i'm trying to optimize time spent.
atm.  my robot can do a 180x360  in under 45 seconds..  hoping to shave this down a tad.
while adding the option of having what ever exposure length  with no need to change the robot firmware

if anybody is interested.  here is a short clip i made for a Nikon competition a while back
https://www.youtube.com/watch?v=b_b1DiRFx3A
(several generations back...(SLOOOW)  but representative of the current robot)

the script seems to work..  just working on the code for the robot. should have
it waiting for the camera pretty quick here

basically I'm replacing my fixed delay(xxxx);  with a simple sub routine 
Code: [Select]
void camera_delay(){
  while (digitalRead(photosensor) == LOW) {
    delay(50);
  }
}
I have wired the photo transistor so i get logic high when the camera LED is on.
should now wait for that and then carry on to next azimuth / elevation..
will test tomorrow

I'm also adding the option for a CHDK script to transmit configuration settings
to the robot..  via the LED / photo transistor link.   number of azimuth / elevations  and so on..

oh.. and this is the reason for this thread..
i tried to do a 180x360 spherical panorama of some northern lights in the arctic. (long exposures)..
i had run back to my room like 10 times  to change the FIXED delay before it worked out...
Nomore!!  haha

https://dl.dropboxusercontent.com/u/1644351/pano/Northern_Lights/index.html

yes... the 110HS has pretty crappy low light performance.

/Kyndal
« Last Edit: 13 / January / 2015, 00:57:38 by kyndal »
SD1100IS 101a,  homebuilt 0.9.9-866

Re: need to detect when the camera is done taking the picture
« Reply #5 on: 13 / January / 2015, 15:49:42 »
including a couple of other tweaks.  i managed to shave about 10 secs
off my sequence  with this script

takes about 35 secs  for a full 180x360  at regular shutter speeds.
and the Robot now waits for the camera..  Neat!

https://www.youtube.com/watch?v=TWPbzo4Mfio



/Kyndal
SD1100IS 101a,  homebuilt 0.9.9-866

*

Offline reyalp

  • ******
  • 11090
Re: need to detect when the camera is done taking the picture
« Reply #6 on: 13 / January / 2015, 16:25:39 »
That's awesome, really nice to see people do cool stuff with CHDK.

FWIW, if you want to know exactly when the the camera is ready to take the next shot with minimum latency, you can use the "shutter hook" described in http://chdk.wikia.com/wiki/Script_Shooting_Hooks

You can also use this to control when an exposure starts in Canon continuous mode, which may be slightly faster than holding halfpress and clicking shoot full (though it may also be slower... see http://chdk.setepontos.com/index.php?topic=11527.0)

One caveat to this is that you are committed to taking the shot when you wait for the shutter hook, so if you don't know the number of shots in advance, it can be hard to avoid ending up with an extra shot at the end.

For continuous mode the logic would look something like

press  shoot_full
repeat
  wait for shutter hook and robot to signal ready via remote
  wait for raw hook (or exposure counter increase, they are pretty much equivalent)
  use LEDs to signal the robot that it can move again
until done
release shoot_full
Don't forget what the H stands for.

Re: need to detect when the camera is done taking the picture
« Reply #7 on: 16 / January / 2015, 22:13:58 »
yes..  CHDK  is Great!   
I have been using it for years..
first version of my robot is from back in 2010   using NXT Lego's..

the Hooks option looks very interesting if i need more accurate control.
and probably even better latency.. 

but i already had to add a small delay in the script so the robot can catch up.
so i might need to look over my robot code first.. 
speed the thing up even more



/Kyndal
SD1100IS 101a,  homebuilt 0.9.9-866


Re: need to detect when the camera is done taking the picture
« Reply #8 on: 21 / January / 2015, 01:41:38 »
so I went over my Robot code and optimized it significantly.
(able to be much faster)

so I'm now hoping to shave some latency off by using the new "hooks"
basically I'm wanting to use  continuous mode for faster shooting.
and blink the led for robot movement as soon as the camera has closed the shutter..


so the first "robot trigger"   "pushes" / holds shoot_full_only

and the shooting sequence its then halted with the raw hook
and each "robot trigger" then lets it continue. one picture at a time
and it seems to work.  sorta?

but when i add my "blink_led() subroutine in there to control my robot..   
the hook halts with the LED solid on until the next trigger signal
does not blink it

cant seem to make sense of that.

Sniplet:

Code: [Select]
hook_raw.set(10000)


repeat 
  if ((is_pressed("remote")) or (is_pressed("video")))  then
   press('shoot_full_only')   --start continuous shooting

   repeat
    hook_raw.wait_ready()      --  when raw ready
    blink_led()              --  blink led

    --wait for robot to trigger

   if ((is_pressed("remote")) or (is_pressed("video")))  then 
   hook_raw.continue()
   end

   until ( false )
   
   release('shoot_full_only')
  end


i added the "video record" button for simpler testing

any suggestions ?
SD1100IS 101a,  homebuilt 0.9.9-866

*

Offline reyalp

  • ******
  • 11090
Re: need to detect when the camera is done taking the picture
« Reply #9 on: 21 / January / 2015, 02:27:48 »
but when i add my "blink_led() subroutine in there to control my robot..   
the hook halts with the LED solid on until the next trigger signal
does not blink it

cant seem to make sense of that.
What does the blink_led code look like?
Is the LED one that might be turned on or off by the canon firmware (or CHDK) while shooting?
Don't forget what the H stands for.

 

Related Topics