ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

the_notorious_kid's profile - activity

2022-01-13 01:30:35 -0500 received badge  Famous Question (source)
2019-05-20 02:26:53 -0500 marked best answer How to get image from custom server using service?

Hello People,

I am trying to pass image from server to a client. The code complies when I use cv_bridge::toCvCopy, but it says core dumped when I actually call the image from the server. So I am currently trying to do the same thing using cv_bridge::toCvShare, but it throws following error -

error: no matching function for call to ‘toCvShare(robot_vision::request_imageResponse_<std::allocator<void> >::_img_type&, const char [5])’ cv::imshow("view", cv_bridge::toCvShare(srv.response.img, "bgr8")->image);

Inorder to check my server please check my previous question (I have updated the code with working one). My code for client is below -

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include "sensor_msgs/Image.h"
#include <opencv2/imgproc/imgproc.hpp>
#include "robot_vision/request_image.h"
#include <cstdlib>
#include <iostream>

namespace enc = sensor_msgs::image_encodings;

cv_bridge::CvImagePtr cv_ptr;

int main(int argc,char **argv)
{
    ros::init(argc,argv,"image_client_node");
    ros::NodeHandle nh;
    ros::ServiceClient client = nh.serviceClient<robot_vision::request_image>("image_server");
    robot_vision::request_image srv;
    srv.request.request_msg = true;
    if(client.call(srv))
    {
        ROS_INFO("Service initiated");
        try
        {
           //cv_ptr = cv_bridge::toCvCopy(srv.response.img, sensor_msgs::image_encodings::BGR8);
           cv::imshow("view", cv_bridge::toCvShare(srv.response.img, "bgr8")->image);
           cv::waitKey(30);
        }
        catch (cv_bridge::Exception& e)
        {
           ROS_ERROR("cv_bridge exception: %s", e.what());
           //return;
        }
    }
    else
    {
        ROS_ERROR("Failed to call service image_server");
        return 1;
    }
    ros::spinOnce();
    return 0;
}
2017-12-06 09:47:56 -0500 received badge  Famous Question (source)
2017-09-26 21:06:11 -0500 received badge  Famous Question (source)
2017-08-22 17:12:02 -0500 commented answer How to get image from custom server using service?

I managed to solve the core problem by using cv_bridge::toCvCopy. @jayees Thanks for the help though.

2017-08-22 17:11:34 -0500 commented answer How to get image from custom server using service?

I managed to solve the core problem by using cv_bridge::toCvCopy. @jayees

2017-08-22 15:11:00 -0500 commented answer How to get image from custom server using service?

this is how .color went - error: ‘robot_vision::request_imageResponse_<std::allocator<void> >::_img_type’

2017-08-22 15:10:26 -0500 commented answer How to get image from custom server using service?

error: ‘robot_vision::request_imageResponse_<std::allocator<void> >::_img_type’ has no member named ‘color’

2017-08-22 15:10:09 -0500 commented answer How to get image from custom server using service?

error: ‘robot_vision::request_imageResponse_<std::allocator<void> >::_img_type’ has no member named ‘color’

2017-08-22 15:10:00 -0500 commented answer How to get image from custom server using service?

error: ‘robot_vision::request_imageResponse_<std::allocator<void> >::_img_type’ has no member named ‘color’

2017-08-22 15:10:00 -0500 received badge  Commentator
2017-08-22 14:26:48 -0500 commented answer How to get image from custom server using service?

cont.... error: base operand of ‘->’ has non-pointer type ‘robot_vision::request_imageResponse_<std::allocator<

2017-08-22 14:26:14 -0500 commented answer How to get image from custom server using service?

I tried with what you said and it throws following error - error: base operand of ‘->’ has non-pointer type ‘robot_

2017-08-21 23:43:47 -0500 received badge  Notable Question (source)
2017-08-21 18:58:47 -0500 commented answer How to get image from custom server using service?

@ jayees I don't have any msg variable in my client code. The link you shared has a image callback function, i.e. it's a

2017-08-21 17:49:19 -0500 received badge  Popular Question (source)
2017-08-21 17:41:01 -0500 commented question How to get image from custom server using service?

Done @jayess

2017-08-21 17:40:35 -0500 edited question How to get image from custom server using service?

How to get image from custom server using service? Hello People, I am trying to pass image from server to a client. The

2017-08-21 17:39:54 -0500 edited question How to get image from custom server using service?

How to get image from custom server using service? Hello People, I am trying to pass image from server to a client. The

2017-08-21 14:09:51 -0500 edited question How to get image from custom server using service?

How to get image from custom server using service? Hello People, I am trying to pass image from server to a client. The

2017-08-21 14:02:33 -0500 edited question How to get image from custom server using service?

How to get image from custom server using service? Hello People, I am trying to pass image from server to a client. The

2017-08-21 13:33:54 -0500 commented question How to get image from custom server using service?

Will do it, Thanks @jayess

2017-08-21 12:38:59 -0500 asked a question How to get image from custom server using service?

How to get image from custom server using service? Hello People, I am trying to pass image from server to a client. The

2017-08-19 16:20:18 -0500 received badge  Notable Question (source)
2017-08-19 15:17:53 -0500 commented answer Client for Receiving Images from Server

@EdisonJava comment answers not questions. Inorder to ask question related to the question post in the add comment secti

2017-08-19 11:25:59 -0500 received badge  Popular Question (source)
2017-08-18 16:31:03 -0500 asked a question Client for Receiving Images from Server

Client for Receiving Images from Server Hello People, I am trying to pass image from server to a client. The code compl

2017-08-17 18:14:14 -0500 commented answer How to pass an image (subscribed from a image publishing topic) using service?

Hello @lucasw. I still have a query it works using res.img = *image_msg, but that means I am passing the data stored at

2017-08-17 16:48:06 -0500 received badge  Notable Question (source)
2017-08-15 10:49:41 -0500 edited question How to pass an image (subscribed from a image publishing topic) using service?

How to pass an image (subscribed from a image publishing topic) using service? Hello People, I am trying to get image fr

2017-08-15 00:35:49 -0500 received badge  Popular Question (source)
2017-08-14 22:49:27 -0500 commented answer How to pass an image (subscribed from a image publishing topic) using service?

Thanks again @lucasw. It worked.

2017-08-14 22:48:36 -0500 marked best answer How to pass an image (subscribed from a image publishing topic) using service?

Hello People, I am trying to get image from a camera fitted on a robot and pass them using services. I will use a client to grab images from the server and later process it according to the need. It would be great if some can give me a sample template code to follow to achieve the same. But I have been receiving the following error -

error: ‘const struct sensor_msgs::Image_<std::allocator<void> >’ has no member named ‘toImageMsg’
   res.img = image_msg->toImageMsg;
                        ^
/home/dark_knight/ros_prac/catkin_ws_baxter2.1/src/robot_vision/src/vision_node.cpp: In function ‘void imageCallback(const ImageConstPtr&)’:
/home/dark_knight/ros_prac/catkin_ws_baxter2.1/src/robot_vision/src/vision_node.cpp:37:67: error: no matching function for call to ‘cv_bridge::CvImage::CvImage(std_msgs::Header, const char [5], const ImageConstPtr&)’
     image_msg = cv_bridge::CvImage(std_msgs::Header(), "bgr8", msg).toImageMsg();

Below is my code trying to do the same, I have been trying various things -

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include "sensor_msgs/Image.h"
#include <opencv2/imgproc/imgproc.hpp>
#include "robot_vision/request_image.h"

ros::ServiceServer service;
image_transport::Subscriber sub;

sensor_msgs::ImageConstPtr image_msg;

bool get_image(robot_vision::request_image::Request  &req, robot_vision::request_image::Response &res)
{
    if(req.request_message == true)
    {
        ROS_INFO("sending back response");
        res.img = *image_msg;
    }
    else
    {
        ROS_INFO("No request received");
    }
    ros::spinOnce();
    ros::Duration(0.2).sleep();
    return true;
}
void imageCallback(const sensor_msgs::ImageConstPtr& msg)
{
  try
  {
    image_msg = msg;
   }
  catch (cv_bridge::Exception& e)
  {
    ROS_ERROR("Image data was not received");
  }
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "vision_node");
  ros::NodeHandle nh;
  //cv::namedWindow("view");
  //cv::startWindowThread();
  image_transport::ImageTransport it(nh);
  sub = it.subscribe("/cameras/head_camera/image", 1, imageCallback);
  service = nh.advertiseService("image_server", get_image);
  ros::spin();
  //cv::destroyWindow("view");
}

The above coded has been edited to work.

2017-08-14 18:46:37 -0500 edited question How to pass an image (subscribed from a image publishing topic) using service?

How to pass an image (subscribed from a image publishing topic) using service? Hello People, I am trying to get image fr

2017-08-14 18:40:22 -0500 edited question How to pass an image (subscribed from a image publishing topic) using service?

How to pass an image (subscribed from a image publishing topic) using service? Hello People, I am trying to get image fr

2017-08-14 18:39:52 -0500 asked a question How to pass an image (subscribed from a image publishing topic) using service?

How to pass an image (subscribed from a image publishing topic) using service? Hello People, I am trying to get image fr

2017-08-13 20:05:36 -0500 received badge  Enthusiast
2017-08-13 20:05:36 -0500 received badge  Enthusiast
2017-08-01 02:59:32 -0500 received badge  Notable Question (source)
2017-07-31 17:28:25 -0500 received badge  Editor (source)
2017-07-31 17:28:25 -0500 edited question Problem integrating ros with opencv to work with rgb camera output in ros.

Problem integrating ros with opencv to work with rgb camera output in ros. I am trying to integrate the normal rgb camer