Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a dynamic reconfigure value to not set arbitrarily brightness, co… #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cfg/VideoStream.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ gen.add("flip_horizontal", bool_t, LEVEL.NORMAL, "Flip image horizontally", Fals
gen.add("flip_vertical", bool_t, LEVEL.NORMAL, "Flip image vertically", False)
gen.add("width", int_t, LEVEL.RUNNING, "Target width", 0, 0, 10000)
gen.add("height", int_t, LEVEL.RUNNING, "Target height", 0, 0, 10000)
gen.add("set_camera_properties", bool_t, LEVEL.RUNNING, "Set the camera properties (brightness, contrast, hue, saturation)", False)
gen.add("brightness", double_t, LEVEL.RUNNING, "Target brightness", 0.5019607843137255, 0.0, 1.0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be better if it is "Target brightness (Available only when set_camera_properties is true)".
Same on the "contrast", "hue" and "saturation".

gen.add("contrast", double_t, LEVEL.RUNNING, "Target contrast", 0.12549019607843137, 0.0, 1.0)
gen.add("hue", double_t, LEVEL.RUNNING, "Target hue", 0.5, 0.0, 1.0)
Expand Down
18 changes: 13 additions & 5 deletions src/video_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,13 @@ virtual void subscribe() {
cap->set(cv::CAP_PROP_FRAME_HEIGHT, latest_config.height);
}

cap->set(cv::CAP_PROP_BRIGHTNESS, latest_config.brightness);
cap->set(cv::CAP_PROP_CONTRAST, latest_config.contrast);
cap->set(cv::CAP_PROP_HUE, latest_config.hue);
cap->set(cv::CAP_PROP_SATURATION, latest_config.saturation);

if (latest_config.set_camera_properties) {
cap->set(cv::CAP_PROP_BRIGHTNESS, latest_config.brightness);
cap->set(cv::CAP_PROP_CONTRAST, latest_config.contrast);
cap->set(cv::CAP_PROP_HUE, latest_config.hue);
cap->set(cv::CAP_PROP_SATURATION, latest_config.saturation);
}

if (latest_config.auto_exposure) {
cap->set(cv::CAP_PROP_AUTO_EXPOSURE, 0.75);
latest_config.exposure = 0.5;
Expand Down Expand Up @@ -387,6 +389,12 @@ virtual void configCallback(VideoStreamConfig& new_config, uint32_t level) {
NODELET_INFO_STREAM("Flip vertical image is: " << ((new_config.flip_vertical)?"true":"false"));
NODELET_INFO_STREAM("Video start frame is: " << new_config.start_frame);
NODELET_INFO_STREAM("Video stop frame is: " << new_config.stop_frame);
NODELET_INFO_STREAM("set_camera_properties (if False, brightness, contrast, hue and saturation won't be used) is: " << new_config.set_camera_properties);
NODELET_INFO_STREAM("Set brightness is: " << new_config.brightness);
NODELET_INFO_STREAM("Set contrast is: " << new_config.contrast);
NODELET_INFO_STREAM("Set hue is: " << new_config.hue);
NODELET_INFO_STREAM("Set saturation is: " << new_config.saturation);


if (new_config.width != 0 && new_config.height != 0)
{
Expand Down