Detect non rectangular bounding box for objects
Let's label your corners like this:

1-------2
|       |
3-------4   

For your destination.  Let, $P_1, P_2, P_3, \text{ and } P_4 $ be vectors representing the corners in pixel coordinates.
For your source, Let $H$ and $W$ represent the height and width, and $(x,y)$ be a point in that rectangle you want to project.
You can calculate your coefficients like this:
$$
\begin{aligned}
C_1 &amp;= \left(1 - \frac{x}{W} \right)\left( 1 - \frac{y}{H} \right) \\
C_2 &amp;= \frac{x}{W} \left( 1 - \frac{y}{H} \right) \\
C_3 &amp;= \left(1 - \frac{x}{W} \right)\frac{y}{H} \\
C_4 &amp;= \frac{x}{W} \cdot \frac{y}{H}
\end{aligned}
$$
Note: $C_1 + C_2 + C_3 + C_4 = 1 $
Then the projection on the screen is at:
$$ P = C_1 \cdot P_1 + C_2 \cdot P_2 + C_3 \cdot P_3 + C_4 \cdot P_4 $$
This is a first order approximation that should be adequate for your needs.  Especially if the TV image is a relatively small portion of the screen.
To locate the corners, a rough approach is to scan horizontally looking for black streaks.  Match them row by row.  The endpoints will define your TV edges.  Use linear regression to fit a line.  Next scan vertically in the same manner and do the same.  Calculate the intersections as your corners.  They need not be integer, and will be more accurate if you leave them fractional.
This is the easy way.  Depending upon what you are projecting will likely work fine.  The more proper way is to find the inverse mapping, then for every pixel on the screen, find the location in your source rectangle and do a weighted average there using the same splitting formula there to find the weights of the corners.