Publishing 2D Array with sensor_msgs/Image
I want to publish a 2D array, which is populated by int values. These values are delivered by a radar sensor and represent the reflected power of detected targets. So these values give information about the distance between the detected objects and the sensor.
This is an extract of my source code:
int* pointCloud //double pointer for 2D Array with dimension sizeX and sizeY int rasterImage; //array-variable int sizeX; //amount of pixel along X-axis int sizeY; //amount of pixel along Y-axis int index; //represents value of reflected power
pointCloud = new int* [sizeX]; for (int x = 0; x < sizeX; x++) { pointCloud[x] = new int [sizeY]; for (int y = 0; y < sizeY; y++) { int index = (sizeX * y) + x; pointCloud[x][y] = rasterImage[index]; } }
for (int y = 0; y < sizeY; y++) { for (int x = 0; x < sizeX; x++) { printf("%d ", pointCloud[x][y]); } printf("\n"); }
I want to create a image to visualize the detected objects. Now the problem is to fill the matrix data into the message and to publish rasterImage via sensor_msgs/Image...
depth_image.height = sizeY;
depth_image.width = sizeX;
//depth_image.encoding = rgb8;
depth_image.is_bigendian = false;
depth_image.step = sizeX * sizeY;
depth_image.data = rasterImage; --> ERROR MESSAGE
ERROR: no match for ‘operator=’ (operand types are ‘sensor_msgs::Image_<std::allocator<void> >::_data_type {aka std::vector<unsigned char,="" std::allocator<unsigned="" char=""> >}’ and ‘int*’)
Has anybody an advice to fix this problem?
==============================================
If I use std:vector<uint8_t> rasterImage, I get this error:
error: cannot convert ‘std::vector<unsigned char="">’ to ‘int’ for argument ‘1’ to ‘WALABOT_RESULT Walabot_GetRawImageSlice(int, int, int, double, double)’ res = Walabot_GetRawImageSlice(rasterImage, &sizeX, &sizeY, &sliceDepth, &power);
The function I'm using to get the values is this one:
http://api.walabot.com/_walabot_a_p_i...
How to solve this problem?
Thanks!
I was about to devel into something Similar with the Walabot do you have your code on Github or anywhere?