From d968088f420d9856ebe457a63a18b05b6fc4778a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 20 May 2023 20:46:40 +0200 Subject: [PATCH 1/4] Update esp32_camera.rst --- components/esp32_camera.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/components/esp32_camera.rst b/components/esp32_camera.rst index 8361f0daf..ba738ad5d 100644 --- a/components/esp32_camera.rst +++ b/components/esp32_camera.rst @@ -173,6 +173,21 @@ Test Setting: Camera uses PWM timer #1. If you need PWM (via the ``ledc`` platform) you need to manually specify a channel there (with the ``channel: 2`` parameter) +Base64 encode/decode +-------------------- +There are a helper functions which can decode or encode raw image data to base64 string. So it can be sent over MQTT or other protocols. + +.. code-block:: yaml + # Example of how to encode data + esp32_camera: + ... + on_image: + then: + - lambda: |- + const char* image_data_char = reinterpret_cast(image.data); + std::string encodedData = base64_encode(&image_data_char[0], image.length); + id(mqtt_client).publish("cam/image", encodedData); + Configuration for Ai-Thinker Camera ----------------------------------- From 17ae77fa1ed9c7d10204a7c4708a040d716df14c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 20 May 2023 20:51:37 +0200 Subject: [PATCH 2/4] Update esp32_camera.rst --- components/esp32_camera.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/esp32_camera.rst b/components/esp32_camera.rst index ba738ad5d..40b1a1687 100644 --- a/components/esp32_camera.rst +++ b/components/esp32_camera.rst @@ -178,6 +178,7 @@ Base64 encode/decode There are a helper functions which can decode or encode raw image data to base64 string. So it can be sent over MQTT or other protocols. .. code-block:: yaml + # Example of how to encode data esp32_camera: ... @@ -187,6 +188,14 @@ There are a helper functions which can decode or encode raw image data to base64 const char* image_data_char = reinterpret_cast(image.data); std::string encodedData = base64_encode(&image_data_char[0], image.length); id(mqtt_client).publish("cam/image", encodedData); + + # Example of how to decode data + mqtt: + on_message: + topic: cam/image + then: + - lambda: |- + std::vector decodedData = base64_decode(x); Configuration for Ai-Thinker Camera ----------------------------------- From 576f771926f11602b637896de656133f9411a4ec Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 20 May 2023 20:53:55 +0200 Subject: [PATCH 3/4] Update esp32_camera.rst --- components/esp32_camera.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp32_camera.rst b/components/esp32_camera.rst index 40b1a1687..ee14e938d 100644 --- a/components/esp32_camera.rst +++ b/components/esp32_camera.rst @@ -178,7 +178,7 @@ Base64 encode/decode There are a helper functions which can decode or encode raw image data to base64 string. So it can be sent over MQTT or other protocols. .. code-block:: yaml - + # Example of how to encode data esp32_camera: ... From 76060774f01dff7154cbc839f11bd95bda2851e1 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 21 May 2023 17:59:48 +0200 Subject: [PATCH 4/4] Update components/esp32_camera.rst Co-authored-by: Stefan Rado --- components/esp32_camera.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp32_camera.rst b/components/esp32_camera.rst index ee14e938d..cfebeacec 100644 --- a/components/esp32_camera.rst +++ b/components/esp32_camera.rst @@ -175,7 +175,7 @@ Test Setting: Base64 encode/decode -------------------- -There are a helper functions which can decode or encode raw image data to base64 string. So it can be sent over MQTT or other protocols. +There are helper functions available which can encode or decode raw image data into Base64 strings and vice versa. This can be useful to sent images over MQTT or other protocols. .. code-block:: yaml