Convert image code
- camera_fb_t *pic = NULL;
- pic = esp_camera_fb_get();
- size_t output_length; // note *NOT* a pointer
- unsigned char *encoded= base64_encode((const unsigned char *)pic->buf, pic->len, &output_length);
- esp_camera_fb_return(pic);
- cJSON *root = NULL;
- cJSON *size = create_point(800,600);
- root = cJSON_CreateObject();
- cJSON_AddStringToObject(root, "img", (const char*)encoded);
- cJSON_AddItemToObject(root, "size", size);
- cJSON_AddStringToObject(root, "storeId", "upload_validation_store");
- cJSON_AddStringToObject(root, "clientId", "upload_validation_client");
- cJSON_AddStringToObject(root, "deviceId", "1234");
- cJSON_AddNumberToObject(root, "timestamp", 123456);
- if (print_preallocated(root) != 0) {
- cJSON_Delete(root);
- exit(EXIT_FAILURE);
- }
- cJSON_Delete(root);
{
"size": [800, 600],
"storeId": "upload_validation_store",
"clientId": "upload_validation_client",
"deviceId": "1234",
"timestamp": 123456
}
The img line simply disappears