Closed attiamohammed closed 6 months ago
Hi,
Yes, it is possible. The CHW setting here describes how to utilize CNN memory for the first layer. The camera works with the same setting for both MAX78000 and MAX78002. The difference will be the load_input() function. For getting the image from the camera and loading it to the CNN with CHW format, you may find an example code snippet below.
#define HEIGHT_DET 224
#define WIDTH_DET 168
#define BYTE_PER_PIXEL 2
uint32_t input_0[HEIGHT_DET*WIDTH_DET/4];
uint32_t input_1[HEIGHT_DET*WIDTH_DET/4];
uint32_t input_2[HEIGHT_DET*WIDTH_DET/4];
uint32_t imgLen;
uint32_t w, h;
uint8_t* raw;
uint8_t *in0;
uint8_t *in1;
uint8_t *in2;
camera_get_image(&raw, &imgLen, &w, &h);
uint8_t* data = raw;
in0 = (uint8_t *)input_0;
in1 = (uint8_t *)input_1;
in2 = (uint8_t *)input_2;
// Prepare input data
for (int i = 0; i < HEIGHT_DET ; i++) {
data = raw;
data += i * BYTE_PER_PIXEL;
for (int j = 0; j < WIDTH_DET; j++) {
uint8_t ur, ug, ub;
int8_t r, g, b;
ub = (uint8_t)(data[j * BYTE_PER_PIXEL * HEIGHT_DET + 1] << 3);
ug = (uint8_t)((data[j * BYTE_PER_PIXEL * HEIGHT_DET] << 5) |
((data[j * BYTE_PER_PIXEL * HEIGHT_DET + 1] & 0xE0) >> 3));
ur = (uint8_t)(data[j * BYTE_PER_PIXEL * HEIGHT_DET] & 0xF8);
// convert to sign values
b = ub - 128;
g = ug - 128;
r = ur - 128;
*in0++ = r;
*in1++ = g;
*in2++ = b;
}
}
// Load data into CNN memory
memcpy32((uint32_t *) 0x51800000, input_0, 9408);
memcpy32((uint32_t *) 0x52800000, input_1, 9408);
memcpy32((uint32_t *) 0x53800000, input_2, 9408);
Thanks for your prompt reply. I found the issue for the HWC was not working for the OV5640. The included generic reading function in the examples is not working "camera_get_image" . But the modified version in the pascal_voc with FPN is working fine. I was able to use the OV5640 camera. "mipi_camera_capture()" is working despite the Documentation has OV5640 as supported by "camera_get_image". I am not sure why.
The OV5640 camera sensor supports two interfaces MIPI and DVP. The camera board supplied with MAX78002 EVKIT uses MIPI interface. You need to use MIPI version of the driver which includes "mipi_camera_capture()".
Hi, there. I have a Mac78002 EVKit. I want to use the model with the camera as in the MAX78000. When I change to HWC i get this error on the debug "the Data mismatch (338/623) at address 0x51800544: Expected 0xbb80f37f, read 0xbc80f37f."
I modified the YAML as follows: processors: from 0x0000000100010001 to 0x0000000000000007 and set streaming to True.
Is it possible to use the camera in CHW format?
TIA