Interval shooting without closing shutter? - Feature Requests - CHDK Forum supplierdeeply

Interval shooting without closing shutter?

  • 11 Replies
  • 9500 Views
Interval shooting without closing shutter?
« on: 13 / May / 2011, 18:32:35 »
Advertisements
I'm using CHDK on a pair of S5 IS cameras, as part of a book-scanning system (http://diybookscanner.org/forum), and because of the large number of pictures this generates, I've already worn out a couple of shutters, which cost me $130 each to replace -- almost as much as the camera itself, these days.

I need to be able to take shots at maximum resolution -- 8 MP for these cameras -- but I only need one shot every 5 seconds.

I see there are motion detection routines for taking pictures of lightning.  I assume these keep the shutter open, as video mode would, and poll (clear?) the CCD at specified intervals, looking for a threshholded change.  When it detects the change, the MD routine returns, and the calling script can elect to take a picture.

What I wonder is, is it possible to take a picture without flipping the shutter?  Just leave the shutter open, as it is in the MD routine, and clear/collect/write the CCD to the SD?  I'm using manual focus, manual aperture, and manual interval, so there's no real need for a press-half to get focus.  I'm just looking for a way to extend the life of the shutter, while taking interval pictures at maximum resolution.

Of course, it's possible that holding the shutter open for minutes or hours at a time (is that even possible?) will actually shorten its life quicker than simply opening it and closing it to take a picture, but assume for the sake of argument that it won't.  Is the low-level control available to those who actually create releases of CHDK such that what I propose is even feasible?  I realize that I would probably have to do it myself, but I'm pretty comfortable with C and ASM, so I'd be willing to give it a shot, time permitting.  I'm just hoping that someone who has more experience with the inner workings of CHDK can suggest whether or not such a thing is possible before I start digging through CHDK source code.  Thanks.
« Last Edit: 13 / May / 2011, 18:46:20 by spamsickle »

*

Offline reyalp

  • ******
  • 14117
Re: Interval shooting without closing shutter?
« Reply #1 on: 13 / May / 2011, 22:29:56 »
I'm using CHDK on a pair of S5 IS cameras, as part of a book-scanning system (http://diybookscanner.org/forum), and because of the large number of pictures this generates, I've already worn out a couple of shutters, which cost me $130 each to replace -- almost as much as the camera itself, these days.
Do you have a rough idea of how many exposures were on the camera when they wore out ? I think this would be of interest to many users.

ISTR some users have put > 100,000 shots on their cameras with timelapse scripts.

Quote
I see there are motion detection routines for taking pictures of lightning.  I assume these keep the shutter open, as video mode would, and poll (clear?) the CCD at specified intervals, looking for a threshholded change.  When it detects the change, the MD routine returns, and the calling script can elect to take a picture.
Nope, MD watches the live view (the same thing you see on the display). When it detects motion, it triggers a normal shot, shutter and all. Lesson: lighting isn't as fast as you might think ;)
Quote
What I wonder is, is it possible to take a picture without flipping the shutter?  Just leave the shutter open, as it is in the MD routine, and clear/collect/write the CCD to the SD?
We certainly don't know how to do this currently. Eventprocs have been found that allow control over the shutter (e.g. the dark frame script here http://forum.chdk-treff.de/viewtopic.php?f=7&t=2157 ) but that's not quite the same as stopping the camera from closing the shutter.

A full readout must be quite long compared to video, which might cause trouble without the shutter (otherwise, why would Canon bother with a mechanical shutter at all ?) However, I guess your could use relatively low light with the book scanner, so it might be OK.
Don't forget what the H stands for.

Re: Interval shooting without closing shutter?
« Reply #2 on: 14 / May / 2011, 08:18:51 »
Do you have a rough idea of how many exposures were on the camera when they wore out ? I think this would be of interest to many users.

ISTR some users have put > 100,000 shots on their cameras with timelapse scripts.

I don't really know.  I know I'd only put around 30,000 shots on them, but I bought both cameras "refurbished" from Canon, and I doubt that replacing a working shutter would be part of the refurbishing process.  They may have had more than 70,000 shots on them when I got them.  The reason I know I'd shot about 30,000 is that my counter rolls over at 10,000 shots, an event which requires special handling when I'm post-processing the images of the books.  If you know of an internal counter which doesn't roll over, I'd be happy to take a look, but even if such a counter exists, it wouldn't surprise me if resetting that to zero WAS part of the refurbishing process.

MD watches the live view (the same thing you see on the display). When it detects motion, it triggers a normal shot, shutter and all. Lesson: lighting isn't as fast as you might think ;)

The fact that live view exists shows that the shutter is naturally open in the "rest" state.  It appears that taking a normal shot involves clearing the CCD while the shutter remains open, accumulating the exposure, then closing the shutter before writing the image to the SD.

A full readout must be quite long compared to video, which might cause trouble without the shutter (otherwise, why would Canon bother with a mechanical shutter at all ?)

You know, that's a good question.  Why do they bother with a mechanical shutter?  Video mode is obviously not closing the shutter for every frame, and my 2 MP phone camera doesn't employ a shutter at all.  I think you're probably right, that the higher resolution means it would take so long to write the data to the SD that the exposure would be compromised if the shutter didn't enforce a physical cutoff in light accumulation.  The fact that the CCD can be cleared (I'm assuming) "instantaneously" at the beginning of the exposure suggests that the bottleneck is the speed at which the data can be read from the CCD and written to the SD.

However, I guess you could use relatively low light with the book scanner, so it might be OK.

It might be possible to employ low-light, but that would introduce noise.  In practice, I'm throwing quite a bit of light onto the pages I'm photographing.

The more I think about it, the more I think I may need to wait for technological advancement to provide CCDs and memory storage which is fast enough to take high-res shutterless pictures.  Video surveillance could probably benefit from higher resolution; I always have to laugh at the news stories which show video of a robbery in which the resolution is so low that the robber remains virtually anonymous despite having been caught on camera.

Thank you for your input; it's been very helpful.

*

Offline reyalp

  • ******
  • 14117
Re: Interval shooting without closing shutter?
« Reply #3 on: 14 / May / 2011, 15:39:28 »
I don't really know.  I know I'd only put around 30,000 shots on them, but I bought both cameras "refurbished" from Canon, and I doubt that replacing a working shutter would be part of the refurbishing process.  They may have had more than 70,000 shots on them when I got them.  The reason I know I'd shot about 30,000 is that my counter rolls over at 10,000 shots, an event which requires special handling when I'm post-processing the images of the books.  If you know of an internal counter which doesn't roll over, I'd be happy to take a look, but even if such a counter exists, it wouldn't surprise me if resetting that to zero WAS part of the refurbishing process.
There is a 'total shot' count display in the later pages of the vers.req info. It is quite possible that canon zeros it when when they service.

Quote
You know, that's a good question.  Why do they bother with a mechanical shutter?  Video mode is obviously not closing the shutter for every frame, and my 2 MP phone camera doesn't employ a shutter at all.
It's slightly more complicated an also depends on sensor design. This PDF from Kodak describes some of the variations http://www.isgchips.com/pdf/Shutter_Operations_Kodak_App_Note.pdf
Quote
I think you're probably right, that the higher resolution means it would take so long to write the data to the SD that the exposure would be compromised if the shutter didn't enforce a physical cutoff in light accumulation.
Read out to RAM, not SD.  I'm not sure how long it takes, but it must be fairly fast. A 0.5 or 1 second exposure should be very long compared to the readout time. At lowest ISO, this might produce acceptable results.

Assuming it's an interlaced (I assume so, since reading a subset of lines is how the live view/video are done AFAIK), you could also de-stripe it afterward, assuming your expose such the the more exposed fields are not saturated. This would be much better done with the raw than jpeg, which adds a lot of overhead to your workflow if you aren't already using raw.

The time spent to accomplish any this would most likely pay for a lot of shutter replacements ;)

Quote
The more I think about it, the more I think I may need to wait for technological advancement to provide CCDs and memory storage which is fast enough to take high-res shutterless pictures.
This can be done now, it's just more expensive...
Don't forget what the H stands for.


Re: Interval shooting without closing shutter?
« Reply #4 on: 14 / May / 2011, 22:54:30 »
There is a 'total shot' count display in the later pages of the vers.req info. It is quite possible that canon zeros it when when they service.
It looks like it was zeroed out when the camera was refurbished, but not when the shutter was replaced.

This PDF from Kodak describes some of the variations http://www.isgchips.com/pdf/Shutter_Operations_Kodak_App_Note.pdf
According to that document, the mechanical shutter is required because the CCD output is interlaced.  If video mode is writing each interlaced stripe as a frame, that could explain why no shutter is required for video mode. 

For my application, the subject will not change significantly between frames, so if I could only get video mode to write each interlaced stripe at maximum resolution (at a rate of one frame every five seconds, or even slightly slower if necessary) that would be a workable solution.

I guess I need to see what control over video mode CHDK provides today, and go from there.


*

Offline reyalp

  • ******
  • 14117
Re: Interval shooting without closing shutter?
« Reply #5 on: 15 / May / 2011, 01:26:10 »
According to that document, the mechanical shutter is required because the CCD output is interlaced.  If video mode is writing each interlaced stripe as a frame, that could explain why no shutter is required for video mode. 
It's a reason, but if I understand correctly, that's not the only one.
Quote
For my application, the subject will not change significantly between frames, so if I could only get video mode to write each interlaced stripe at maximum resolution (at a rate of one frame every five seconds, or even slightly slower if necessary) that would be a workable solution.
I wouldn't think the full raw lines are ever available anywhere camera software could get them. My guess is something squishes them down to 640 pixels very early on. I would also guess that video readout just reads the same subset of the available lines over and over, so you even if you could get the full width lines, you wouldn't be able to build up the full frame.

CHDK certainly can't get you anything like that today.
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Interval shooting without closing shutter?
« Reply #6 on: 15 / May / 2011, 12:38:41 »
FWIW, I was curious what the photo would look like if the shutter was open during readout, so I modified my multiexp.lua script (which controls the mechanical shutter from Lua during long exposures) to call OpenMShutter in a loop while shooting:

Code: [Select]
press("shoot_half")
repeat
  sleep(1)
until get_shooting() == true

press("shoot_full")  -- start shooting by fully pressing the shutter
tstart=get_tick_count() -- store exposure start time
repeat
  openshutter() --force shutter open even during photo readout
  sleep(1)
until (get_tick_count() - tstart ) >= exptime

release("shoot_full") -- release shutter button
sleep(1)
release("shoot_half")

It crashes with lens open right after the camera has closed the shutter for readout. Romlog points at MechaShutterActuator.c Line 158.

So that was a failed experiment, but AFAIK you do need a mechanical shutter to black out the CCD during readout even if the scene is static, because the charge from distant pixels on a row is passed through pixels closer to the readout section and all pixels are still sensitive to light during readout. People with broken shutters have posted photos on this forum before, I think...

But the question is why did you have the cameras repaired if all you want is a camera with no shutter? Did they fail to an error code? My a570 has >120k shots on its counter. A very large portion of those were with manual focus and manual exposure in timelapses or motion detect, i.e. minimal mechanical movements (= minimal amount of clicking noises during/between shots).

If you have a camera with no mechanical shutter (or manage to override it open in CHDK -- this might be possible as we are already replacing some shooting related ASM code with our own) you could build a sturdier external one or have exposure controlled by switching lights on/off (or a flash) in a dark book container box.

Re: Interval shooting without closing shutter?
« Reply #7 on: 17 / May / 2011, 14:32:15 »
I wouldn't think the full raw lines are ever available anywhere camera software could get them. My guess is something squishes them down to 640 pixels very early on. I would also guess that video readout just reads the same subset of the available lines over and over, so you even if you could get the full width lines, you wouldn't be able to build up the full frame.

CHDK certainly can't get you anything like that today.
With almost 4000 posts, I'm sure your guesses are better than mine, but what are they based on?  If the camera software can't get to them, the implication is that JPEG compression for each image size is being done in hardware.  While that may be true, it would surprise me.  I see values in str_list like JPEGBufferFull, JPEGBufferFullForMovie, and JPEGbuf.c, which suggest to me that software is involved somewhere along the line.  It's possible I'm misunderstanding where str_list.txt originated.

FWIW, I was curious what the photo would look like if the shutter was open during readout, so I modified my multiexp.lua script (which controls the mechanical shutter from Lua during long exposures) to call OpenMShutter in a loop while shooting:
[...]
It crashes with lens open right after the camera has closed the shutter for readout. Romlog points at MechaShutterActuator.c Line 158.

So that was a failed experiment, but AFAIK you do need a mechanical shutter to black out the CCD during readout even if the scene is static, because the charge from distant pixels on a row is passed through pixels closer to the readout section and all pixels are still sensitive to light during readout. People with broken shutters have posted photos on this forum before, I think...
I took a look at another thread (http://chdk.setepontos.com/index.php?topic=4337.0) to learn about your multiexp.lua script.

I also looked for documentation of an openshutter() call, but all I could find was open-shutter.bas, which doesn't seem like the same thing.  Trying to learn more about MechaShutter took me to chdk.setepontos.com/index.php?action=dlattach;topic=126.0;attach=80, which I assume is a dump of strings from the camera firmware.  In that dump, I see lots of strings like InitPB, Rec2PB, PB.Flash, PB.MHist, etc.  In a perfect world, PB would stand for "picture buffer", and I'd be on the right track.  Can you burst my thought balloon?

But the question is why did you have the cameras repaired if all you want is a camera with no shutter? Did they fail to an error code? My a570 has >120k shots on its counter. A very large portion of those were with manual focus and manual exposure in timelapses or motion detect, i.e. minimal mechanical movements (= minimal amount of clicking noises during/between shots).
It's been several months, but as I recall, they didn't fail to an error code, the shutters just froze shut.  I got them repaired because they didn't take pictures.

If you have a camera with no mechanical shutter (or manage to override it open in CHDK -- this might be possible as we are already replacing some shooting related ASM code with our own) you could build a sturdier external one or have exposure controlled by switching lights on/off (or a flash) in a dark book container box.
Assuming I did that, can you suggest how I'd get a picture from the CCD to the SD?  Are existing CHDK commands up to that task, or are "click" and "press" the only things that can currently accomplish it?


*

Offline reyalp

  • ******
  • 14117
Re: Interval shooting without closing shutter?
« Reply #8 on: 17 / May / 2011, 16:05:09 »
With almost 4000 posts, I'm sure your guesses are better than mine, but what are they based on?  If the camera software can't get to them, the implication is that JPEG compression for each image size is being done in hardware.  While that may be true, it would surprise me.
My guess is based on
1) the main CPU is two slow to do real time video compression
2) A very substantial part of the "Digic" package is taken up by stuff other than the ARM core and it's associated cache and TCM http://techon.nikkeibp.co.jp/english/NEWS_EN/20090218/165866/
3) Strings in the firmware suggest something else is doing the jpeg (and H264 on recent cameras)  processing.
4) Throughput considerations would suggest reducing the resolution as close to the sensor as possible. I would guess (and this is purely a WAG, not an informed guess like the above) that the readout hardware has a specific video (+live) view readout modes, where it reads a limited subset of lines, and for each line bins the raw values to reduce the lines to the desired horizontal resolution.
Quote
I see values in str_list like JPEGBufferFull, JPEGBufferFullForMovie, and JPEGbuf.c, which suggest to me that software is involved somewhere along the line.  It's possible I'm misunderstanding where str_list.txt originated.
There is no doubt that the arm CPU (whose ROM those strings come from) controls the process. That doesn't mean it does the actual processing.
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Interval shooting without closing shutter?
« Reply #9 on: 18 / May / 2011, 14:47:24 »
I see values in str_list like JPEGBufferFull, JPEGBufferFullForMovie, and JPEGbuf.c, which suggest to me that software is involved somewhere along the line.  It's possible I'm misunderstanding where str_list.txt originated.
As reyalp said, it's rather certain that jpeg, mjpeg, h264 are done outside the ARM core, inside the Digic. It may be a HW IP block or a programmable DSP, but either way the buffers (RAW and JPEG) are probably mapped and accessible for both the codec and the ARM core. So it's not at all surprising to find references to those in the ARM firmware -- after all it's responsible of triggering shooting, SD card writing etc.

 In some (or all, I wouldn't know) firmwares there exists compressed code that has been guessed to be code for loading to DSP program memory at startup. AFAIK, little has been done to investigate this.

I also looked for documentation of an openshutter() call, but all I could find was open-shutter.bas, which doesn't seem like the same thing. 

openshutter() is just a wrapper function defined in multiexp.lua. The required Canon firmware function (for shutter control) is different for dryos and vxworks (as are functions that initialize these functions as event procedures) so I did it that way -- at startup it checks which os the camera in question is running, initializes and defines the functions as
closeproc="CloseMShutter"
 and openproc="OpenMShutter"
 for vxworks or
closeproc="CloseMechaShutter"
 and openproc="OpenMechaShutter" for dryos.
It then uses call_event_proc() to use call these eventprocs.

From my crash, my first guess (without taking a look at the disassembly) I'd guess that Canon's functions do some sanity checking before making things happen with the hardware, and a photo readout in progress seems like a good moment to deny this. If that's the case, the check could possibly be avoided by copying some code, removing sanity checking and executing it instead of OpenMShutter / OpenMechaShutter. Naturally it should be quite clear to everyone that skipping sanity checks is potentially unsafe for the health of the camera.

In a perfect world, PB would stand for "picture buffer", and I'd be on the right track.  Can you burst my thought balloon?
In many cases (such as rec2pb) PB definitely stands for playback (play mode, as opposed to rec mode).

If you have a camera with no mechanical shutter (or manage to override it open in CHDK -- this might be possible as we are already replacing some shooting related ASM code with our own) you could build a sturdier external one or have exposure controlled by switching lights on/off (or a flash) in a dark book container box.
Assuming I did that, can you suggest how I'd get a picture from the CCD to the SD?  Are existing CHDK commands up to that task, or are "click" and "press" the only things that can currently accomplish it?
No, you'd shoot as usual. Just use exposures long enough and dark enough not to expose anything when you aren't illuminating. And maybe trigger shooting externally to sync with our light sources, or use motion detection as a trigger.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal