Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
739 Views

Locking down all automatic sensor adjustments for color frame

Jump to solution

I am getting ready for a trade show where I am showing off a live projection masking program based on the realsense sdk 2.0. I am cleaning up my masks by running a pixel difference calculation on subjects entering the scene and a reference image without them. This works perfectly, except the camera will occasionally adjust its automatic settings when a subject enters, changing more about the image than the fact that the subject is in frame as a result.

 

I already lock down exposure on my camera profile:

pipeProfile.get_device().first<rs2::depth_sensor().set_option(RS2_OPTION_ENABLE_AUTO_EXPOSURE, false); int new_exposure = pipeProfile.get_device().first<rs2::depth_sensor().get_option(RS2_OPTION_EXPOSURE); pipeProfile.get_device().first<rs2::depth_sensor>().set_option(RS2_OPTION_EXPOSURE, new_exposure);

But I found all of these other options here:

https://intelrealsense.github.io/librealsense/doxygen/rs__option_8h.html#a8b9c011f705cfab20c7eaaa7a2...

 

I am wondering which of these might influence the RGB sensor's image and how to disable the automatic image adjustment in a similar method to what I am currently doing for auto-exposure. Thanks!

0 Kudos

Accepted Solutions
Highlighted
18 Views

Re: Locking down all automatic sensor adjustments for color frame

Jump to solution

Thank you as always for pointing me in the right direction! For future visitors, here is the complete solution:

 

auto&& dev = list[0]; //where list is the set returned from ctx.query_devices()   rs2::sensor depth_sensor; rs2::sensor color_sensor; auto advanced_dev = dev.as<rs400::advanced_mode>(); auto advanced_sensors = advanced_dev.query_sensors();   bool depth_found = false; bool color_found = false;   for (auto&& sensor : advanced_sensors) { std::string module_name = sensor.get_info(RS2_CAMERA_INFO_NAME); std::cout << module_name << std::endl;   if (module_name == "Stereo Module") { depth_sensor = sensor; depth_found = true; } else if (module_name == "RGB Camera") { color_sensor = sensor; color_found = true; } }   if (!(depth_found && color_found)) { std::cout << "Unable to find both stereo and color modules" << std::endl; }   //Adjust depth sensor auto exposure depth_sensor.set_option(RS2_OPTION_ENABLE_AUTO_EXPOSURE, false); int new_exposure = depth_sensor.get_option(RS2_OPTION_EXPOSURE); depth_sensor.set_option(RS2_OPTION_EXPOSURE, new_exposure);   //Adjust color sensor auto exposure color_sensor.set_option(RS2_OPTION_ENABLE_AUTO_EXPOSURE, false); new_exposure = color_sensor.get_option(RS2_OPTION_EXPOSURE); color_sensor.set_option(RS2_OPTION_EXPOSURE, new_exposure); //Disable auto white balance on color color_sensor.set_option(RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE, false); int new_white_balance = color_sensor.get_option(RS2_OPTION_WHITE_BALANCE); color_sensor.set_option(RS2_OPTION_WHITE_BALANCE, new_white_balance);  

And just as a heads up, if you try something "silly" like adjusting white balance for the depth sensor, you will get a rather ambiguous runtime error. Just be careful about what settings you change! And make sure you have imported the rs_advanced_mode.hpp file!

View solution in original post

0 Kudos
2 Replies
Highlighted
Honored Contributor III
18 Views

Re: Locking down all automatic sensor adjustments for color frame

Jump to solution

Any of the first 12 options in that list (all of the ones with 'Color' in their description) could potentially affect the RGB image.

 

If you have experimented with the RealSense Viewer program, you may have noticed that both the depth controls and the RGB controls have an auto-exposure option. Disabling the color auto-exposure is a bit trickier than just disabling the depth auto-exposure alone, as both modes use the same RS2_OPTION_ENABLE_AUTO_EXPOSURE instruction, and you have to differentiate between them with a descriptor at the start of the code line.

 

For example, one user differentiated between the depth and color sensors with the descriptors ' realSenseSensor.set' for the color auto-exposure and 'realSenseSensorDepth.set' for the depth auto-exposure. The complication is that these descriptor terms need to be defined earlier in the script.

 

The best reference that I know of for setting up these custom references is in a long script in the first message of the discussion linked to below.

 

https://github.com/IntelRealSense/librealsense/issues/2637

 

In that discussion, the user first defines terms called depth_sensor and color_sensor with these lines:

 

rs2::sensor depth_sensor;

rs2::sensor color_sensor;

 

Further down the script, they use these descriptors in two separate blocks of the code to differentiate between depth and color sensors when disabling auto-exposure by setting them to '0' (setting them to '1' enables them).

 

depth_sensor.set_option(RS2_OPTION_ENABLE_AUTO_EXPOSURE, 0);

 

color_sensor.set_option(RS2_OPTION_ENABLE_AUTO_EXPOSURE, 0);

 

Highlighted
19 Views

Re: Locking down all automatic sensor adjustments for color frame

Jump to solution

Thank you as always for pointing me in the right direction! For future visitors, here is the complete solution:

 

auto&& dev = list[0]; //where list is the set returned from ctx.query_devices()   rs2::sensor depth_sensor; rs2::sensor color_sensor; auto advanced_dev = dev.as<rs400::advanced_mode>(); auto advanced_sensors = advanced_dev.query_sensors();   bool depth_found = false; bool color_found = false;   for (auto&& sensor : advanced_sensors) { std::string module_name = sensor.get_info(RS2_CAMERA_INFO_NAME); std::cout << module_name << std::endl;   if (module_name == "Stereo Module") { depth_sensor = sensor; depth_found = true; } else if (module_name == "RGB Camera") { color_sensor = sensor; color_found = true; } }   if (!(depth_found && color_found)) { std::cout << "Unable to find both stereo and color modules" << std::endl; }   //Adjust depth sensor auto exposure depth_sensor.set_option(RS2_OPTION_ENABLE_AUTO_EXPOSURE, false); int new_exposure = depth_sensor.get_option(RS2_OPTION_EXPOSURE); depth_sensor.set_option(RS2_OPTION_EXPOSURE, new_exposure);   //Adjust color sensor auto exposure color_sensor.set_option(RS2_OPTION_ENABLE_AUTO_EXPOSURE, false); new_exposure = color_sensor.get_option(RS2_OPTION_EXPOSURE); color_sensor.set_option(RS2_OPTION_EXPOSURE, new_exposure); //Disable auto white balance on color color_sensor.set_option(RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE, false); int new_white_balance = color_sensor.get_option(RS2_OPTION_WHITE_BALANCE); color_sensor.set_option(RS2_OPTION_WHITE_BALANCE, new_white_balance);  

And just as a heads up, if you try something "silly" like adjusting white balance for the depth sensor, you will get a rather ambiguous runtime error. Just be careful about what settings you change! And make sure you have imported the rs_advanced_mode.hpp file!

View solution in original post

0 Kudos