Sending inference data from esp32 camera to arduino mega

did you try the simple serial test programs for transmitting data between the Mega and ESP32-CAM in post communication-between-esp32-cam-and-arduino-uno
get the basic communications test working before attempting any advanced processing

the Mega uses 5V logic the ESP32 3.3V logic you therefore require a potential divider on the Mega serial Tx to ESP-32-CAM Rx line (as shown in the diagram in the post) or a level shifter as suggested by @GolamMostafa