Simply, you need to undistort your images first to correct the fish-eye distortion. Then, align your image plane to be coplanar with the table.
Both of the mentioned operations are geometrical transforms, and you need to know the transform's parameters. To calculate these parameters, you need a set of points with known actual coordinates and their projected coordinates onto the image. Personally, I find printing a checkerboard pattern and using the corner's coordinates to be the simplest method (There are image processing libraries that can automatically find the corner coordinates in the image).
Pose the checkerboard in front of camera with different orientations and take a few pictures. Using checkersboard's corners coordinates, you can determine the distortion parameters and use these distortion parameters to undistort images. Next place the printed checkerboard on the table and take another picture. Undistort this image, then find corners coordinates from undistorted image and use them to find a projective transform prameters, where this transform aligns the image plane with the table. Finally warp the undistorted image using the obtained projective transform.
Finally, you can combine these two geometric transformations into a single transform to reduce computational cost. By doing this you would apply single transform to the images instead of two cascaded transform.