The presence of foreign materials in a batch of cocoa beans affect its profitability, marketability and overall quality grade of the product. Therefore, the identification of these materials and their subsequent removal is very important to ensure the high quality of the final product. This study aims to investigate the feasibility of using hyperspectral imaging technology for the detection and discrimination of four categories of foreign materials (wood, plastic, stone and plant organs) that are relevant to the cocoa processing industries. The spectral image data of 250 cocoa beans and foreign material was analyzed using principal component analysis and three classification models Support Vector Machine (SVM) Linear Discriminant Analyses (LDA) and K Nearest Neighbours (KNN). Optimal wavebands, which were obtained from the second spectra graph and the first three PCs, were fed into the classification models and the performance of classifiers was compared. The results showed that SVM could reach over 89.10% accuracy in classifying cocoa beans and foreign materials. The accuracy of the SVM classifier when using optimal features as input was 86.90% for the training set and 81.28% for the test set. An external test set of data was used to test the generalization of the model. The results showed that the classification of foreign materials could be more robust when the optimal feature was used as input data.