\hypertarget{_raspi_still_8c}{}\section{/\+Volumes/\+W\+O\+R\+K\+\_\+\+I\+N\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S/\+R\+A\+S\+P\+B\+E\+R\+R\+Y\+\_\+\+P\+I/github/userland/host\+\_\+applications/linux/apps/raspicam/\+Raspi\+Still.c File Reference}
\label{_raspi_still_8c}\index{/\+Volumes/\+W\+O\+R\+K\+\_\+\+I\+N\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S/\+R\+A\+S\+P\+B\+E\+R\+R\+Y\+\_\+\+P\+I/github/userland/host\+\_\+applications/linux/apps/raspicam/\+Raspi\+Still.\+c@{/\+Volumes/\+W\+O\+R\+K\+\_\+\+I\+N\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S/\+R\+A\+S\+P\+B\+E\+R\+R\+Y\+\_\+\+P\+I/github/userland/host\+\_\+applications/linux/apps/raspicam/\+Raspi\+Still.\+c}}
{\ttfamily \#include $<$stdio.\+h$>$}\\*
{\ttfamily \#include $<$stdlib.\+h$>$}\\*
{\ttfamily \#include $<$string.\+h$>$}\\*
{\ttfamily \#include $<$memory.\+h$>$}\\*
{\ttfamily \#include $<$unistd.\+h$>$}\\*
{\ttfamily \#include $<$errno.\+h$>$}\\*
{\ttfamily \#include $<$sysexits.\+h$>$}\\*
{\ttfamily \#include \char`\"{}bcm\+\_\+host.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/vcos/vcos.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/mmal.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/mmal\+\_\+logging.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/mmal\+\_\+buffer.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/util/mmal\+\_\+util.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/util/mmal\+\_\+util\+\_\+params.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/util/mmal\+\_\+default\+\_\+components.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/util/mmal\+\_\+connection.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}Raspi\+Cam\+Control.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}Raspi\+Preview.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}Raspi\+C\+L\+I.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}Raspi\+Tex.\+h\char`\"{}}\\*
{\ttfamily \#include $<$semaphore.\+h$>$}\\*
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{struct_r_a_s_p_i_s_t_i_l_l___s_t_a_t_e}{R\+A\+S\+P\+I\+S\+T\+I\+L\+L\+\_\+\+S\+T\+A\+T\+E}
\item 
struct \hyperlink{struct_p_o_r_t___u_s_e_r_d_a_t_a}{P\+O\+R\+T\+\_\+\+U\+S\+E\+R\+D\+A\+T\+A}
\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\hypertarget{_raspi_still_8c_a369266c24eacffb87046522897a570d5}{}\#define {\bfseries \+\_\+\+G\+N\+U\+\_\+\+S\+O\+U\+R\+C\+E}\label{_raspi_still_8c_a369266c24eacffb87046522897a570d5}

\item 
\hypertarget{_raspi_still_8c_a698acb89e1bf5837b33c30ef35c30044}{}\#define {\bfseries V\+E\+R\+S\+I\+O\+N\+\_\+\+S\+T\+R\+I\+N\+G}~\char`\"{}v1.\+3.\+8\char`\"{}\label{_raspi_still_8c_a698acb89e1bf5837b33c30ef35c30044}

\item 
\hypertarget{_raspi_still_8c_a8cc92011d6ebe2f6c3bd842467181fe0}{}\#define {\bfseries M\+M\+A\+L\+\_\+\+C\+A\+M\+E\+R\+A\+\_\+\+P\+R\+E\+V\+I\+E\+W\+\_\+\+P\+O\+R\+T}~0\label{_raspi_still_8c_a8cc92011d6ebe2f6c3bd842467181fe0}

\item 
\hypertarget{_raspi_still_8c_ab8b496a6c64a35c25734f640ff2909db}{}\#define {\bfseries M\+M\+A\+L\+\_\+\+C\+A\+M\+E\+R\+A\+\_\+\+V\+I\+D\+E\+O\+\_\+\+P\+O\+R\+T}~1\label{_raspi_still_8c_ab8b496a6c64a35c25734f640ff2909db}

\item 
\hypertarget{_raspi_still_8c_a6ea8994f409e4b977b3f49529bd8836e}{}\#define {\bfseries M\+M\+A\+L\+\_\+\+C\+A\+M\+E\+R\+A\+\_\+\+C\+A\+P\+T\+U\+R\+E\+\_\+\+P\+O\+R\+T}~2\label{_raspi_still_8c_a6ea8994f409e4b977b3f49529bd8836e}

\item 
\hypertarget{_raspi_still_8c_a7c1cd57790def94505c3b4507aeb42e3}{}\#define {\bfseries S\+T\+I\+L\+L\+S\+\_\+\+F\+R\+A\+M\+E\+\_\+\+R\+A\+T\+E\+\_\+\+N\+U\+M}~0\label{_raspi_still_8c_a7c1cd57790def94505c3b4507aeb42e3}

\item 
\hypertarget{_raspi_still_8c_a9ef3e70e36c423824d0d8c32ae3cd362}{}\#define {\bfseries S\+T\+I\+L\+L\+S\+\_\+\+F\+R\+A\+M\+E\+\_\+\+R\+A\+T\+E\+\_\+\+D\+E\+N}~1\label{_raspi_still_8c_a9ef3e70e36c423824d0d8c32ae3cd362}

\item 
\hypertarget{_raspi_still_8c_a45ef30a3e903c0589d9c1191047fb960}{}\#define \hyperlink{_raspi_still_8c_a45ef30a3e903c0589d9c1191047fb960}{V\+I\+D\+E\+O\+\_\+\+O\+U\+T\+P\+U\+T\+\_\+\+B\+U\+F\+F\+E\+R\+S\+\_\+\+N\+U\+M}~3\label{_raspi_still_8c_a45ef30a3e903c0589d9c1191047fb960}

\begin{DoxyCompactList}\small\item\em Video render needs at least 2 buffers. \end{DoxyCompactList}\item 
\hypertarget{_raspi_still_8c_ad40a9b23f8923a1bec42a88697ed7b99}{}\#define {\bfseries M\+A\+X\+\_\+\+U\+S\+E\+R\+\_\+\+E\+X\+I\+F\+\_\+\+T\+A\+G\+S}~32\label{_raspi_still_8c_ad40a9b23f8923a1bec42a88697ed7b99}

\item 
\hypertarget{_raspi_still_8c_a5deead59ba65ab0a847c8422f8baab82}{}\#define {\bfseries M\+A\+X\+\_\+\+E\+X\+I\+F\+\_\+\+P\+A\+Y\+L\+O\+A\+D\+\_\+\+L\+E\+N\+G\+T\+H}~128\label{_raspi_still_8c_a5deead59ba65ab0a847c8422f8baab82}

\item 
\hypertarget{_raspi_still_8c_a721fbb1d0d042060c837542581127418}{}\#define \hyperlink{_raspi_still_8c_a721fbb1d0d042060c837542581127418}{F\+R\+A\+M\+E\+\_\+\+N\+E\+X\+T\+\_\+\+S\+I\+N\+G\+L\+E}~0\label{_raspi_still_8c_a721fbb1d0d042060c837542581127418}

\begin{DoxyCompactList}\small\item\em Frame advance method. \end{DoxyCompactList}\item 
\hypertarget{_raspi_still_8c_add6929127c0adedca29a10e73a0c0d4c}{}\#define {\bfseries F\+R\+A\+M\+E\+\_\+\+N\+E\+X\+T\+\_\+\+T\+I\+M\+E\+L\+A\+P\+S\+E}~1\label{_raspi_still_8c_add6929127c0adedca29a10e73a0c0d4c}

\item 
\hypertarget{_raspi_still_8c_aea3b638a727db146fcc8eab0c23607b5}{}\#define {\bfseries F\+R\+A\+M\+E\+\_\+\+N\+E\+X\+T\+\_\+\+K\+E\+Y\+P\+R\+E\+S\+S}~2\label{_raspi_still_8c_aea3b638a727db146fcc8eab0c23607b5}

\item 
\hypertarget{_raspi_still_8c_a3c963731a6a72354af0ccdb8d01cd45b}{}\#define {\bfseries F\+R\+A\+M\+E\+\_\+\+N\+E\+X\+T\+\_\+\+F\+O\+R\+E\+V\+E\+R}~3\label{_raspi_still_8c_a3c963731a6a72354af0ccdb8d01cd45b}

\item 
\hypertarget{_raspi_still_8c_ac4c01b071f6d0b0767234d8c54e9350d}{}\#define {\bfseries F\+R\+A\+M\+E\+\_\+\+N\+E\+X\+T\+\_\+\+G\+P\+I\+O}~4\label{_raspi_still_8c_ac4c01b071f6d0b0767234d8c54e9350d}

\item 
\hypertarget{_raspi_still_8c_a8b4cbc8571b66841b70d81ec2d08223b}{}\#define {\bfseries F\+R\+A\+M\+E\+\_\+\+N\+E\+X\+T\+\_\+\+S\+I\+G\+N\+A\+L}~5\label{_raspi_still_8c_a8b4cbc8571b66841b70d81ec2d08223b}

\item 
\hypertarget{_raspi_still_8c_ac7df6f8945a61257e4330ecfe5402ad6}{}\#define {\bfseries F\+R\+A\+M\+E\+\_\+\+N\+E\+X\+T\+\_\+\+I\+M\+M\+E\+D\+I\+A\+T\+E\+L\+Y}~6\label{_raspi_still_8c_ac7df6f8945a61257e4330ecfe5402ad6}

\item 
\hypertarget{_raspi_still_8c_aad1276a10255691d5d1b6ee899744210}{}\#define \hyperlink{_raspi_still_8c_aad1276a10255691d5d1b6ee899744210}{Command\+Help}~0\label{_raspi_still_8c_aad1276a10255691d5d1b6ee899744210}

\begin{DoxyCompactList}\small\item\em Comamnd I\+D\textquotesingle{}s and Structure defining our command line options. \end{DoxyCompactList}\item 
\hypertarget{_raspi_still_8c_a23426ba6b576d1b04df947f94bb797e8}{}\#define {\bfseries Command\+Width}~1\label{_raspi_still_8c_a23426ba6b576d1b04df947f94bb797e8}

\item 
\hypertarget{_raspi_still_8c_ad5d81a9785e84731ec2d3d9301154445}{}\#define {\bfseries Command\+Height}~2\label{_raspi_still_8c_ad5d81a9785e84731ec2d3d9301154445}

\item 
\hypertarget{_raspi_still_8c_a145bad17f84f433ea590a74412c49a5c}{}\#define {\bfseries Command\+Quality}~3\label{_raspi_still_8c_a145bad17f84f433ea590a74412c49a5c}

\item 
\hypertarget{_raspi_still_8c_a9450d7c03ae1bfa2f29bb12590632882}{}\#define {\bfseries Command\+Raw}~4\label{_raspi_still_8c_a9450d7c03ae1bfa2f29bb12590632882}

\item 
\hypertarget{_raspi_still_8c_acb7191506c0e3244de2ef6122b685e29}{}\#define {\bfseries Command\+Output}~5\label{_raspi_still_8c_acb7191506c0e3244de2ef6122b685e29}

\item 
\hypertarget{_raspi_still_8c_a38a193491d99a525fc5553be50d32aed}{}\#define {\bfseries Command\+Verbose}~6\label{_raspi_still_8c_a38a193491d99a525fc5553be50d32aed}

\item 
\hypertarget{_raspi_still_8c_acd7db803d94a3b35ace48c387ff39280}{}\#define {\bfseries Command\+Timeout}~7\label{_raspi_still_8c_acd7db803d94a3b35ace48c387ff39280}

\item 
\hypertarget{_raspi_still_8c_a4e88567a1bfcba504fb0307a7a5a4ee1}{}\#define {\bfseries Command\+Thumbnail}~8\label{_raspi_still_8c_a4e88567a1bfcba504fb0307a7a5a4ee1}

\item 
\hypertarget{_raspi_still_8c_af7e87beca7cd252571e5a60922259264}{}\#define {\bfseries Command\+Demo\+Mode}~9\label{_raspi_still_8c_af7e87beca7cd252571e5a60922259264}

\item 
\hypertarget{_raspi_still_8c_a9869a2382cbbbf45b14056348a37f53c}{}\#define {\bfseries Command\+Encoding}~10\label{_raspi_still_8c_a9869a2382cbbbf45b14056348a37f53c}

\item 
\hypertarget{_raspi_still_8c_aa67ce44e9686a9cb4b6b35f487e88c63}{}\#define {\bfseries Command\+Exif\+Tag}~11\label{_raspi_still_8c_aa67ce44e9686a9cb4b6b35f487e88c63}

\item 
\hypertarget{_raspi_still_8c_a4c1f442f4f08caacb7fa9f8312767684}{}\#define {\bfseries Command\+Timelapse}~12\label{_raspi_still_8c_a4c1f442f4f08caacb7fa9f8312767684}

\item 
\hypertarget{_raspi_still_8c_a4aac1d94951cea17578a09d859b5a592}{}\#define {\bfseries Command\+Full\+Res\+Preview}~13\label{_raspi_still_8c_a4aac1d94951cea17578a09d859b5a592}

\item 
\hypertarget{_raspi_still_8c_a25d9ede4380b278af5a9543813d14384}{}\#define {\bfseries Command\+Link}~14\label{_raspi_still_8c_a25d9ede4380b278af5a9543813d14384}

\item 
\hypertarget{_raspi_still_8c_abf1325fdb7fa052c2df5fcbf227165c8}{}\#define {\bfseries Command\+Keypress}~15\label{_raspi_still_8c_abf1325fdb7fa052c2df5fcbf227165c8}

\item 
\hypertarget{_raspi_still_8c_af4b07fae0f52e4b323d5623587b9020a}{}\#define {\bfseries Command\+Signal}~16\label{_raspi_still_8c_af4b07fae0f52e4b323d5623587b9020a}

\item 
\hypertarget{_raspi_still_8c_a453f9918613c7826bbda394c0b2cee6d}{}\#define {\bfseries Command\+G\+L}~17\label{_raspi_still_8c_a453f9918613c7826bbda394c0b2cee6d}

\item 
\hypertarget{_raspi_still_8c_a58f46b81d6214ea1ef1e9cddbd03b217}{}\#define {\bfseries Command\+G\+L\+Capture}~18\label{_raspi_still_8c_a58f46b81d6214ea1ef1e9cddbd03b217}

\item 
\hypertarget{_raspi_still_8c_aeb41897c3ac5e5450ee4a70e8b7d6217}{}\#define {\bfseries Command\+Settings}~19\label{_raspi_still_8c_aeb41897c3ac5e5450ee4a70e8b7d6217}

\item 
\hypertarget{_raspi_still_8c_a1ecb703a41dbfec83baf7dca9b5611f7}{}\#define {\bfseries Command\+Cam\+Select}~20\label{_raspi_still_8c_a1ecb703a41dbfec83baf7dca9b5611f7}

\item 
\hypertarget{_raspi_still_8c_a49da5dda6a076e5a2eb7d14543608a44}{}\#define {\bfseries Command\+Burst\+Mode}~21\label{_raspi_still_8c_a49da5dda6a076e5a2eb7d14543608a44}

\item 
\hypertarget{_raspi_still_8c_ac12c379225ea75dad46e82cf4bd1e818}{}\#define {\bfseries Command\+Sensor\+Mode}~22\label{_raspi_still_8c_ac12c379225ea75dad46e82cf4bd1e818}

\item 
\hypertarget{_raspi_still_8c_a0604c00a567753fff04b90322c7e8dcc}{}\#define {\bfseries Command\+Date\+Time}~23\label{_raspi_still_8c_a0604c00a567753fff04b90322c7e8dcc}

\item 
\hypertarget{_raspi_still_8c_a43a5367d16a6ee5038d9f6a9098ca5c3}{}\#define {\bfseries Command\+Time\+Stamp}~24\label{_raspi_still_8c_a43a5367d16a6ee5038d9f6a9098ca5c3}

\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{_raspi_still_8c_ad6cc73ee106e56252e3e10278aa463b7}{mmal\+\_\+status\+\_\+to\+\_\+int} (M\+M\+A\+L\+\_\+\+S\+T\+A\+T\+U\+S\+\_\+\+T status)
\item 
M\+M\+A\+L\+\_\+\+S\+T\+A\+T\+U\+S\+\_\+\+T \hyperlink{_raspi_still_8c_a04f044c445ee46aab2afe72c6d6eb5c3}{create\+\_\+filenames} (char $\ast$$\ast$final\+Name, char $\ast$$\ast$temp\+Name, char $\ast$pattern, int frame)
\item 
int \hyperlink{_raspi_still_8c_a217dbf8b442f20279ea00b898af96f52}{main} (int argc, const char $\ast$$\ast$argv)
\end{DoxyCompactItemize}


\subsection{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.

\begin{DoxyDate}{Date}
31 Jan 2013 \+: James Hughes
\end{DoxyDate}
Description

3 components are created; camera, preview and J\+P\+G 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\textquotesingle{}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 Raspi\+Cam\+Control code to handle the specific camera settings. 

\subsection{Function Documentation}
\hypertarget{_raspi_still_8c_a04f044c445ee46aab2afe72c6d6eb5c3}{}\index{Raspi\+Still.\+c@{Raspi\+Still.\+c}!create\+\_\+filenames@{create\+\_\+filenames}}
\index{create\+\_\+filenames@{create\+\_\+filenames}!Raspi\+Still.\+c@{Raspi\+Still.\+c}}
\subsubsection[{create\+\_\+filenames}]{\setlength{\rightskip}{0pt plus 5cm}M\+M\+A\+L\+\_\+\+S\+T\+A\+T\+U\+S\+\_\+\+T create\+\_\+filenames (
\begin{DoxyParamCaption}
\item[{char $\ast$$\ast$}]{final\+Name, }
\item[{char $\ast$$\ast$}]{temp\+Name, }
\item[{char $\ast$}]{pattern, }
\item[{int}]{frame}
\end{DoxyParamCaption}
)}\label{_raspi_still_8c_a04f044c445ee46aab2afe72c6d6eb5c3}
Allocates and generates a filename based on the user-\/supplied pattern and the frame number. On successful return, final\+Name and temp\+Name point to malloc()ed strings which must be freed externally. (On failure, returns nulls that don\textquotesingle{}t need free()ing.)


\begin{DoxyParams}{Parameters}
{\em final\+Name} & pointer receives an \\
\hline
{\em pattern} & sprintf pattern with d to be replaced by frame \\
\hline
{\em frame} & for timelapse, the frame number \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Returns a M\+M\+A\+L\+\_\+\+S\+T\+A\+T\+U\+S\+\_\+\+T giving result of operation 
\end{DoxyReturn}
\hypertarget{_raspi_still_8c_a217dbf8b442f20279ea00b898af96f52}{}\index{Raspi\+Still.\+c@{Raspi\+Still.\+c}!main@{main}}
\index{main@{main}!Raspi\+Still.\+c@{Raspi\+Still.\+c}}
\subsubsection[{main}]{\setlength{\rightskip}{0pt plus 5cm}int main (
\begin{DoxyParamCaption}
\item[{int}]{argc, }
\item[{const char $\ast$$\ast$}]{argv}
\end{DoxyParamCaption}
)}\label{_raspi_still_8c_a217dbf8b442f20279ea00b898af96f52}
main \hypertarget{_raspi_still_8c_ad6cc73ee106e56252e3e10278aa463b7}{}\index{Raspi\+Still.\+c@{Raspi\+Still.\+c}!mmal\+\_\+status\+\_\+to\+\_\+int@{mmal\+\_\+status\+\_\+to\+\_\+int}}
\index{mmal\+\_\+status\+\_\+to\+\_\+int@{mmal\+\_\+status\+\_\+to\+\_\+int}!Raspi\+Still.\+c@{Raspi\+Still.\+c}}
\subsubsection[{mmal\+\_\+status\+\_\+to\+\_\+int}]{\setlength{\rightskip}{0pt plus 5cm}int mmal\+\_\+status\+\_\+to\+\_\+int (
\begin{DoxyParamCaption}
\item[{M\+M\+A\+L\+\_\+\+S\+T\+A\+T\+U\+S\+\_\+\+T}]{status}
\end{DoxyParamCaption}
)}\label{_raspi_still_8c_ad6cc73ee106e56252e3e10278aa463b7}
Convert a M\+M\+A\+L status return value to a simple boolean of success A\+Lso displays a fault if code is not success


\begin{DoxyParams}{Parameters}
{\em status} & The error code to convert \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if status is sucess, 1 otherwise 
\end{DoxyReturn}
