How to set nvarguscamerasrc white balance in manual to a specific colour temperature light source

Hi there.

I would like to set the white balance for my pipeline to match my light sources, which are all 4000k, which is a standard, time-tested way to describe colour temperature. I do not want to use one of the presets in wbmode, instead I would like to use mode(9): manual and set this parameter exactly.

I have read the earlier topic " How to modify white balance color temperature by using the gstreamer-plugin which name is "nvarguscamerasrc"?", which is close to what I want to do, however the “solution” is extremely complicated and introduces “lots of tuning parameters, curves related to white balance”. It also suggests directing this question to the sensor vendor.

This question is not about my sensor (imx219), it is about my light source.
Daylight (mode (5)) is around 6000k, incandescent (mode (2)) is around 2000k. I would like to set mode (9) to 4000k.

Please.

hello pddarrell,

you may using Argus API to configure as AWB_MODE_MANUAL, and Argus::IAutoControlSettings::setWbGains.
please see-also Argus sample, userAutoWhiteBalance for reference.

Hi Jerry.

Thank you for your very brief response, this is clearly an area that is not to be ventured into lightly and it would appear that you are not minded to encourage such venturing.
Moving on, when I run:
“$ cat main.cpp” from /usr/src/jetson_multimedia_api/argus/samples/userAutoWhiteBalance

If I keep scrolling down through the C++ code eventually, just before the bottom, we find:
"printf("Intensity: r:%0.3f gO:%0.3f gE:: %0.3f b:%0.3f "
“WBGains: r:%0.3f gO:%0.3f gE:: %0.3f b:%0.3f\n”,
bayerAverages[0],
bayerAverages[1],
bayerAverages[2],
bayerAverages[3],
whiteBalanceGains[0],
whiteBalanceGains[1],
whiteBalanceGains[2],
whiteBalanceGains[3]);

BayerTuple bayerGains(whiteBalanceGains[0], whiteBalanceGains[1], whiteBalanceGains[2], whiteBalanceGains[3]);

iAutoControlSettings->setWbGains(bayerGains);
iAutoControlSettings->setAwbMode(AWB_MODE_MANUAL); "

This appears to be the code for GST_NVCAM_WB_MODE_AUTO (1), but it mentions"AWB_MODE_MANUAL", which may not be the same as GST_NVCAM_WB_MODE_MANUAL (9).

If I have this correct please may I request that you point me in the direction of the equivalent code relating to GST_NVCAM_WB_MODE_INCANDESCENT (2) and GST_NVCAM_WB_MODE_ DAYLIGHT (5), or better still provide it. If I have mis-interpreted the code, please advise.

I hope this post will be useful to anyone else who is tempted to go beyond the presets provided by nvarguscamerasrc.

Many thanks

hello pddarrell,

I did not get your point.
it’s setting AWB mode to manual, so that internal code flow has pause to update the AWB params.
and… you may assign different WBgains for your own use-case.

Hi Jerry,

Thanks for that

So:

  1. I only need to adjust settings in the line that currently reads: "WBGains: r: %0.3f gO:%0.3f gE:: %0.3f b:%0.3f\n”?
  2. I only adjust the 4 values that currently all read “0.3” to my preferred floating point values?
  3. Does the build system automatically re-run CMake, or do I need to run CMake?

Thank you.

no… it means this configure printf() to set the length as 3 floating numbers.

Are you telling me that I need to modify the line:
printf("Intensity: r:%0.3f gO:%0.3f gE:%0.3f b:%0.3f " ?

Thank you

hello pddarrell,

please double check the sample app, you should revise the code to assign your expected WBGains for your use-case.

Hi Jerry.

Which sample app are you referring to?


In the Jetson Linux API, in the Sample Applications directory there are two sample apps that might be appropriate:
09_camera_jpeg_capture
10_camera_recording

neither of these contain the string “WBGains” in the main.cpp

“WBGains” is found in /usr/src/jetson_multimedia_api/argus/samples/userAutoWhiteBalance/main.cpp, as I mentioned above.

Both 09_camera_jpeg_capture and 10_camera_recording include the declaration: "include <Argus/Argus.h>

So I need to revise “WBGains: r: %0.3f gO:%0.3f gE:: %0.3f b:%0.3f\n”, in argus/samples/userAutoWhiteBalance/main.cpp and then build and run (e.g) 10_camera_recording , don’t I?

Please confirm or advise

userAutoWhiteBalance

Hi Jerry,

I have made the symbolic links, described in “Building and Running”, with the command:
$ sudo ln -sf libv4l2.so.O libv4l2.so

When I run $ sudo make to re-compile some of the jetson_multimedia_samples with my revised WBGains values, I am getting “/usr/bin/ld: cannot find -lv4l2”. Can you advise on what the problem might be?

Thank you

it’s Argus sample,
you should follow /usr/src/jetson_multimedia_api/argus/README.TXT for the steps to install utility, and build the sample.

Hi Jerry.

Thank you for that.

In order to follow the guidance in README.TXT, please may I ask:
"Start in the source directory (e.g. ‘~/ArgusSDK/’).
What is ‘the source directory’ in this case?
(is it /usr/src/jetson_multimedia_api/argus/samples/userAutoWhiteBalance)?

If I add the prop “wbmode=9” after gst-nvarguscamerasrc-1.0 , does it simply point to userAutoWhiteBalance, it is not clear from the nvarguscamerasrc documentation or the Jetson Linux API/Libargus Camera API documentation.

Thank you

hello pddarrell,

it means you should copy the MMAPI sources from root to user folder to grant user permission.
you should under ~/ArgusSDK to build and install the sources.
for instance,
$ mkdir ~/ArgusSDK
$ cp /usr/src/jetson_multimedia_api/argus ~/ArgusSDK

no. it’s only the option for nvarguscamerasrc.
you may running $ gst-inspect-1.0 nvarguscamerasrc to view all available controls.

Thanks for that Jerry.

README.TXT says:
"Start in the source directory (e.g. ‘~/ArgusSDK/’).

  1. Create and go into a build directory:
    ‘mkdir build && cd build’

I am therefore in ~/ArgusSDK/build, while the copied directory ‘argus’, for which I have permissions, is also in ~ArgusSDK.

The next instruction is also numbered 1). It says:

  1. Create the makefiles:
    ‘cmake …’

The reason I am doing this is because I need to remake the userAutoWhiteBalance sample: path ~/ArgusSDK/argus/userAutoWhiteBalance

If I enter:
cmake samples

I get a cmake source error. I can see why, but I am following the instructions, so do I need to place the ‘argus’ directory inside the ‘build’ directory, which is what cmake appears to want, or is there some preferred solution to this please?

it’s two dots for running cmake.

Aahh yes. Thank you Jerry. Wrong glasses.

Running ‘cmake …’ gives the error ‘The source directory “/path/to/ArgusSDK” does not appear to contain CMakeLists.txt’.
CMakeLists.txt can be found in ~/ArgusSDK/argus, but we are in ~/ArgusSDK/build and CMakeLists.txt is not one of the files that has been copied across from /argus, however each of the samples in the /build/samples directory has its own CMakeLists.txt.
Do I:

  1. Copy ‘CMakeLists.txt’ to ~/ArgusSDK/build and rerun ‘cmake …’
    or
  2. Modify ‘cmake …’ to point explicitly to 'userAutoWhiteBalance
    or
  3. Something else
    ?
    Thank you

hello pddarrell,

had you also read the jetson_multimedia_api/argus/README.TXT to install those utilities mentioned in the [Requirements] section?

let me share my steps.
(1) $ cp /usr/src/jetson_multimedia_api ~/jetson_multimedia_api
(2) $ cd argus
(3) $ mkdir build && cd build
(4) $ cmake ..
please check it’s all complete with below messages.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/nvidia/jetson_multimedia_api/argus/build

(4) you should now have app/ and samples/ folder under build.

~/jetson_multimedia_api/argus/build$ ls
CMakeCache.txt  CMakeFiles/  CPackConfig.cmake  CPackSourceConfig.cmake  Makefile  apps/  cmake_install.cmake  samples/

(5) $ cd samples/userAutoWhiteBalance && make

...
[ 94%] Building CXX object samples/userAutoWhiteBalance/CMakeFiles/argus_userautowhitebalance.dir/main.cpp.o
[100%] Linking CXX executable argus_userautowhitebalance
[100%] Built target argus_userautowhitebalance

(6) here’s binary file you may running on the target. argus_userautowhitebalance

Hi Jerry,

When I run (4) $ cmake …
At line 53 in the messages cmake fails to find module ‘gtk±3.0’

“CMake Error at /usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:419 (message):
A required package was not found
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:597 (_pkg_check_modules_internal)
samples/utils/CMakeLists.txt:41 (pkg_check_modules)”

– Configuring incomplete, errors occurred!
See also “~/jetson_multimedia_api/argus/build/CMakeFiles/CMakeOutput.log”.
See also “~/jetson_multimedia_api/argus/build/CMakeFiles/CMakeError.log”.

CMakeError.log reads:
"Determining if the pthread_create exist failed with the following output:

Change Dir: /home/peter/jetson_multimedia_api/argus/build/CMakeFiles/CMakeTmp

Run Build Command:“/usr/bin/make” “cmTC_c1380/fast”

/usr/bin/make -f CMakeFiles/cmTC_c1380.dir/build.make CMakeFiles/cmTC_c1380.dir/build

make[1]: Entering directory ‘/home/peter/jetson_multimedia_api/argus/build/CMakeFiles/CMakeTmp’

Building C object CMakeFiles/cmTC_c1380.dir/CheckSymbolExists.c.o

/usr/bin/cc -fPIC -o CMakeFiles/cmTC_c1380.dir/CheckSymbolExists.c.o -c /home/peter/jetson_multimedia_api/argus/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c

Linking C executable cmTC_c1380

/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c1380.dir/link.txt --verbose=1

/usr/bin/cc -fPIC -rdynamic CMakeFiles/cmTC_c1380.dir/CheckSymbolExists.c.o -o cmTC_c1380

CMakeFiles/cmTC_c1380.dir/CheckSymbolExists.c.o: In function `main’:

CheckSymbolExists.c:(.text+0x14): undefined reference to `pthread_create’

CheckSymbolExists.c:(.text+0x18): undefined reference to `pthread_create’

collect2: error: ld returned 1 exit status

CMakeFiles/cmTC_c1380.dir/build.make:97: recipe for target ‘cmTC_c1380’ failed

make[1]: *** [cmTC_c1380] Error 1

make[1]: Leaving directory ‘/home/peter/jetson_multimedia_api/argus/build/CMakeFiles/CMakeTmp’

Makefile:126: recipe for target ‘cmTC_c1380/fast’ failed

make: *** [cmTC_c1380/fast] Error 2

File /home/peter/jetson_multimedia_api/argus/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:

/* */

include <pthread.h>

int main(int argc, char** argv)

{

(void)argv;

#ifndef pthread_create

return ((int*)(&pthread_create))[argc];

else

(void)argc;

return 0;

endif

}

Determining if the function pthread_create exists in the pthreads failed with the following output:

Change Dir: /home/peter/jetson_multimedia_api/argus/build/CMakeFiles/CMakeTmp

Run Build Command:“/usr/bin/make” “cmTC_c1342/fast”

/usr/bin/make -f CMakeFiles/cmTC_c1342.dir/build.make CMakeFiles/cmTC_c1342.dir/build

make[1]: Entering directory ‘/home/peter/jetson_multimedia_api/argus/build/CMakeFiles/CMakeTmp’

Building C object CMakeFiles/cmTC_c1342.dir/CheckFunctionExists.c.o

/usr/bin/cc -fPIC -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_c1342.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.10/Modules/CheckFunctionExists.c

Linking C executable cmTC_c1342

/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c1342.dir/link.txt --verbose=1

/usr/bin/cc -fPIC -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_c1342.dir/CheckFunctionExists.c.o -o cmTC_c1342 -lpthreads

/usr/bin/ld: cannot find -lpthreads

collect2: error: ld returned 1 exit status

CMakeFiles/cmTC_c1342.dir/build.make:97: recipe for target ‘cmTC_c1342’ failed

make[1]: *** [cmTC_c1342] Error 1

make[1]: Leaving directory ‘/home/peter/jetson_multimedia_api/argus/build/CMakeFiles/CMakeTmp’

Makefile:126: recipe for target ‘cmTC_c1342/fast’ failed

make: *** [cmTC_c1342/fast] Error 2"

running ls shows that Makefile and cmake_install.cmake are are not under build

~/ArgusSDK/build$ ls
apps CMakeFiles CPackSourceConfig.cmake CMakeCache.txt CPackConfig.cmake samples

May I request your advice

hello pddarrell,

it’s reporting a required package was not found failure.
for instance,

/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status

please double check you’re using the L4T release version with the same version of MMAPI package.
for example,
L4T release version,
$ cat /etc/nv_tegra_release
# R35 (release), REVISION: 4.1, GCID: 33958178, BOARD: t186ref, EABI: aarch64, DATE: Tue Aug 1 19:57:35 UTC 2023

MMAPI package version.
$ apt show nvidia-l4t-jetson-multimedia-api
Version: 35.4.1-20230801124926

after that,
you should follow readme file for the steps to install all necessary utilities.