Set Lens Table

1.Which seller did you purchase the product(s) from?
Scoprion Vision, UK
2.The Model number of the product(s) you have purchased?
3.Which Platform are you using the product(s) on?
RPi 4 32 bit Linux
4.Which instruction are you following?
Reading C code
5.Has your product ever worked properly?
This feature has not worked
6.What problems are you experiencing?

I’m trying to set the lens table of an UC-572 camera with the following code:

int ArduGrab::initCamera() {
int res;
log(“init camera”);

if (!cameraConnected) {
if (!this->sim) {

res = arducam_init_camera(&this->camera_instance);
if (res) {return -1;}
string str = “/home/pi/ArduGrab/imx298/ls_table_4656x3496.h”;
log("setting lens table from " + str);
char *path = new char[str.length() + 1];
strcpy(path, str.c_str());
arducam_set_lens_table(camera_instance, path);
delete [] path;

res = arducam_set_mode(camera_instance, 4);
if (res) {return -1;}

cameraConnected = true;
log(“init camera done”);
return 0;


However, this isn’t working, the output when testing this is:

[email protected]:~/ArduGrab $ ./run-c+±
set debug true
set sim false
init camera
Found sensor imx298 at address 1A
setting lens table from /home/pi/ArduGrab/imx298/ls_table_4656x3496.h
mmal: Failed to fix lens shading, use the default mode!

Just to check that we are pointing to the correct file:

[email protected]:~/ArduGrab $ ls -al /home/pi/ArduGrab/imx298/ls_table_4656x3496.h
-rw-r–r-- 1 pi pi 14348 Jun 15 17:39 /home/pi/ArduGrab/imx298/ls_table_4656x3496.h

Can you help advise as to the reason from the problem please?



7.What attempts at troubleshooting have you already made?
Wrriten code and debugged it
8.How would you like us to help you?
advise on settign lens table


I’m still messing with this, arducamstill.h has the following line:

char path = NULL;//"./lens_shading_table/imx230/2672x2004.h";

In fact if you remove the comment and actually point to the file you get a seg fault. I’ve also changed to the actual lens shading table for my camera and resolution (imx298, mode 4) but it still seg faults. My C++ code doesn’t seg fault but just shows the above error.

I’m hoping we can look at this - I’m trying to get this camera into my product for over a week now and the lens table and seg faults are proving a real sticking point!




I think I have solved it, you need to set the resolution which will give an unknown lens shading table error and then set the lens table. This still gives off colour images but they are not corrupted. Luckily I only need greyscale images so this is fine.





In fact, the MIPI_Camera library does not have detailed ISP parameters for lens shading, and the effect is not very good. We do not maintain it, and it is not recommended to use this function.