Magic Lantern Forum

Using Magic Lantern => Raw Video => Topic started by: cedricp on November 16, 2021, 09:52:31 AM

Title: Calculate final sensor crop from MLV video data (in crop mode)
Post by: cedricp on November 16, 2021, 09:52:31 AM
Hi,

I'm writing a little application to play with my EOS-M footages and I need to calculate the final crop sensor (if crop rec is enabled), the goal is to give the correct information to the LensFun library to do lens undistortion and exposition correction. I tried to find a way with pixel binning params, but not sure how to handle it properly.

Thank you
Title: Re: Calculate final sensor crop from MLV video data (in crop mode)
Post by: Walter Schulz on November 16, 2021, 11:38:58 AM
I think you should be able to extract this data from footage itself.
Title: Re: Calculate final sensor crop from MLV video data (in crop mode)
Post by: cedricp on November 16, 2021, 02:17:05 PM
Yes, I get the sensor crop factor (1.62 on EOS-M) via (mlv_oject*)->RAWC.sensor_crop, what I'd like to get is the crop factor when the captured image data doesn't fill the entire sensor (in crop mode)
Title: Re: Calculate final sensor crop from MLV video data (in crop mode)
Post by: Walter Schulz on November 16, 2021, 02:22:12 PM
That is not what I meant. Footage contains resolution and you should be able to retrieve that information from footage file itself.
Title: Re: Calculate final sensor crop from MLV video data (in crop mode)
Post by: cedricp on November 16, 2021, 02:58:18 PM
Oh, yes, there is a lot of information, but I don't exactly know how to do the calculus with pixel binning/skipping values...
Title: Re: Calculate final sensor crop from MLV video data (in crop mode)
Post by: cedricp on November 16, 2021, 03:52:32 PM
Here's what I found so far, but seems wrong (or miss parameter(s)) :
sensor_res_x / (sampling_x * raw_res_x) * sensor_crop
where sampling_x = binning_x + skipping_x

example : on EOS-M raw video 1800x754 with 3x3 sampling (3x1 binning) gives a crop factor of 1.56 (!!)
Title: Re: Calculate final sensor crop from MLV video data (in crop mode)
Post by: 2blackbar on November 17, 2021, 11:24:07 AM
man, nobody told you but its not a constant precise crop formula, its total manual adjustment of what acmera lets us record and card speed factor.
Sometimes you chop off pixels from crop modes to get more recording time.
its a hack, if we will somehow get even more speed from cards, the crop will get more pixels and field of view will be bigger, with slow sd cards crop gets smaller part of full resolution image.
easiest thing you can do, compare full resolution photo size to raw mlv resolutions.
but remember that crop modes are not centered super precisely into the middle of the sensor
your math does not apply, you can divide full res photo by 3 , and even then some pixels can get discarded depending on what ml coders choose.
Title: Re: Calculate final sensor crop from MLV video data (in crop mode)
Post by: cedricp on November 18, 2021, 11:24:40 AM
Tough ! Thank you for the reply. I'll do manual correction.