fix runtime exception, initialise cam and p universally

Signed-off-by: Liew Zhao Wei <zhaoweiliew@gmail.com>