There are a few things that can cause this issue. I would first try a hard reset...holding the power and home button for 10 seconds or so. If that doesnt work, try to Go to "Settings" > "General" > "Reset" > "Reset All Settings". This won't delete any files or apps on your iPhone but erase your preferred settings on the apps. After the resetting, open the camera app and see if it works okay now.
If not: Go to "Settings" > "General" > "Reset" and choose "Erase All Content and Settings". This will delete all files and third-party apps on your iPhone so it should be the last resort. To not lose any data, back up your iPhone before factory reset (If important photos are lost after factory reset, recover iPhone/iPad photos with iCloud/iTunes backup).
If none of those work, check the Filters near the Flex connection on the logic board to see if they have continuity or have been damaged or knocked off the board.
Before doing the factory reset, I would definitely check the filters first but never hurts to have a full backup of your phone either way.