Try to restart your iphone (turn it off, wait a few moments, and the turn it back on).
Try to force restart your iPhone (Press and hold the power button and then press and hold the volume down button for almost 10-15 seconds, untill the Apple Logo appears.
If nothing helps, read this support guide:
Get help with the camera on your iPhone, iPad, or iPod touch - Apple Support
If the issue still persists, make an appointment at your nearest Apple Store and have your device inspected.
Regards
Giulio