create a Calibration Board
You should position the board at roughly the same distance from the camera as the distance between the camera and your objects of interest. The board should be big enough to cover a good portion of the field of view at that distance.  

Another point: ideally, your board should have an even number of squares along one side, and an odd number of squares along the other.  Then the orientation of the board can be detected unambiguously.

Finally, since you have a "matlab" tag on your question, please check out the Camera Calibrator app, which is a part of the latest release of the Computer Vision System Toolbox for MATLAB.