roberttidey / userland

Source code for ARM side libraries for interfacing to Raspberry Pi GPU.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] What is out pixel format of image?

AlexanderBykin opened this issue · comments

Hi
What is out pixel format of image?
Does it possible to convert out images from RaspiMJPEG to RGB565 ?
This will help to reduce image size and increase network bandwidth

There is an internal pipeline which connects the camera data to various components h26 encoder, jpeg encoders, motion data etc.

Still image capture and the mjpeg stream use separate jpeg encoders. For the mjpeg stream the encoder writes a new cam.jpg file into /dev/shm/cam.jpg for every new frame of data from the camera.

RGB565 is a 16bit raw image format which uses 5 bits for Red and Blue and 6 for Green. It is not compressed and would give larger files than jpeg.

If you want to reduce image size and reduce network bandwidth then you can tune the preview parameters under camera settings. The pixel resolution can be reduced by changing the width, the compression can be increased by reducing the quality factor and the frame rate can be adjusted by changing the divider.

So for example with default w=512,q=10,d=1 I got an image size of 12KB updating 25 fps for a network bandwidth of 400KB/s.

Changing to w=256,q=6,d=3 I got an image size of 3KB updating 8.3 fps for a network bandwidth of 25KB/s

ok understand that, thanks.
also does it possible to receive taken image directly from FIFO instead of saving them to file?
i just want to write an program to listen FIFO, receive bytes and then send image by network.

The relevant code here is the jpegencoder_buffer_callback in host_applications/linux/apps/raspicam/RaspiMCam.c

This takes the jpeg stream from the encoder and writes it to file. Actually it writes to a temporary file and then when it has a buffer which includes an end flag it closes this file and copies it to the final one (cam.jpg). It is done this way so that cam.jpg is always a valid full jpg file.

You could either change this routine to write to a FIFO instead or leave it alone and have a separate program picking up each new cam.jpg (detected by its modify date) and write that to your stream. Note that the dev/shm/mjpeg folder is in RAM fs quick and does not wear out the SD card.

thanks for clarification.
in my tests Linux FS Notify system is not so fast as RaspiMJPEG takes picture in that case only helps infinite loop to read that file.

Actually it writes to a temporary file so in that case we anyway take time of CPU and RAM to copy and save that file, could it be direct write to FIFO (some modification needed) ?

Yes. The routine I mentioned would need to be modified to write direct to FIFO input. Ideally this could be done in a way that keeps the existing functionality. So, for example, one could write the buffer to both a FIFO and to the exiting file output.

The temporary file is actually just renamed so no physical copying is involved so this is very quick.

Note that these file sizes are very small so the CPU time involved is tiny. The whole CPU usage of the whole raspimjpeg process (camera input, video and image processing etc) is typically about 2%.

could write the buffer to both a FIFO and to the exiting file output so, could it be a Feature request to write also to FIFO ?
FIFO should be configurable as it done with other FIFOs