Any answer depends on your jurisdiction; in some places it may be okay to record generalized visual footage as long as it’s not also recording audio, while in some jurisdictions it may be viewed as illegal surveillance. To be certain, seek legal advice from an attorney or ask your local municipality for guidance. It might be in your favor if you can demonstrate that the security camera is only picking up some sideways views as a side effect of primarily focusing on covering your own property and that there is no intention to surveil your neighbors. As a matter of courtesy, even if it's confirmed your camera's placement is legal, talk to your neighbor to explain that full coverage of your own property also means you happen to capture some of theirs but that you have no intention of disturbing their privacy. If possible, avoid such positioning altogether, both for legal certainty and good neighborliness.