Corrupted output image imx219

  1. Where did you get the camera module(s)?
    Other - www.botland.com.pl
  2. Model number of the product(s)?
    Buy Raspberry Pi NoIR Camera HD v2 8MPx - Botland - Robotic Shop
    USB3.0 shield plus (B0317) UC-593 Rev C
  3. What hardware/platform were you working on?
    Linux x86
  4. Instructions you have followed. (link/manual/etc.)
    https://github.com/ArduCAM/ArduCAM_USB_Camera_Shield
  5. Problems you were having?

When using camera in following way:

  1. Initialize camera
  2. Start capture (run threads)
  3. Capture few frames
  4. Stop capture (stop threads and execute ArduCam_flush)
  5. Wait for until data is needed again, then go to step 2.

Sometimes first image after restarting capture(marked on picture as (2)) has corrupted data. See picture attached below

Corrupted image contains part of previous frame(marked as (1)). Using ArduCam_flush doesn’t really help to prevent that. Do you think images buffers are handled correctly after ArduCam_endCaptureImage?

Sometimes before that happen, ArduCam_captureImage returns USB_CAMERA_DATA_LEN_ERROR followed by multiple USB_CAMERA_FRAME_INDEX_ERROR.
Can you help me to understand reason those errors appear?
a) USB_CAMERA_DATA_LEN_ERROR (is that transfer error? what does it mean?)
b) USB_CAMERA_FRAME_INDEX_ERROR (it appears at leas once at each start, sometimes after USB_CAMERA_DATA_LEN_ERROR multiple times)

  1. The dmesg log from your hardware?
    None
  2. Troubleshooting attempts you’ve made?
    Power cycle, check camera buffers flushing methods and try to clean pending images manually.
  3. What help do you need?
    Solve a bug (imho in SDK or board FW) or find reasonable workaround

Hi @edul,

There are indeed some design vulnerabilities in the SDK,
My suggestion is not to stop the capture thread. The capture thread is actually the thread that obtains data from the USB. If it does not process the USB data in time, it will cause problems with the data on the device.

Hi @wong,

Thanks for answer, are you planning to address design vulnerabilities in the SDK in near future?

Going back to my 2nd question. Can you help me to understand reason those errors appear?
a) USB_CAMERA_DATA_LEN_ERROR (is that transfer error? what does it mean?)
b) USB_CAMERA_FRAME_INDEX_ERROR (it appears at leas once at each start, sometimes after USB_CAMERA_DATA_LEN_ERROR multiple times)

Unfortunately, there is no clear plan, in fact it needs to be refactored as a whole.

Yes, this is a transmission error.
The data may be lost due to the failure to process the data output by the device in time.

This error means that the image frames are not continuous, and each image frame has a frame number. If it is not continuous, it will prompt this error, but you can ignore it.

The current design exposes too many things to users, and it is not easy to handle these combinations correctly. You can refer to this simple wrap:

C++ Version:

Python Version:

Thanks for quick answer.

The current design exposes too many things to users, and it is not easy to handle these combinations correctly.

From my point of view more extensive documentation combined with some examples are usually enough to handle such SDK. On the other hand I understand it could be more user friendly.