static void lane_cannyhough_callback(const sensor_msgs::Image& image_source) { cv_bridge::CvImagePtr cv_image = cv_bridge::toCvCopy(image_source, sensor_msgs::image_encodings::BGR8); IplImage frame = cv_image->image; process_image_common(&frame); cvWaitKey(2); }
int main(int argc, char *argv[]) { #if defined(USE_POSIX_SHARED_MEMORY) attach_ShareMem(); while (1) { CvMemStorage *houghStorage = cvCreateMemStorage(0); IplImage *frame = getImage_fromSHM(); process_image_common(frame); cvReleaseImage(frame); } detach_ShareMem(); #else ros::init(argc, argv, "line_ocv"); ros::NodeHandle n; ros::Subscriber subscriber = n.subscribe("/image_raw", 1, lane_cannyhough_callback); image_lane_objects = n.advertise<lane_detector::ImageLaneObjects>("lane_pos_xy", 1); ros::spin(); #endif return 0; }
int main(int argc, char *argv[]) { #if defined(USE_POSIX_SHARED_MEMORY) attach_ShareMem(); while (1) { CvMemStorage *houghStorage = cvCreateMemStorage(0); IplImage *frame = getImage_fromSHM(); process_image_common(frame); cvReleaseImage(frame); } detach_ShareMem(); #else ros::init(argc, argv, "line_ocv"); ros::NodeHandle n; ros::NodeHandle private_nh("~"); std::string image_topic_name; private_nh.param<std::string>("image_raw_topic", image_topic_name, "/image_raw"); ROS_INFO("Setting image topic to %s", image_topic_name.c_str()); ros::Subscriber subscriber = n.subscribe(image_topic_name, 1, lane_cannyhough_callback); image_lane_objects = n.advertise<lane_detector::ImageLaneObjects>("lane_pos_xy", 1); ros::spin(); #endif return 0; }