I have the template pattern (for example, rectangle), so I know it's size in mm. Also I have several frames with this pattern. So I know the intrinsic matrix $K$ of camera with which these frames were taken. And I want to find displacement and rotation of the template pattern relative to the camera in 3D space. The intrinsic matrix $K$ has this form.
where $\alpha_x$ and $\alpha_y$ represent the focal length of the camera in terms of pixel dimensions in the $x$ and $y$ direction respectively. $x_0$ is width of pixel dimensions, $y_0$ is height of pixel dimensions. So how can I find displacement and rotation of the template pattern relative to the camera in 3D space?