The weakly electric fish Gnathonemus petersii uses active electrolocation for non-visual orientation and object detection. Fish emit brief electric signals, which build up an electric field around their body. Nearby objects project electric images onto the fish's skin, which are perceived by epidermal electroreceptors, enabling the animal to discriminate between objects and to detect their electric properties. To test up to what distance object recognition is possible and whether complex backgrounds influence the discrimination performance, animals were trained to detect various objects of different sizes and shapes in front of different stagnant or moving backgrounds. Our results show that G. petersii is able to distinguish between objects up to a distance of about 3cm even in complete darkness. Moving backgrounds improve the discrimination distance up to 4cm. Using electric fish as models, underwater robots can be given an electric sense, which will enable them to navigate in dark or turbid environments. Our bionic approach will allow the robots to detect and analyse objects and recognize different object properties such as material composition, size and shape. Object recognition based on active electrolocation will still be possible in opaque surroundings where visual orientation is impossible.