Obstructive sleep apnea (OSA) is a long-term sleep disorder that causes temporary disruption in breathing while sleeping. Polysomnography (PSG) is the technique for monitoring different signals during the patient's sleep cycle, including electroencephalogram (EEG), electromyography (EMG), electrocardiogram (ECG), and oxygen saturation (SpO2). Due to the high cost and inconvenience of polysomnography, the usefulness of ECG signals in detecting OSA is explored in this work, which proposes a two-dimensional convolutional neural network (2D-CNN) model for detecting OSA using ECG signals.A publicly available apnea ECG database from PhysioNet is used for experimentation. Further, a constant Q-transform (CQT) is applied for segmentation, filtering, and conversion of ECG beats into images. The proposed CNN model demonstrates an average accuracy, sensitivity and specificity of 91.34%, 90.68% and 90.70%, respectively. The findings obtained using the proposed approach are comparable to those of many other existing methods for automatic detection of OSA.