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ibCwzg1ItAHUA2ra/az+1tiKfm8K7\n"\
"XGvocJFxbLtRhIU0vaQ9MEjX+6sAAAGJKOVtVwAABAMARjBEAiBUbWpp6uCjWPkX\n"\
"1a3kdzajezONw5Uwdn7l+xypjE6bdwIgG2GK8pH+5UqZTTKxNyqCRoiJDX7rAXzx\n"\
"O22aIRkkBcAwDQYJKoZIhvcNAQELBQADggEBABlaZ1BDsax6k6hoGHKLQH6mdd6s\n"\
"IfzJQRYgS/OMC7lHRa74XXn2QzUmAZjwuYY+KQHx37Byta540t9htnhnisl3mt7g\n"\
"5EEvnB7lO3yXP0IvreNJf50rAoiQaSUDARS5tcsPWT0tlz0C1VGQaQyBECLaxlHv\n"\
"SAzST95h8mqHFaVtcY43AqKFDx4ZdaOALmoaogKML+y9PYEDP4rAoOa0DghXywAc\n"\
"ircbjzhxmo3AcQw/vNS+Vp33GMGqvuTfGobiYm8jhjBUeC1HH7StBSlzJJgUoBnA\n"\
"Av2QkE5iXOhNMYnD6Iuec1k7mJHKR6UFW8Uej4U5Ds61JgqATp8IShFJE2M=\n"\
"-----END CERTIFICATE-----\n";
esp_err_t _http_event_handler(esp_http_client_event_t* evt) {
if (evt->event_id == HTTP_EVENT_ON_DATA) {
httpResponseString.concat((char*)evt->data);
}
return ESP_OK;
}
String recognizeImage(String image) {
httpResponseString = "";
esp_http_client_handle_t http_client;
esp_http_client_config_t config_client = { 0 };
config_client.url = post_url;
config_client.event_handler = _http_event_handler;
config_client.auth_type = HTTP_AUTH_TYPE_NONE;
config_client.cert_pem =root_ca;
config_client.client_cert_len= strlen(root_ca)+1;
config_client.skip_cert_common_name_check = true;
config_client.buffer_size_tx =313000;
config_client.transport_type = HTTP_TRANSPORT_OVER_TCP;
config_client.method = HTTP_METHOD_POST;