OV5642 SPI Image read and save in Python returns gray image

  1. Where did you get the camera module(s)?
    Core Electronics

  2. Model number of the product(s)?
    Arducam 5MP Plus OV5642 Mini Module Camera

  3. What hardware/platform were you working on?
    Raspberry Pi CM4 Ubuntu Server 22.04

  4. Instructions you have followed. (link/manual/etc.)
    PICO_SPI_CAM/Python at master · ArduCAM/PICO_SPI_CAM · GitHub
    I have adapted this to use spidev and smbus2.

  5. Problems you were having?
    I am receiving a gray image with lines of gray circles (buffer returns almost all values of 86. (see image below)

  6. The dmesg log from your hardware?

  7. Troubleshooting attempts you’ve made?
    The camera is detected on i2c and the spi interface returns the testing register.
    I have tried to change to RAW and I receive the same response. I am using the following code to save the image:

raw_data = np.array(buffer[:-8], dtype=np.uint8)
img = raw_data.reshape((self.img_height, self.img_width))
if img is None:
    print("Failed to decode image from buffer.")
else:
    # Save the image to disk.
    cv2.imwrite(filename, img)
    print(f"Image saved as {filename}")
  1. What help do you need?
    I would like to know the correct registers to initialize the camera. I am currently using Camera_Init() from Arducam.py but I think there may be more or it may have changed. How do I find the correct and most up to date registers?
    I also am not sure if it is the registers that causes so if you know of another reason why this is happening please share some other solutions.
    captured_image