is it possible to build an app that would "hack" camera so that it uses photos from album instead of picture from lens when any other other app is using the camera?

To make it more clear, here's my use case: I'm using third party app which uses camera for image recognition. However, I want it to recognize photos I have received by e-mail and stored to album, not only pictures I can make with camera.