It is not illegal so long as you don't violate their right to privacy. A surveillance camera used to monitor your own property is fine; don't go peeking in windows.
In most European countries it is. The US has no far reaching privacy laws, but some individual states do. Consult a lawyer in your area to avoid liability.