Hi, I’m using an Arducam Mega 3MP camera with an MSP430FR5994 and Arducam Mega GUI v2.0.4 (the ArducamMegaSetup_Windows_x64.exe package). I had an initialization problem earlier but that’s sorted now — photo capture and settings adjustments are working. The issue is that exporting photos is limited to the Mega GUI. I’m also receiving the image data over UART, so my question is: can the UART-received data be converted directly into a photo file? Is there a standard way to do that?
Good to hear the init issue is behind you. For the UART side, make sure your code has arducamUartWrite(0x01); inside the ReadBuffer function — that call is what tells the camera to send the image data out over UART. Once that’s in place, you should be getting a raw stream you can capture and save. Are you seeing a continuous stream of bytes after adding that call?
Thanks, yes — after adding that line I’m getting data over UART now. While I try to decode it, which YUV format does the Arducam Mega 3MP actually output? Is it planar or packed, and is it YUV4:2:2 or YUV4:2:0? I don’t want to parse the buffer wrong.
Also, the API reference seems to be down. I’m getting an error opening: https://www.arducam.com/docs/arducam-mega/arducam-mega-getting-started/packs/C%2B%2B_ApiDoc.html — could that be fixed?
On the UART-to-photo question and the API doc: we’re actively working on fixing the docs. In the meantime, I’ve sent you an enclosed file through private message — please check your messages and download it. You can also refer to the API document at that same link once it’s back up. And to recap the UART part: the arducamUartWrite(0x01); call inside ReadBuffer is what pushes the image data over UART.
For the YUV question: the Mega 3MP uses YUV4:2:2 in packed form. I’ve also included a small test demo with functions to convert the received data into an image — here’s the relevant code:
Convert YUV format to an image
def YUVToMat(self,data,Width,Height, color_mode):
codeMap = {
0:cv2.COLOR_YUV2BGR_YUYV,
1:cv2.COLOR_YUV2BGR_YVYU,
2:cv2.COLOR_YUV2BGR_UYVY,
3:cv2.COLOR_YUV2BGR_Y422,
4:cv2.COLOR_YUV2BGR_YUY2,
}
image = np.frombuffer(data, np.uint8).reshape(Height, Width, 2)
return cv2.cvtColor(image,codeMap[color_mode])
Convert RGB565 format to an image
def RGB565ToMat(self,data,Width,Height):
arr = np.frombuffer(data,dtype=‘<u2’).astype(np.uint32)
arr = ((arr & 0xFF00) >> 8) + ((arr & 0x00FF) << 8)
arr = 0xFF000000 + ((arr & 0xF800) << 8) + ((arr & 0x07E0) << 5) + ((arr & 0x001F) << 3)
arr.dtype = np.uint8
image = arr.reshape(Height,Width,4)
return image
So the workaround right now is: capture the UART bytes, then feed them into YUVToMat with the right color mode (the demo supports YUYV, YVYU, UYVY, Y422, and YUY2 via cv2.cvtColor). Try that and let me know how the output looks.