On 4/22/10 8:19 PM, Patrick Mihelich wrote:
What is the type of the data in your cvMat? I assume it's either float or double?
I probably should have included the line where the cvMat was declared.
CvMat _h = cvMat(3, 3, CV_64F, h);

Are the publisher and subscriber on the same machine?
They are

I suspect you meant h_m.mat[j*3+k], but that doesn't explain the totally wrong numbers.

Right before your publish() call, can you print out the contents of h_m.mat and check that they're correct.
If I print out the numbers before publishing, they are indeed correct.

As an aside, the new C++ interface to OpenCV is a big improvement over cvMat/IplImage if you like niceties like type safety, automatic freeing of memory and more succinct code.
Awesome, I didn't know about that!

-Patrick

On Thu, Apr 22, 2010 at 5:52 PM, Dan Lazewatsky <lazewatskyd@cse.wustl.edu> wrote:
Hi all -
I have a cvMat that I'm trying to send out in a ROS message, but I'm
having some issues getting it to work right.

My message definition is: float64[9] mat
I'm loading data into the message as follows:
myMessage h_m;
for(int j=0; j<3;++j){
    for(int k=0; k<3; ++k){
        h_m.mat[j+k*3] = cvmGet(&_h, j, k);
    }
}

No errors here, but when I look at the data from a subscriber (or using
rostopic echo), but numbers are wrong. Numbers that should be in the
range of 0-10 end up in 10^6-10^-5. I've tried creating a
std_msgs::Float64 and casting to a Float64 first, neither of which
worked. I'm at a bit of a loss as to what's going on. Any help would be
appreciated.

Thanks,
-Dan
_______________________________________________
ros-users mailing list
ros-users@code.ros.org
https://code.ros.org/mailman/listinfo/ros-users

_______________________________________________ ros-users mailing list ros-users@code.ros.org https://code.ros.org/mailman/listinfo/ros-users