In contemporary academic settings, end-of-semester student feedback on a lecturer’s teaching abilities often fails to provide a comprehensive, real-time evaluation of their proficiency, and becomes less relevant with each new cohort of students. To address these limitations, an innovative feedback method has been proposed, utilizing image processing algorithms to dynamically assess the emotional states of students during lectures by analyzing their facial expressions. This real-time approach enables lecturers to promptly adapt and enhance their teaching techniques. Recognizing and engaging with emotionally positive students has been shown to foster better learning outcomes, as their enthusiasm actively stimulates cognitive engagement and information analysis. The purpose of this work is to identify emotions based on facial expressions using a deep learning model based on a convolutional neural network (CNN), where facial recognition is performed using the Viola–Jones algorithm on a group of students in a learning environment. The algorithm encompasses four key steps: image acquisition, preprocessing, emotion detection, and emotion recognition. The technological advancement of this research lies in the proposal to implement photonic hardware and create an optical neural network which offers unparalleled speed and efficiency in data processing. This approach demonstrates significant advancements over traditional electronic systems in handling computational tasks. An experimental validation was conducted in a classroom with 45 students, demonstrating that the level of understanding in the class as predicted was 43–62.94%, and the proposed CNN algorithm (facial expressions detection) achieved an impressive 83% accuracy in understanding students’ emotional states. The correlation between the CNN deep learning model and the students’ feedback was 91.7%. This novel approach opens avenues for the real-time assessment of students’ engagement levels and the effectiveness of the learning environment, providing valuable insights for ongoing improvements in teaching practices.