Skip to content

Commit 0c344ac

Browse files
committed
Merge pull request #61 from JamesH65/raw_rgb
Added the option to save the raw data as RGB888.
2 parents 7e47f7f + 277cff2 commit 0c344ac

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

host_applications/linux/apps/raspicam/RaspiStillYUV.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
2828

2929
/*
30-
* \file RaspiStill.c
31-
* Command line program to capture a still frame and encode it to file.
30+
* \file RaspiStillYUV.c
31+
* Command line program to capture a still frame and dump uncompressed it to file.
3232
* Also optionally display a preview/viewfinder of current camera input.
3333
*
3434
* \date 4th March 2013
@@ -102,6 +102,7 @@ typedef struct
102102
char *filename; /// filename of output file
103103
int verbose; /// !0 if want detailed run information
104104
int timelapse; /// Delay between each picture in timelapse mode. If 0, disable timelapse
105+
int useRGB; /// Output RGB data rather than YUV
105106

106107
RASPIPREVIEW_PARAMETERS preview_parameters; /// Preview setup parameters
107108
RASPICAM_CAMERA_PARAMETERS camera_parameters; /// Camera setup parameters
@@ -131,6 +132,7 @@ static void display_valid_parameters(char *app_name);
131132
#define CommandVerbose 4
132133
#define CommandTimeout 5
133134
#define CommandTimelapse 6
135+
#define CommandUseRGB 7
134136

135137
static COMMAND_LIST cmdline_commands[] =
136138
{
@@ -141,6 +143,7 @@ static COMMAND_LIST cmdline_commands[] =
141143
{ CommandVerbose, "-verbose", "v", "Output verbose information during run", 0 },
142144
{ CommandTimeout, "-timeout", "t", "Time (in ms) before takes picture and shuts down. If not specified set to 5s", 1 },
143145
{ CommandTimelapse,"-timelapse", "tl", "Timelapse mode. Takes a picture every <t>ms", 1},
146+
{ CommandUseRGB, "-rgb", "rgb","Save as RGB data rather than YUV", 0},
144147
};
145148

146149
static int cmdline_commands_size = sizeof(cmdline_commands) / sizeof(cmdline_commands[0]);
@@ -292,6 +295,9 @@ static int parse_cmdline(int argc, const char **argv, RASPISTILLYUV_STATE *state
292295
i++;
293296
break;
294297

298+
case CommandUseRGB: // display lots of data during run
299+
state->useRGB = 1;
300+
break;
295301

296302
default:
297303
{
@@ -551,8 +557,16 @@ static MMAL_STATUS_T create_camera_component(RASPISTILLYUV_STATE *state)
551557
format = still_port->format;
552558

553559
// Set our stills format on the stills port
554-
format->encoding = MMAL_ENCODING_I420;
555-
format->encoding_variant = MMAL_ENCODING_I420;
560+
if (state->useRGB)
561+
{
562+
format->encoding = MMAL_ENCODING_BGR24;
563+
format->encoding_variant = MMAL_ENCODING_BGR24;
564+
}
565+
else
566+
{
567+
format->encoding = MMAL_ENCODING_I420;
568+
format->encoding_variant = MMAL_ENCODING_I420;
569+
}
556570
format->es->video.width = state->width;
557571
format->es->video.height = state->height;
558572
format->es->video.crop.x = 0;

0 commit comments

Comments
 (0)