How should I detect an object in a camera image?
Is this a good approach? Will I have a lot of trouble with different backgrounds?


A lot will depend on the nature of the backgrounds you have, and how well they encode/decode by themselves without the object in frame. My gut feeling is that your system will have poor performance compared to a properly trained classifier, as the autoencoder will naturally have to get good at constructing background elements in order to score well, so unless your object is very consistently always in a similar place with radically different appearance to the background then the autoencoder will get good reconstructions of background-only frames, and your anomaly detection would need to be set too sensitive. That would cause the detector to fail to spot the object when in frame.

There is a catch-all answer to "how well will my idea work" with ML projects. You should try it and see. Data science is essentially an empirical approach, and building practical models is an engineering discipline where testing is a core part of the process.

In order to test your model, you are going to need a lot of images of just background, including all the kinds of background that you expect the system to be used. Which begs the question, why not collect a range of suitable images without your target object, and use them as the second class?


  This doesn't solve the problem, because I don't know what else could not be an object. It would be impossible to train for 2 classes: object / not object.


Actually, it is easy. Just collect suitable images from locations where you expect your system to be used, without the object in frame. These are your "Not Object" class. A "Not Object" does not have to include some substitute foreground object. Although I recommend that you do have some images like this to prevent accidentally creating an "object is in the foreground" detector*. The primary goal should be to be collect data that matches how the model will be used once deployed. That will depend a lot on how much control and consistency you get over the production cameras where the trained detector will be put to use.

I would do this, then train a standard binary classifier.

If you are still interested in how well your auto-encoder idea could work, you then have plenty of test data to evaluate it.



*  This is one area where your auto-encoder idea might do better than a classifier - reconstructing unfamiliar foreground objects should be hard for it leading to high error.

It is too difficult to tell in advance whether this effect is strong enough to make your auto-encoder approach better than a classifier.