Non-invasive brain-computer interfaces can be implemented through different paradigms, the most used one being motor imagery and evoked potentials, although recently there has been an interest in paradigms based on perception and visual imagery. Following this approach, this work demonstrates the classification of visual imagery, visual perception and also the possibility of knowledge transfer between these two domains from EEG signals using convolutional neural networks. Also, we propose an adequate framework for such classification, which uses convolutional neural networks and the black hole heuristic algorithm for the search for optimal neural network structures.