From looking at your diagram, it appears to me that the transformation takes the unit vector $(i_x,i_y,i_z)$ and rotates it to point to $(f_x,f_y,f_z)$:
$$\begin{pmatrix}c_\Psi&s_\Psi&0\\-s_\Psi&c_\Psi&0\\0&0&1\end{pmatrix}
\begin{pmatrix}1&0&0\\0&c_\theta&-s_\theta\\0&s_\theta&c_\theta\end{pmatrix}
\begin{pmatrix}c_\phi&-s_\phi&0\\s_\phi&c_\phi&0\\0&0&1\end{pmatrix}
\begin{pmatrix}i_x\\i_y\\i_z\end{pmatrix} =
\begin{pmatrix}f_x\\f_y\\f_z\end{pmatrix}
$$
where $c_\phi = \cos(\phi), s_\phi = \sin(\phi)$, etc.
It isn't hard to solve for $\phi,\theta$ and $\Psi$ if you assume that your camera begins by pointing in a convenient direction such as $(i_x,i_y,i_z) = (0,0,1)$.