As a common mental disorder, depression is placing an increasing burden on families and society. However, the current methods of depression detection have some limitations, and it is essential to find an objective and efficient method. With the development of automation and artificial intelligence, computer-aided diagnosis has attracted more and more attention. Therefore, exploring the use of deep learning (DL) to detect depression has valuable potential. In this paper, convolutional neural network (CNN) is applied to build a diagnostic model for depression based on electroencephalogram (EEG). EEG recordings are analyzed by three different CNN structures, namely EEGNet, DeepConvNet and ShallowConvNet, to dichotomize depression patients and healthy controls. EEG data were collected in the resting state from three electrodes (Fp1, Fz, Fp2) among 80 subjects (40 depressive patients and 40 normal subjects). After the preprocessing step, the DL structures are employed to classify the data, and their recognition performance is evaluated by comparing the classification results. The classification performance shows that depression was effectively detected using EEGNet with 93.74% accuracy, 94.85% sensitivity and 92.61% specificity. In the process of optimizing the parameters of EEGNet structure, the highest accuracy can reach 94.27%. Compared with traditional diagnostic methods, EEGNet is highly worthy for the future depression detection and valuable in terms of accuracy and speed.