Skip to content

Commit

Permalink
Use encoding reported by camera
Browse files Browse the repository at this point in the history
The camera driver reports its encoding in the sensor_msgs::Image. This
string is taken from include/sensor_msgs/image_encodings.h. The most
common ones:
    "mono8"
    "bgr8"
    "bgra8"
    "rgb8"
    "rgba8"
    "mono16"
are also used for cv_bridge::toCvCopy. So it can be simply passed on.
  • Loading branch information
Karl D. Hansen committed May 20, 2021
1 parent 36a4c9c commit ae23d0f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion darknet_ros/src/YoloObjectDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void YoloObjectDetector::cameraCallback(const sensor_msgs::ImageConstPtr& msg) {
cv_bridge::CvImagePtr cam_image;

try {
cam_image = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
cam_image = cv_bridge::toCvCopy(msg, msg->encoding);
} catch (cv_bridge::Exception& e) {
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
Expand Down

0 comments on commit ae23d0f

Please sign in to comment.