Last active
November 11, 2017 04:58
-
-
Save goldbattle/2810f8bd734fb7b2be4de7ba43c327f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Subscriber::imageCallback(const sensor_msgs::ImageConstPtr& msg,/* | |
| const sensor_msgs::CameraInfoConstPtr& info,*/ | |
| unsigned int cameraIndex) | |
| { | |
| //============================================================================== | |
| // Copy the ros image message to cv::Mat. | |
| // Note we force reading it in as a MONO image (we don't handle color images) | |
| cv_bridge::CvImageConstPtr cv_ptr; | |
| try { | |
| cv_ptr = cv_bridge::toCvShare(msg, sensor_msgs::image_encodings::MONO8); | |
| } catch (cv_bridge::Exception& e) { | |
| ROS_ERROR("cv_bridge exception: %s", e.what()); | |
| return; | |
| } | |
| // Finally do our normal blur if specified | |
| cv::Mat filtered; | |
| if (vioParameters_.optimization.useMedianFilter) { | |
| cv::medianBlur(cv_ptr->image, filtered, 3); | |
| } else { | |
| filtered = cv_ptr->image.clone(); | |
| } | |
| //============================================================================== | |
| // adapt timestamp | |
| okvis::Time t(msg->header.stamp.sec, msg->header.stamp.nsec); | |
| t -= okvis::Duration(vioParameters_.sensors_information.imageDelay); | |
| if (!vioInterface_->addImage(t, cameraIndex, filtered)) | |
| LOG(WARNING) << "Frame delayed at time "<<t; | |
| // TODO: pass the keypoints... | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make sure to include
This will allow OKVIZ to correctly handle color images.