Reading a JPEG off the FIFO buffer

1.Which seller did you purchase the product(s) from?
Amazon

2.The Model number of the product(s) you have purchased?
Arducam OV5642 5MP Plus

3.Which Platform are you using the product(s) on?
Arduino Nano 33 BLE Sense

4.Which instruction are you following?
I’m working off one of the built-in examples from the GitHub

5.Has your product ever worked properly?
The camera has output what seemed to be proper looking bytes from time to time, but I would need this to work much more consistently

6.What problems are you experiencing?
Hello! I’m trying using the ArduCAM 0V5642 5MP Plus to help take pictures for a project I am working on. My goal for it right now is to be able to take a picture once it receives the proper Serial input and then output the hex bytes of the JPEG image to Serial so that my a python script on my computer can read it using PySerial. The problem I am facing is with printing the hex bytes to the Serial Monitor. I am able to print all the bytes in the FIFO to the Serial monitor, however, they don’t seem to represent a valid JPEG image file. I am figuring this for the fact that JPEG images are supposed to start with the bytes FF D8 and then end with the bytes FF D9. Here’s a PasteBin with my current code:

https://pastebin.com/nzViK1c7

The current rationale of my the read_fifo_burst is that I have the Arduino read off the FIFO buffer and save the bytes in an array. Once the array hits a certain size/finds the end of the image it spits out the contents of the array and begins filling up from the beginning again. This only happens once the FF D8 (image start) bytes are found and ends when FF D9 (image end) bytes are found. However, if I simply print out all the bytes found in the FIFO buffer I find that most of the time FF D8 and FF D9 are nowhere to be found! This might correlate with the fact that the built-in host-application doesn’t work most of the time anyways with any of the example sketches. I’m eagerly awaiting any response or solution to this unusual problem! Thank you in advance for any help!

7.What attempts at troubleshooting have you already made?
See above!

8.How would you like us to help you?
Some guidance on how to reliably get the image data off the camera module and onto the Serial monitor would be nice!

As a little update, I simply went ahead and made a python script to read the data from the Serial port and write it to a .jpeg file. On examining the hex of the file (using a VSCode extension) the FFD8 and FFD9 bytes are present but the file is showing up as corrupted. Downloading a JPEG file from google of the same resolution shows that my file is around 1/4th size of the downloaded file and contains far fewer lines. One thing I did notice when I was tinkering around with my python script is that the JPEG header and footer was repeated twice, as if there were a JPEG file embedded in the JPEG file. I fixed this by simply choosing to throw away the first header the script finds if a second one is found and then choosing to use the first footer the script finds. I am attaching two more PasteBins, one with the current Arduino code and one with the current Python code. Once again, thank you for taking the time to look at this and am patiently awaiting your swift response. I would be more than happy to hop on a Zoom or Google Meet call to discuss this at any time of your convenience if that would be easier!

Arduino: https://pastebin.com/1pJ9mz6M
Python: https://pastebin.com/KGvXrCj7