Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7633

Camera board • Re: MMAL lens shading v2 (Zero 2W) + Camera v2 NOIR

$
0
0
Good afternoon 6by9. Thanks for moving and looking at this thread. It is appreciated.

> The legacy camera stack using MMAL is deprecated. What are your reasons for not being able to use libcamera?

I have looked at the README and I do not fully understand it yet. I am reading background information. I am not a camera person so learning ergo please be patient with me. Also I may be spouting stuff that may seem nonsense to you partly it is because of my lacked of understanding. We do medical devices using Raspi; it's a boring industry but the good heart and intent is there. It's an interesting project to use Raspi in this sense. I do not think this is done anywhere else so big kudos when we complete this work.

We started the project since 2020 and it is hard for us to rewrite stuff to use libcamera. Out of interest, does libcamera provide simple tooling for this "calibration" because there is also another thread viewtopic.php?t=394098 seems to also there may be some issues but they are using arducam?

We made many things work with MMAL even with H264 streaming. We have gone pretty far in this project with a very small team. Yay for us in this aspect.

Our issue is, instead of using standard Raspi Camera V2 NOIR module's lens, we need something more flexible and we found a lens that worked with our use case where we could programmatically change lens focus. Unfortunately, using this lens, we also noticed subtle residue of image processing from the ISP. We know it is to do with lens shading and we only need to tweak it a little to make it work with our project and we will be happy.


> MMAL_PARAMETER_LENS_SHADING_T is defined in the MMAL headers, and the firmware code is generally kept backwards compatible even when a new version of a parameter is added.

Does it mean using the GitHub in https://github.com/6by9/lens_shading will also work for the Camera V2 with IMX219?

> V2 only added the option to use alternate gain formats in the table, and to specify the values as applying at the corners of a grid rather in the middle.

What does this mean by `to specify the values as applying at the corners of a grid rather in the middle`? Could you please explain more? I know the GitHub repo, your original work focused on the lens shading at the centre.


Some other questions ...
1/ Is the MMAL_PARAMETER_LENS_SHADING_V2_T fully implemented which means I can use it?


2/ In the file opt/vc/include/interface/mmal/mmal_parameters_camera.h:143: MMAL_PARAMETER_LENS_SHADING_OVERRIDE, /**< Takes a @ref MMAL_PARAMETER_LENS_SHADING_T */

Does this mean if I use MMAL_PARAMETER_LENS_SHADING_OVERRIDE for a V2 (or above) camera, I would get MMAL_PARAMETER_LENS_SHADING_V2_T returned instead of MMAL_PARAMETER_LENS_SHADING_T?

Example:

Code:

MMAL_PARAMETER_HEADER_T get_hdr ={    MMAL_PARAMETER_LENS_SHADING_OVERRIDE,  //  will this request to the ISP that jmnemonic wants to query the lens shading table?    0                                      // to use size == 0 means to query?};// to discover required sizemmal_port_parameter_get(camera->control, &get_hdr);uint32_t required = get_hdr.size;// allocate properly-sized structureMMAL_PARAMETER_LENS_SHADING_V2_T *ls = (MMAL_PARAMETER_LENS_SHADING_V2_T*) calloc(1, required);ls->hdr.id = MMAL_PARAMETER_LENS_SHADING_OVERRIDE;ls->hdr.size = required;

3/ From the above, will this allow me to read into the BIN and see values which are MMAL_PARAM_LS_GAIN_FORMAT_TYPE_T::MMAL_PARAM_LS_GAIN_FORMAT_TYPE_U0P8_1 meaning unsigned 0 integer bits, 8 fractional so it is 8 bits with 256 precision from 0 ~ 0.996 (more or less)?


Thank you 6by9 and others who contribute.

Statistics: Posted by jmnemonic — Mon Dec 01, 2025 2:32 pm



Viewing all articles
Browse latest Browse all 7633

Trending Articles