RAPICAM_3-15-2015
RaspiStill.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <unistd.h>
#include <errno.h>
#include <sysexits.h>
#include "bcm_host.h"
#include "interface/vcos/vcos.h"
#include "interface/mmal/mmal.h"
#include "interface/mmal/mmal_logging.h"
#include "interface/mmal/mmal_buffer.h"
#include "interface/mmal/util/mmal_util.h"
#include "interface/mmal/util/mmal_util_params.h"
#include "interface/mmal/util/mmal_default_components.h"
#include "interface/mmal/util/mmal_connection.h"
#include "RaspiCamControl.h"
#include "RaspiPreview.h"
#include "RaspiCLI.h"
#include "RaspiTex.h"
#include <semaphore.h>

Classes

struct  RASPISTILL_STATE
 
struct  PORT_USERDATA
 

Macros

#define _GNU_SOURCE
 
#define VERSION_STRING   "v1.3.8"
 
#define MMAL_CAMERA_PREVIEW_PORT   0
 
#define MMAL_CAMERA_VIDEO_PORT   1
 
#define MMAL_CAMERA_CAPTURE_PORT   2
 
#define STILLS_FRAME_RATE_NUM   0
 
#define STILLS_FRAME_RATE_DEN   1
 
#define VIDEO_OUTPUT_BUFFERS_NUM   3
 Video render needs at least 2 buffers.
 
#define MAX_USER_EXIF_TAGS   32
 
#define MAX_EXIF_PAYLOAD_LENGTH   128
 
#define FRAME_NEXT_SINGLE   0
 Frame advance method.
 
#define FRAME_NEXT_TIMELAPSE   1
 
#define FRAME_NEXT_KEYPRESS   2
 
#define FRAME_NEXT_FOREVER   3
 
#define FRAME_NEXT_GPIO   4
 
#define FRAME_NEXT_SIGNAL   5
 
#define FRAME_NEXT_IMMEDIATELY   6
 
#define CommandHelp   0
 Comamnd ID's and Structure defining our command line options.
 
#define CommandWidth   1
 
#define CommandHeight   2
 
#define CommandQuality   3
 
#define CommandRaw   4
 
#define CommandOutput   5
 
#define CommandVerbose   6
 
#define CommandTimeout   7
 
#define CommandThumbnail   8
 
#define CommandDemoMode   9
 
#define CommandEncoding   10
 
#define CommandExifTag   11
 
#define CommandTimelapse   12
 
#define CommandFullResPreview   13
 
#define CommandLink   14
 
#define CommandKeypress   15
 
#define CommandSignal   16
 
#define CommandGL   17
 
#define CommandGLCapture   18
 
#define CommandSettings   19
 
#define CommandCamSelect   20
 
#define CommandBurstMode   21
 
#define CommandSensorMode   22
 
#define CommandDateTime   23
 
#define CommandTimeStamp   24
 

Functions

int mmal_status_to_int (MMAL_STATUS_T status)
 
MMAL_STATUS_T create_filenames (char **finalName, char **tempName, char *pattern, int frame)
 
int main (int argc, const char **argv)
 

Detailed Description

Command line program to capture a still frame and encode it to file. Also optionally display a preview/viewfinder of current camera input.

Date
31 Jan 2013 : James Hughes

Description

3 components are created; camera, preview and JPG encoder. Camera component has three ports, preview, video and stills. This program connects preview and stills to the preview and jpg encoder. Using mmal we don't need to worry about buffers between these components, but we do need to handle buffers from the encoder, which are simply written straight to the file in the requisite buffer callback.

We use the RaspiCamControl code to handle the specific camera settings.

Function Documentation

MMAL_STATUS_T create_filenames ( char **  finalName,
char **  tempName,
char *  pattern,
int  frame 
)

Allocates and generates a filename based on the user-supplied pattern and the frame number. On successful return, finalName and tempName point to malloc()ed strings which must be freed externally. (On failure, returns nulls that don't need free()ing.)

Parameters
finalNamepointer receives an
patternsprintf pattern with d to be replaced by frame
framefor timelapse, the frame number
Returns
Returns a MMAL_STATUS_T giving result of operation
int main ( int  argc,
const char **  argv 
)

main

int mmal_status_to_int ( MMAL_STATUS_T  status)

Convert a MMAL status return value to a simple boolean of success ALso displays a fault if code is not success

Parameters
statusThe error code to convert
Returns
0 if status is sucess, 1 otherwise