Get custom category image from menu

Not sure why your object is returning the non-object notice, but you can set the output of get_term_by to OBJECT, ARRAY_A, or ARRAY_N – You’ll want to use ARRAY_A and then access the term ID via $term['term_id'].