<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Josh,<br>
<br>
Using a null deleter and shared_ptr works properly.<br>
<br>
Thank you,<br>
Soonhac<br>
<br>
<br>
On 11/19/2010 01:24 PM, Josh Faust wrote:
<blockquote
 cite="mid:AANLkTi=mJfM=WstS7gJRhoPznJTOb2ezmvQ2rfYBBzB3@mail.gmail.com"
 type="cite">Ah, but it looks like fromImage is deprecated.  Does
anyone know why there's no longer a way of turning a non-shared pointer
of a sensor_msgs/Image into a cv image?
  <div><br>
  </div>
  <div>In the meantime you could use a null deleter and create a
shared_ptr out of the image:</div>
  <div><br>
  </div>
  <div>void nullDeleter(void*) {}</div>
  <div>boost::shared_ptr<sensor_msgs::Image>
image_ptr(&srv.response.left_image, nullDeleter);</div>
  <div><br>
  </div>
  <div>Josh</div>
  <div><br>
  <div class="gmail_quote">On Fri, Nov 19, 2010 at 1:18 PM, Josh Faust <span
 dir="ltr"><<a moz-do-not-send="true"
 href="mailto:jfaust@willowgarage.com">jfaust@willowgarage.com</a>></span>
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">What
was the compile error you got originally?  That's not a valid cast to
be making.
    <div><br>
    </div>
    <div>There's a version of fromImage that just takes the
sensor_msgs/Image -- are you sure that srv.response.left_image is a
sensor_msgs/Image?</div>
    <div><br>
    </div>
    <div><font color="#888888">Josh<br>
    <br>
    </font>
    <div class="gmail_quote">
    <div class="im">On Fri, Nov 19, 2010 at 12:49 PM, Soonhac Hong <span
 dir="ltr"><<a moz-do-not-send="true"
 href="mailto:soonhac.hong@gmail.com" target="_blank">soonhac.hong@gmail.com</a>></span>
wrote:<br>
    </div>
    <div>
    <div class="h5">
    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi
all,<br>
      <br>
I'm trying to convert sensor_msgs/Image to the opencv image. The<br>
sensor_msgs/Image is defined in the ros service as follows.<br>
      <br>
<temp_srv.srv><br>
bool isColor<br>
----<br>
sensor_msgs/Image left_image<br>
      <br>
      <br>
The problem has happened at the following code.<br>
      <br>
IplImage* left_image = bridge_.imgMsgToCv((const<br>
sensor_msgs::ImageConstPtr&) srv.response.left_image,
"passthrough");<br>
      <br>
Without the casting,(const sensor_msgs::ImageConstPtr&), there was
an<br>
compile error. With the casting, there is a runtime error, segmentation<br>
fault. Is there anyone to know how to get the<br>
sensor_msgs::ImageConstPtr& of the sensor_msgs/Image which is
defined in<br>
the ros service?<br>
      <br>
I confirmed that there are the proper value of each pixel in the<br>
srv.response.left_image.data[] as well as srv.response.left_image.width<br>
and srv.response.left_image.hight.<br>
      <br>
Thank you for any comments.<br>
      <br>
Best,<br>
Soonhac<br>
      <br>
_______________________________________________<br>
ros-users mailing list<br>
      <a moz-do-not-send="true" href="mailto:ros-users@code.ros.org"
 target="_blank">ros-users@code.ros.org</a><br>
      <a moz-do-not-send="true"
 href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
    </blockquote>
    </div>
    </div>
    </div>
    <br>
    </div>
  </blockquote>
  </div>
  <br>
  </div>
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
ros-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a>
<a class="moz-txt-link-freetext" href="https://code.ros.org/mailman/listinfo/ros-users">https://code.ros.org/mailman/listinfo/ros-users</a>
  </pre>
</blockquote>
<br>
</body>
</html>