You can try a couple of things.
Open the Camera app & go to settings & click on "reset" & test.
You can also go to Settings > Apps & Search for the Camera & Scroll down to Storage & Clear both Cache and Data for the camera & test.
Only other thing that you can try to get some information, go to Samsung Members app Click on "Get Help" & Diagnostics & Check the camera & run the test for the camera.
You could also backup your phone with smart switch & factory reset & see if that fixes the problem?
If it's a hardware issue, then visit a Samsung Service center.
It can be many things and must be specific about the problem and as many sent advises if this is not solving your issue then you need to get help at near Samsung Center's for solving the issue with your issue.