# Raspicam Image Publish RAW instead

**URL:** <https://forum.ubiquityrobotics.com/t/raspicam-image-publish-raw-instead/768>\
**Category:** Uncategorized\
**Created:** [March 26, 2021, 9:22pm UTC](https://forum.ubiquityrobotics.com/t/raspicam-image-publish-raw-instead/768 "2021-03-26T21:22:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![IngeniousDoc](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/i/94ad74/32.png) [@IngeniousDoc](https://forum.ubiquityrobotics.com/u/IngeniousDoc)\
**Post date:** [March 26, 2021, 9:22pm UTC](https://forum.ubiquityrobotics.com/t/raspicam-image-publish-raw-instead/768/1 "2021-03-26T21:22:49Z")

</div>

I am trying to use the raspicam pacakge as my camera device, however, I need to use raw image instead of the compressed.

What do I need to adjust in the code to make the image being published to be raw instead of compressed?

---

<div class="post-metadata">

**Author:** ![mjstn2011](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/mjstn2011/32/30_2.png) [@mjstn2011](https://forum.ubiquityrobotics.com/u/mjstn2011)\
**Post date:** [March 26, 2021, 10:29pm UTC](https://forum.ubiquityrobotics.com/t/raspicam-image-publish-raw-instead/768/2 "2021-03-26T22:29:33Z")

</div>

It has been a long time since I did what you are discussing but I have this note, look into use of this method I guess. This method takes in a compressed stream and outputs a raw stream.  
This was for my use a few years back so you may have to mess with the topic names.

The tool is use of image\_transport (if this is not on your image you would have to get it using an apt get but I don’t have time right now to try all this. See if this helps. I can try more later if the info below does not work for you today.

rosrun image\_transport republish compressed in:=/raspicam\_node/image raw out:=/raspicam\_node/image

And here is a second note that was meant for putting in my launch file rather than on command line:

The second one new topic is a different name so you have to use the new name of the raw topic stream of course in your conversion input source topic.

---

<div class="post-metadata">

**Author:** ![IngeniousDoc](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/i/94ad74/32.png) [@IngeniousDoc](https://forum.ubiquityrobotics.com/u/IngeniousDoc)\
**Post date:** [March 26, 2021, 10:39pm UTC](https://forum.ubiquityrobotics.com/t/raspicam-image-publish-raw-instead/768/3 "2021-03-26T22:39:30Z")

</div>

I shall try this out and see what I can do, thanks!

---

<div class="post-metadata">

**Author:** ![MoffKalast](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/moffkalast/32/214_2.png) [@MoffKalast](https://forum.ubiquityrobotics.com/u/MoffKalast)\
**Post date:** [March 27, 2021, 1:23am UTC](https://forum.ubiquityrobotics.com/t/raspicam-image-publish-raw-instead/768/4 "2021-03-27T01:23:25Z")

</div>

Actually, that’s not the whole story. The raw format requires width to be divisible by 32, and height to be divisible by 16 which it isn’t by default.

So you’ll have to go into the launch file and correct to resolution so it fits that requirement otherwise transport will crash.

More info:

> <https://github.com/UbiquityRobotics/raspicam_node/issues/77#issuecomment-615138550>
>
> Hi there,
> When I enable the \`enable\_raw\` flag to get the raw image, unfortunate…ly the image cannot be loaded to Rviz. The reason is that the data being published into the \`/raspicam\_node/image\` topic is somehow corrupted. Here is an instance of the published raw image:
> 
> \`header: 
> seq: 1109
> stamp: 
> secs: 1555185561
> nsecs: 712540212
> frame\_id: raspicam
> height: 308
> width: 410
> encoding: bgr8
> is\_bigendian: 0
> step: 1230
> data: \<array type: uint8, length: 399360\>\`
> 
> By looking at the published raw image above, we see that the stream size (length of the data:399360) does not match the calculated image size (308\*410\*3=378840). And that is why Rviz cannot visualise it. 
> If I use the image\_transport package to uncompress the compressed image published into the \`/raspicam\_node/image/compressed\`, then I get the following data type, and I can visualise it in Rviz. 
> 
> \`header: 
> seq: 1246
> stamp: 
> secs: 1555185575
> nsecs: 412069710
> frame\_id: raspicam
> height: 308
> width: 410
> encoding: bgr8
> is\_bigendian: 0
> step: 1230
> data: \<array type: uint8, length: 378840\>\`
> 
> I would appreciate any hint on how to fix this bug. Thank you

This is something we should really fix, but nobody’s really taken it up yet.

---

<div class="post-metadata">

**Author:** ![rohbotics](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/rohbotics/32/222_2.png) [@rohbotics](https://forum.ubiquityrobotics.com/u/rohbotics)\
**Post date:** [March 27, 2021, 2:57pm UTC](https://forum.ubiquityrobotics.com/t/raspicam-image-publish-raw-instead/768/5 "2021-03-27T14:57:24Z")

</div>

Raspicam also supports raw publishing by adding `enable_raw:=true` to the launch command, for example:

```auto
roslaunch raspicam_node camerav2_1280x960_10fps.launch enable_raw:=true

```

Its in the calibration section of the README: [https://github.com/UbiquityRobotics/raspicam\_node#calibration](https://github.com/UbiquityRobotics/raspicam_node#calibration)
