High-contrast medium resolution spectroscopy has been used to detect molecules such as water and carbon monoxide in the atmospheres of gas giant exoplanets . In this work , we show how it can be used to derive radial velocity ( RV ) measurements of directly imaged exoplanets . Improving upon the traditional cross-correlation technique , we develop a new likelihood based on joint forward modelling of the planetary signal and the starlight background ( i.e. , speckles ) . After marginalizing over the starlight model , we infer the barycentric RV of HR 8799 b and c in 2010 yielding -9.2 \pm 0.5 \mathrm { km / s } and -11.6 \pm 0.5 \mathrm { km / s } respectively . These RV measurements help to constrain the 3D orientation of the orbit of the planet by resolving the degeneracy in the longitude of ascending node . Assuming coplanar orbits for HR 8799 b and c , but not including d and e , we estimate \Omega = { 89 ^ { \circ } } ^ { +27 } _ { -17 } and i = { 20.8 ^ { \circ } } ^ { +4.5 } _ { -3.7 } .