Skip to content

Commit 7523064

Browse files
griffith826Dan Griffith
andauthored
add check for bayer encoding (#67)
Co-authored-by: Dan Griffith <dan.griffith@ll.mit.edu>
1 parent 72db57a commit 7523064

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

hydra_ros/src/input/image_receiver.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,14 @@ ColorSubscriber::Filter& ColorSubscriber::getFilter() const {
5757

5858
void ColorSubscriber::fillInput(const Image& img, ImageInputPacket& packet) const {
5959
// Allow also mono images to be converted to grayscale.
60-
if (sensor_msgs::image_encodings::isColor(img.encoding)) {
60+
if (sensor_msgs::image_encodings::isColor(img.encoding) ||
61+
sensor_msgs::image_encodings::isBayer(img.encoding)) {
6162
try {
6263
packet.color =
6364
cv_bridge::toCvCopy(img, sensor_msgs::image_encodings::RGB8)->image;
6465
return;
6566
} catch (const cv_bridge::Exception& e) {
66-
LOG(ERROR) << "Failed to convert mono image as color input: " << e.what();
67+
LOG(ERROR) << "Failed to convert color image: " << e.what();
6768
return;
6869
}
6970
} else if (sensor_msgs::image_encodings::isMono(img.encoding)) {
@@ -73,7 +74,7 @@ void ColorSubscriber::fillInput(const Image& img, ImageInputPacket& packet) cons
7374
cv::cvtColor(mono, packet.color, cv::COLOR_GRAY2RGB);
7475
return;
7576
} catch (const cv_bridge::Exception& e) {
76-
LOG(ERROR) << "Failed to convert color image: " << e.what();
77+
LOG(ERROR) << "Failed to convert mono image as color input: " << e.what();
7778
return;
7879
}
7980
}

0 commit comments

Comments
 (0)