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

Revision history [back]

click to hide/show revision 1
initial version

hello,

the uint8[] data is the raw image data. inorder to have individual channel you need to know the image data is structured or unstructured. it means the it RGB[pix1] RGB[pix2]....... or R[pix1] R[pix2].........G[pix1] G[pix2].........G[pix1] R[pix2].......... once u know which type it is using a incremental loop (for loop) you can extract whatever you want. i can give you one eg i used for reconstrution of image in the subscriber node.

for(int i=(w-1);i>=0;i--)

{

for(int j=(h-1);j>=0;j--)
 { 

   *(image(i,j)) = *(&img->data[count]);

   count++;
   *(image(i,j)+1) = *(&img->data[count]);
   count++;
   *(image(i,j)+2) = *(&img->data[count]);
    count++;
  }
}

here img is sensor_msgs::Image. please tell me if its not clear.

hello,

the uint8[] data is the raw image data. inorder to have individual channel you need to know the image data is structured or unstructured. it means the it is RGB[pix1] RGB[pix2]....... or R[pix1] R[pix2].........G[pix1] G[pix2].........G[pix1] R[pix2].......... G[pix2].........B[pix1] B[pix2].......... once u know which type it is using a incremental loop (for loop) you can extract whatever you want. i can give you one eg i used for reconstrution of image in the subscriber node.

for(int i=(w-1);i>=0;i--)

{

for(int j=(h-1);j>=0;j--)
 { 

   *(image(i,j)) = *(&img->data[count]);

   count++;
   *(image(i,j)+1) = *(&img->data[count]);
   count++;
   *(image(i,j)+2) = *(&img->data[count]);
    count++;
  }
}

here img is sensor_msgs::Image. please tell me if its not clear.

hello,

the uint8[] data is the raw image data. inorder to have individual channel you need to know the image data is structured or unstructured. it means the it is RGB[pix1] RGB[pix2]....... or R[pix1] R[pix2].........G[pix1] G[pix2].........B[pix1] B[pix2].......... once u know which type it is using a incremental loop (for loop) you can extract whatever you want. i can give you one eg i used for reconstrution reconstruction of image in the subscriber node.

for(int i=(w-1);i>=0;i--)

{

for(int j=(h-1);j>=0;j--)
 { 

   *(image(i,j)) = *(&img->data[count]);

   count++;
   *(image(i,j)+1) = *(&img->data[count]);
   count++;
   *(image(i,j)+2) = *(&img->data[count]);
    count++;
  }
}

here img is sensor_msgs::Image. please tell me if its not clear.

hello,

the uint8[] data is the raw image data. inorder to have individual channel you need to know the image data is structured or unstructured. it means the it is RGB[pix1] RGB[pix2]....... or R[pix1] R[pix2].........G[pix1] G[pix2].........B[pix1] B[pix2].......... once u know which type it is using a incremental loop (for loop) you can extract whatever you want. i can give you one eg i used for reconstruction of image in the subscriber node.

for(int i=(w-1);i>=0;i--)

{

for(int i=(w-1);i>=0;i--)
{
    for(int j=(h-1);j>=0;j--)
  { 
     *(image(i,j)) = *(&img->data[count]);
     count++;
    *(image(i,j)+1) = *(&img->data[count]);
    count++;
    *(image(i,j)+2) = *(&img->data[count]);
     count++;
   }
}

here img is sensor_msgs::Image. please tell me if its not clear.