what version of software are you on? how close do you mean? like 1-2ft away or like... 2,3inches away?
is it happening on any camera using apps or just the camera app?
if it's happening everywhere, then you probably just have a hardware issue that should be replaced by UBreakIFix. You might have to wait a bit since the pandemic supply shortage and what not (maybe). But it's LIKELY covered under warranty, good luck!!!
Or another option you have is to submit an error report to Samsung Members app after reproducing the issue. This lets the app collect logs regarding the issue and lets the techs see what went wrong with the phone at the time of issue