Quality of X-ray image plays an important role in diagnostic results. The traditional method for taking x-ray image depends on the operator's judgments and requires high professional quality of the radiologist. The quality of X-ray image for chest region obtains the best results when the ribcage is full air. That corresponds the peak time of inhaling cycle. In this paper, we use a depth camera of Microsoft Kinect to record the patient's breath and find the time of the deepest inhaling to improve the quality of X-ray image. Our design utilizes image processing methods to record human breath fluctuation, to calculate the breath rate and to predict the peak time of inhaling for the next breath cycle to capture automatically X-ray image.