Reading sensor data without closing shutter? - page 4 - Script Writing - CHDK Forum supplierdeeply

Reading sensor data without closing shutter?

  • 70 Replies
  • 29613 Views
*

Offline srsa_4c

  • ******
  • 4451
Re: Reading sensor data without closing shutter?
« Reply #30 on: 03 / February / 2018, 07:02:57 »
Advertisements
The capture.* event procedures only exist on EOS M models.

But "EvfCaptureSystem.c" present on Powershots too.
See function 0xFC172520 at G7X_100d. It looks similar to EOS M3 (0xFC20D880). At least assertion line number is the same. Maybe you could find similar function for sx280. Maybe it's 0xFC16212C for SX280_102b.
sx280 102b: sub_FC16212C looks similar to what I found: sub_FC162020. I've been experimenting a bit with the latter. I used a short fw function from chdkptp that calls sub_FC162020: sub_FC3E1F6E. This one is called from an event procedure named SetImageMode which exists in all PowerShots.
The function works very similarly to Capture.WholeParallel and I get an FRSP.
Out of curiosity, I located the equivalent for my Ixus150 (CCD camera), it is sub_FFB57530. On Ixus150, I get an FRSP that appears to be exposed separately for each of its readout fields (it has an 8 field readout). The 8 fields are interlaced, every 8th horizontal line belongs to the same field.

tl;dr
Full res silent pictures are possible on PowerShots too.

edit:
"frame" -> "field" to match the Sony CCD literature
« Last Edit: 03 / February / 2018, 07:07:45 by srsa_4c »

*

Offline Ant

  • *****
  • 509
Re: Reading sensor data without closing shutter?
« Reply #31 on: 03 / February / 2018, 14:57:47 »
I found two functions (MenuIn and MenuOut) that allow to shoot FRSP without emulation of menu button pressing and rendering the menu.
I hope this will be faster. How accurate is measuring the time of execution from lua script?

Edit:
FRSP(and standard captures too) with Dual ISO also can be done using Capture.SetGainAdjustmentMode and SetCMOSOddEventGainValue
At least I got an interlaced DNG...
« Last Edit: 04 / February / 2018, 14:43:02 by Ant »

*

Offline srsa_4c

  • ******
  • 4451
Re: Reading sensor data without closing shutter?
« Reply #32 on: 04 / February / 2018, 16:38:11 »
I found two functions (MenuIn and MenuOut) that allow to shoot FRSP without emulation of menu button pressing and rendering the menu.
I hope this will be faster.
I checked these functions in an older Powershot firmware and found that they are mostly for stopping/resuming certain liveview related activity (motionvector, wb, ae, and liveview updates). I'd guess they remained similar in recent firmwares.
I also tried finding the traces of LiveImageTool.Pause / LiveImageTool.Resume in the sx280 firmware, without success. Looks like they were removed.
So, for recent cameras, using Menuin and Menuout to stop/resume liveview seems like a good choice.
I'd like to note that using them requires some care: executing Menuout crashed the camera when I executed it while the camera was preparing to "sleep".

Quote
FRSP(and standard captures too) with Dual ISO also can be done using Capture.SetGainAdjustmentMode and SetCMOSOddEventGainValue
At least I got an interlaced DNG...
Can you give some more details?

*

Offline Ant

  • *****
  • 509
Re: Reading sensor data without closing shutter?
« Reply #33 on: 04 / February / 2018, 17:42:36 »
Can you give some more details?

Read the link above. Especially dual_iso.pdf
Just call these two functoins and take RAW picture. It should be interlaced.
SetCMOSOddEventGainValue accepts a pointer to two CMOS Gain values: Odd and Even. On EOS M3 there are seven CMOS Gain levels(from 0 to 6). Probably it can be nominated in dB with corresponding functions.
Normal mode can be set with Capture.SetGainNormalMode


*

Offline srsa_4c

  • ******
  • 4451
Re: Reading sensor data without closing shutter?
« Reply #34 on: 06 / February / 2018, 14:48:28 »
I managed to get interlaced CR2 after executing Capture.SetGainAdjustmentMode and SetCMOSOddEventGainValue(<odd_gain>,<even_gain>).
Some things worth to note:
- If Capture.SetGainAdjustmentMode is active, the camera can crash if halfshoot is held for a longer period. Other crash conditions are also possible.
- SetCMOSOddEventGainValue also affects live view.
- The "SetCMOSOddEventGainValue" name is a bit misleading. It should be read as SetCMOSOddEvenGainValue (there's no "event", just "even").
- The gain values seem to correspond to native ISO stops (ISO = base_ISO * 2^gain ), or at least that is what I currently believe.
- Feeding the dual ISO CR2 to cr2hdr results in a reasonably looking DNG. Only problem is that some AF pixels do show up as bright pixels, depending on scene.
My guess is that AF pixels get interpolated over incorrectly when adjacent pixel rows have different (analog) gain. I don't know whether this issue affects ML DSLRs that have hybrid CMOS AF sensors.

Finally, these event procedures do not exist in Powershots.
« Last Edit: 06 / February / 2018, 14:49:59 by srsa_4c »

Re: Reading sensor data without closing shutter?
« Reply #35 on: 09 / August / 2018, 13:35:21 »
Hey, both features discussed here are really awesome!
I also have an EOS M3, but still have difficulties to get a meaningful disassembly of the firmware dump (will ask/discuss this in another thread). So to get the RAW from Capture.WholeParallel I need the address of the buffer:

Quote
4. Take raw data from RAM. (on EOS M3 there is only one raw buffer for it. Its address can be found at the beginning of "Capture.WholeParallel" function)

@Ant (or anybody else) could you tell me that address for the M3 (currently I have the 101a firmware running)?

Thanks so much

*

Offline srsa_4c

  • ******
  • 4451
Re: Reading sensor data without closing shutter?
« Reply #36 on: 10 / August / 2018, 16:22:23 »
@Ant (or anybody else) could you tell me that address for the M3 (currently I have the 101a firmware running)?
You can look up known function and other addresses (in case you need any) in funcs_by_*.csv and stubs_*.S files.
Capture.WholeParallel looks like this in 101a
Code: [Select]
loc_FC3F3FA8: <Capture.WholeParallel_FW> 1 refs 
    FC3F3FA8 41 49         ldr       r1, =0x4473D248
    FC3F3FAA 01 20         movs      r0, #1
    FC3F3FAC 19 F6 68 BC   b.w       loc_fc20d880
so the buffer's address is 0x4473D248.

*

Offline Ant

  • *****
  • 509
Re: Reading sensor data without closing shutter?
« Reply #37 on: 11 / August / 2018, 03:08:30 »
This script created for fw.1.0.1.a generates raw data at address 0x4473D248:
Code: [Select]
call_func_ptr(0xFC0AAF4D) --MenuIn
call_func_ptr(0xFC5A460F) --EnableHeadDirectCapturePath_FW
call_func_ptr(0xFC20D881, 1, 0x4473D248) --EvfCaptureSystem
call_func_ptr(0xFC5A4615) --DisableHeadDirectCapturePath_FW
call_func_ptr(0xFC0AAF71) --MenuOut


For FRSP I still didn't found good way to control exposure parameters:
it looks like exposure time is the same as they use for EVF(probably it's increased for dark scenes)
So I get more noise because AE controller increases CMOS/video gain.

Also I found that exposure time on EOS M3 depends from difference between VideoTimerB (0xC0F06014) and value of ADTG registers 0x8043 and 0x8044 which is stored at 0x0002947C.
Unfortunately I did not found the place where this value is calculetad. But it depends from VideoTimerB value taken from Field Tables.
« Last Edit: 11 / August / 2018, 03:23:36 by Ant »


*

Offline Ant

  • *****
  • 509
Re: Reading sensor data without closing shutter?
« Reply #38 on: 14 / October / 2018, 14:54:36 »
After some experiments I found the event procedure "ShutterTool.SetExpTime" that allows to control exposure time for EVF capture on my EOS M3. "Capture.Create" need to be called before.
But when I set exposure time larger that 1000000uS camera crashes after EVF capture with "ASSERT!! FpgaPath.c Line 1302".

Probably this limitation depends from timeout of TakeSemaphore function called at 0xFC214A48...

P.S.
With help of SetSafFPGABypassMode it's possible to increase the exposure time up to 2^32 nS. But in this case the image will contain focus pixels.

P.P.S.
After refactoring 0xFC214A2A function I managed to take picture with 4 second exposure time. Now it's need to remove hot pixels.

The result of calling "ShutterTool.GetLimOfExpTime" function in FHD 25p mode:
MaxExpTime = 39971[usec]
MinExpTime = 181[usec]
« Last Edit: 15 / October / 2018, 15:20:14 by Ant »

*

Offline srsa_4c

  • ******
  • 4451
Re: Reading sensor data without closing shutter?
« Reply #39 on: 22 / December / 2018, 14:45:48 »
Here's a first, rudimentary implementation of "full resolution silent pictures" aka frsp.

It probably works on all supported models, but the necessary functions/addresses/constants are only identified on pre-D6 cameras for now.

What it can do:
With the camera in rec mode (sensor has to be active), the new (and probably not final) frsp_shoot() Lua function can be used to take a silent picture and save it on card as raw or dng.
On CMOS cameras, the resulting image has no interlacing issues, but there is significant rolling shutter.
On CCD cameras, the resulting image is only usable if
- camera is steady
- subject is stationary
- lighting does not flicker
Also on CCD cams, if the sensor saturates (due to strong light or reflection), the well-known vertical smear will appear on the picture. Another CCD issue is that each field of the sensor is separately exposed (fields are interlaced).

Issues with current implementation:
- Exposure can't be controlled, it's roughly what live view uses at time of exposure. On cams without manual modes, that means high ISO when in dark.
- Exposure related DNG metadata is likely incorrect (may depend on cam generation, etc).
- CCD cameras need a strong positive exposure compensation because the live view exposure time does not work well for frsp.
- A hardcoded memory buffer is used - it might interfere with normal camera operation (but I have not yet seen any issues on cams I tried this).
- On old, low memory cams the hardcoded buffer overlaps the camera's viewport buffer(s) which can surprise the user at first, but seems to do no harm.
- The scripting interface and the raw processing parts probably need a greater rework.
- It's not currently possible to remote shoot with this method.
- The files are named based on the current date/time, and are saved under A/RAW. I'm not sure how we could maintain an image counter that is reliable. The camera's own picture numbering is obviously unusable for this purpose.


Usage example in a script:

Code: [Select]
sleep(2000)
press("shoot_half")
sleep(2000)
frsp_shoot()
release("shoot_half")


Credits go to Ant for finding this feature and doing most of the original research.

 

Related Topics