├── components ├── camera │ ├── component.mk │ ├── xclk.h │ ├── ov2640.h │ ├── ov7725.h │ ├── sccb.h │ ├── Kconfig │ ├── camera_common.h │ ├── include │ │ ├── bitmap.h │ │ ├── sensor.h │ │ └── camera.h │ ├── bitmap.c │ ├── twi.h │ ├── xclk.c │ ├── sccb.c │ ├── ov2640_regs.h │ ├── ov2640.c │ └── ov7725.c ├── image_util │ ├── component.mk │ └── include │ │ └── image_util.h ├── lcd │ ├── include │ │ ├── glcdfont.h │ │ ├── font7s.h │ │ ├── gfxfont.h │ │ ├── WProgram.h │ │ └── spi_lcd.h │ ├── Adafruit-GFX-Library │ │ ├── .gitignore │ │ ├── fontconvert │ │ │ ├── Makefile │ │ │ ├── makefonts.sh │ │ │ └── fontconvert_win.md │ │ ├── library.properties │ │ ├── gfxfont.h │ │ ├── license.txt │ │ ├── Adafruit_SPITFT.h │ │ ├── README.md │ │ ├── Adafruit_SPITFT_Macros.h │ │ ├── Fonts │ │ │ ├── Picopixel.h │ │ │ ├── Tiny3x3a2pt7b │ │ │ └── Org_01.h │ │ ├── Adafruit_GFX.h │ │ ├── glcdfont.c │ │ └── Adafruit_SPITFT.cpp │ ├── test │ │ ├── component.mk │ │ └── lcd_refresh.cpp │ ├── component.mk │ ├── adaptation.cpp │ └── README.md ├── lib │ ├── libdl_lib.a │ ├── libcoefficients.a │ ├── include │ │ ├── onet_model.h │ │ ├── pnet_model.h │ │ ├── rnet_model.h │ │ ├── dl_lib_coefgetter_if.h │ │ ├── dl_lib_matrix.h │ │ └── dl_lib_matrix3d.h │ └── component.mk └── esp_facenet │ ├── mtmn │ ├── component.mk │ ├── include │ │ └── mtmn.h │ └── mtmn.c │ └── face_detection │ ├── component.mk │ ├── include │ └── face_detection.h │ └── face_detection.c ├── .gitignore ├── examples └── single_chip │ └── camera_with_command_line │ ├── main │ ├── Kconfig.projbuild │ ├── component.mk │ ├── include │ │ ├── app_facenet.h │ │ └── app_camera.h │ ├── app_facenet.c │ ├── app_main.cpp │ └── app_camera.cpp │ ├── build │ └── http_server │ │ ├── libhttp_server.a │ │ ├── src │ │ ├── httpd_main.o │ │ ├── httpd_parse.o │ │ ├── httpd_sess.o │ │ ├── httpd_txrx.o │ │ ├── httpd_uri.o │ │ └── util │ │ │ └── ctrl_sock.o │ │ └── component_project_vars.mk │ ├── partitions.csv │ ├── Makefile │ ├── sdkconfig.defaults │ └── README.md ├── img ├── detected.png ├── m5camera.jpg ├── ov2640.jpg ├── overview.png ├── esp-wrover-kit.jpg └── esp_wrover_kit_with_ov2640.png ├── .gitmodules ├── LICENSE ├── .gitlab-ci.yml └── README.md /components/camera/component.mk: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /components/image_util/component.mk: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | 3 | sdkconfig 4 | sdkconfig.old 5 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/main/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /img/detected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/img/detected.png -------------------------------------------------------------------------------- /img/m5camera.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/img/m5camera.jpg -------------------------------------------------------------------------------- /img/ov2640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/img/ov2640.jpg -------------------------------------------------------------------------------- /img/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/img/overview.png -------------------------------------------------------------------------------- /components/lcd/include/glcdfont.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | extern const unsigned char font[]; 4 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/.gitignore: -------------------------------------------------------------------------------- 1 | default.vim 2 | fontconvert/fontconvert 3 | -------------------------------------------------------------------------------- /img/esp-wrover-kit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/img/esp-wrover-kit.jpg -------------------------------------------------------------------------------- /components/lib/libdl_lib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/components/lib/libdl_lib.a -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "esp-idf"] 2 | path = esp-idf 3 | url = https://github.com/espressif/esp-idf 4 | -------------------------------------------------------------------------------- /components/esp_facenet/mtmn/component.mk: -------------------------------------------------------------------------------- 1 | #Component makefile 2 | 3 | COMPONENT_ADD_INCLUDEDIRS := include 4 | -------------------------------------------------------------------------------- /components/lib/libcoefficients.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/components/lib/libcoefficients.a -------------------------------------------------------------------------------- /components/esp_facenet/face_detection/component.mk: -------------------------------------------------------------------------------- 1 | #Component makefile 2 | 3 | COMPONENT_ADD_INCLUDEDIRS := include 4 | -------------------------------------------------------------------------------- /img/esp_wrover_kit_with_ov2640.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/img/esp_wrover_kit_with_ov2640.png -------------------------------------------------------------------------------- /components/camera/xclk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "camera_common.h" 4 | 5 | esp_err_t camera_enable_out_clock(); 6 | 7 | void camera_disable_out_clock(); 8 | -------------------------------------------------------------------------------- /components/lcd/test/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Component Makefile 3 | # 4 | 5 | COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive 6 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/build/http_server/libhttp_server.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/examples/single_chip/camera_with_command_line/build/http_server/libhttp_server.a -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/build/http_server/src/httpd_main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/examples/single_chip/camera_with_command_line/build/http_server/src/httpd_main.o -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/build/http_server/src/httpd_parse.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/examples/single_chip/camera_with_command_line/build/http_server/src/httpd_parse.o -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/build/http_server/src/httpd_sess.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/examples/single_chip/camera_with_command_line/build/http_server/src/httpd_sess.o -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/build/http_server/src/httpd_txrx.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/examples/single_chip/camera_with_command_line/build/http_server/src/httpd_txrx.o -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/build/http_server/src/httpd_uri.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/examples/single_chip/camera_with_command_line/build/http_server/src/httpd_uri.o -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/build/http_server/src/util/ctrl_sock.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/esp-who/HEAD/examples/single_chip/camera_with_command_line/build/http_server/src/util/ctrl_sock.o -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/partitions.csv: -------------------------------------------------------------------------------- 1 | # Espressif ESP32 Partition Table 2 | # Name, Type, SubType, Offset, Size 3 | factory, app, factory, 0x010000, 2M 4 | nvs, data, nvs, 0x310000, 16K 5 | -------------------------------------------------------------------------------- /components/lib/include/onet_model.h: -------------------------------------------------------------------------------- 1 | //Generated by mkmodel 2 | #pragma once 3 | #include 4 | #include "dl_lib_coefgetter_if.h" 5 | #include "dl_lib.h" 6 | 7 | extern const model_coeff_getter_t get_coeff_onet_model; 8 | -------------------------------------------------------------------------------- /components/lib/include/pnet_model.h: -------------------------------------------------------------------------------- 1 | //Generated by mkmodel 2 | #pragma once 3 | #include 4 | #include "dl_lib_coefgetter_if.h" 5 | #include "dl_lib.h" 6 | 7 | extern const model_coeff_getter_t get_coeff_pnet_model; 8 | -------------------------------------------------------------------------------- /components/lib/include/rnet_model.h: -------------------------------------------------------------------------------- 1 | //Generated by mkmodel 2 | #pragma once 3 | #include 4 | #include "dl_lib_coefgetter_if.h" 5 | #include "dl_lib.h" 6 | 7 | extern const model_coeff_getter_t get_coeff_rnet_model; 8 | -------------------------------------------------------------------------------- /components/lib/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := include 2 | 3 | COMPONENT_SRCDIRS := . 4 | 5 | LIBS := coefficients dl_lib 6 | 7 | COMPONENT_ADD_LDFLAGS += -L$(COMPONENT_PATH)/ $(addprefix -l,$(LIBS)) 8 | 9 | ALL_LIB_FILES += $(patsubst %,$(COMPONENT_PATH)/lib%.a,$(LIBS)) 10 | -------------------------------------------------------------------------------- /components/lcd/include/font7s.h: -------------------------------------------------------------------------------- 1 | #ifndef _FONT_H_ 2 | #define _FONT_H_ 3 | 4 | #define NR_CHRS_F7S 96 5 | #define CHR_HGT_F7S 48 6 | #define DATA_SIZE_F7S 8 7 | #define FIRSTCHR_F7S 32 8 | 9 | extern const unsigned char widtbl_f7s[96]; 10 | extern const unsigned char *chrtbl_f7s[96]; 11 | 12 | #endif -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/fontconvert/Makefile: -------------------------------------------------------------------------------- 1 | all: fontconvert 2 | 3 | CC = gcc 4 | CFLAGS = -Wall -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I/usr/include 5 | LIBS = -lfreetype 6 | 7 | fontconvert: fontconvert.c 8 | $(CC) $(CFLAGS) $< $(LIBS) -o $@ 9 | strip $@ 10 | 11 | clean: 12 | rm -f fontconvert 13 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := facenet_single_command_line 7 | EXTRA_COMPONENT_DIRS += $(PROJECT_PATH)/../../../components $(PROJECT_PATH)/../../../components/esp_facenet 8 | include $(IDF_PATH)/make/project.mk 9 | 10 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/build/http_server/component_project_vars.mk: -------------------------------------------------------------------------------- 1 | # Automatically generated build file. Do not edit. 2 | COMPONENT_INCLUDES += $(IDF_PATH)/components/http_server/include 3 | COMPONENT_LDFLAGS += -L$(BUILD_DIR_BASE)/http_server -lhttp_server 4 | COMPONENT_LINKER_DEPS += 5 | COMPONENT_SUBMODULES += 6 | COMPONENT_LIBRARIES += http_server 7 | component-http_server-build: 8 | -------------------------------------------------------------------------------- /components/camera/ov2640.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * OV2640 driver. 7 | * 8 | */ 9 | #ifndef __OV2640_H__ 10 | #define __OV2640_H__ 11 | #include "sensor.h" 12 | int ov2640_init(sensor_t *sensor); 13 | #endif // __OV2640_H__ 14 | -------------------------------------------------------------------------------- /components/camera/ov7725.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * OV7725 driver. 7 | * 8 | */ 9 | #ifndef __OV7725_H__ 10 | #define __OV7725_H__ 11 | #include "sensor.h" 12 | 13 | int ov7725_init(sensor_t *sensor); 14 | #endif // __OV7725_H__ 15 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit GFX Library 2 | version=1.2.3 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from. 6 | paragraph=Install this library in addition to the display library for your hardware. 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit-GFX-Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main Makefile. This is basically the same as a component makefile. 3 | # 4 | # This Makefile should, at the very least, just include $(SDK_PATH)/make/component.mk. By default, 5 | # this will take the sources in the src/ directory, compile them and link them into 6 | # lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable, 7 | # please read the SDK documents if you need to do this. 8 | # 9 | 10 | -------------------------------------------------------------------------------- /components/lcd/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # "main" pseudo-component makefile. 3 | # 4 | # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) 5 | CXXFLAGS += -D__AVR_ATtiny85__ 6 | 7 | # ifdef CONFIG_IOT_EINK_ENABLE 8 | COMPONENT_ADD_INCLUDEDIRS := include Adafruit-GFX-Library/Fonts Adafruit-GFX-Library 9 | COMPONENT_SRCDIRS := . Adafruit-GFX-Library 10 | 11 | # else 12 | # # Disable component 13 | # COMPONENT_ADD_INCLUDEDIRS := 14 | # COMPONENT_ADD_LDFLAGS := 15 | # COMPONENT_SRCDIRS := 16 | # endif -------------------------------------------------------------------------------- /components/camera/sccb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * SCCB (I2C like) driver. 7 | * 8 | */ 9 | #ifndef __SCCB_H__ 10 | #define __SCCB_H__ 11 | #include 12 | int SCCB_Init(int pin_sda, int pin_scl); 13 | uint8_t SCCB_Probe(); 14 | uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg); 15 | uint8_t SCCB_Write(uint8_t slv_addr, uint8_t reg, uint8_t data); 16 | #endif // __SCCB_H__ 17 | -------------------------------------------------------------------------------- /components/camera/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Camera configuration" 2 | 3 | config ENABLE_TEST_PATTERN 4 | bool "Enable test pattern on camera output" 5 | default n 6 | help 7 | Configure the camera module to output test pattern instead of live image. 8 | 9 | Use this option to troubleshoot image issues like noise, 10 | distortion, not legible and missing live image. 11 | Instead, module will generate regular vertical bars 12 | in shades from dark to white. 13 | 14 | config OV2640_SUPPORT 15 | bool "OV2640 Support" 16 | default y 17 | help 18 | Enable this option if you want to use the OV2640. 19 | Disable this option to safe memory. 20 | 21 | config OV7725_SUPPORT 22 | bool "OV7725 Support" 23 | default y 24 | help 25 | Enable this option if you want to use the OV7725. 26 | Disable this option to safe memory. 27 | 28 | endmenu 29 | -------------------------------------------------------------------------------- /components/lcd/include/gfxfont.h: -------------------------------------------------------------------------------- 1 | // Font structures for newer Adafruit_GFX (1.1 and later). 2 | // Example fonts are included in 'Fonts' directory. 3 | // To use a font in your Arduino sketch, #include the corresponding .h 4 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 5 | // revert to 'classic' fixed-space bitmap font. 6 | 7 | #ifndef _GFXFONT_H_ 8 | #define _GFXFONT_H_ 9 | 10 | typedef struct { // Data stored PER GLYPH 11 | uint16_t bitmapOffset; // Pointer into GFXfont->bitmap 12 | uint8_t width, height; // Bitmap dimensions in pixels 13 | uint8_t xAdvance; // Distance to advance cursor (x axis) 14 | int8_t xOffset, yOffset; // Dist from cursor pos to UL corner 15 | } GFXglyph; 16 | 17 | typedef struct { // Data stored for FONT AS A WHOLE: 18 | uint8_t *bitmap; // Glyph bitmaps, concatenated 19 | GFXglyph *glyph; // Glyph array 20 | uint8_t first, last; // ASCII extents 21 | uint8_t yAdvance; // Newline distance (y axis) 22 | } GFXfont; 23 | 24 | #endif // _GFXFONT_H_ 25 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/gfxfont.h: -------------------------------------------------------------------------------- 1 | // Font structures for newer Adafruit_GFX (1.1 and later). 2 | // Example fonts are included in 'Fonts' directory. 3 | // To use a font in your Arduino sketch, #include the corresponding .h 4 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 5 | // revert to 'classic' fixed-space bitmap font. 6 | 7 | #ifndef _GFXFONT_H_ 8 | #define _GFXFONT_H_ 9 | 10 | typedef struct { // Data stored PER GLYPH 11 | uint16_t bitmapOffset; // Pointer into GFXfont->bitmap 12 | uint8_t width, height; // Bitmap dimensions in pixels 13 | uint8_t xAdvance; // Distance to advance cursor (x axis) 14 | int8_t xOffset, yOffset; // Dist from cursor pos to UL corner 15 | } GFXglyph; 16 | 17 | typedef struct { // Data stored for FONT AS A WHOLE: 18 | uint8_t *bitmap; // Glyph bitmaps, concatenated 19 | GFXglyph *glyph; // Glyph array 20 | uint8_t first, last; // ASCII extents 21 | uint8_t yAdvance; // Newline distance (y axis) 22 | } GFXfont; 23 | 24 | #endif // _GFXFONT_H_ 25 | -------------------------------------------------------------------------------- /components/camera/camera_common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "rom/lldesc.h" 7 | #include "esp_err.h" 8 | #include "esp_intr_alloc.h" 9 | #include "freertos/FreeRTOS.h" 10 | #include "freertos/semphr.h" 11 | #include "freertos/task.h" 12 | #include "camera.h" 13 | #include "sensor.h" 14 | 15 | typedef union { 16 | struct { 17 | uint8_t sample2; 18 | uint8_t unused2; 19 | uint8_t sample1; 20 | uint8_t unused1; 21 | }; 22 | uint32_t val; 23 | } dma_elem_t; 24 | 25 | typedef enum { 26 | /* camera sends byte sequence: s1, s2, s3, s4, ... 27 | * fifo receives: 00 s1 00 s2, 00 s2 00 s3, 00 s3 00 s4, ... 28 | */ 29 | SM_0A0B_0B0C = 0, 30 | /* camera sends byte sequence: s1, s2, s3, s4, ... 31 | * fifo receives: 00 s1 00 s2, 00 s3 00 s4, ... 32 | */ 33 | SM_0A0B_0C0D = 1, 34 | /* camera sends byte sequence: s1, s2, s3, s4, ... 35 | * fifo receives: 00 s1 00 00, 00 s2 00 00, 00 s3 00 00, ... 36 | */ 37 | SM_0A00_0B00 = 3, 38 | } i2s_sampling_mode_t; 39 | 40 | -------------------------------------------------------------------------------- /components/camera/include/bitmap.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITMAP_H_ 2 | #define _BITMAP_H_ 3 | #include 4 | 5 | #define _bitsperpixel 24 6 | #define _planes 1 7 | #define _compression 0 8 | #define _xpixelpermeter 0x130B //2835 , 72 DPI 9 | #define _ypixelpermeter 0x130B //2835 , 72 DPI 10 | #define pixel 0xFF 11 | 12 | typedef struct __attribute__((packed, aligned(1))) { 13 | uint8_t signature[2]; 14 | uint32_t filesize; 15 | uint32_t reserved; 16 | uint32_t fileoffset_to_pixelarray; 17 | } fileheader; 18 | typedef struct __attribute__((packed, aligned(1))) { 19 | uint32_t dibheadersize; 20 | uint32_t width; 21 | uint32_t height; 22 | uint16_t planes; 23 | uint16_t bitsperpixel; 24 | uint32_t compression; 25 | uint32_t imagesize; 26 | uint32_t ypixelpermeter; 27 | uint32_t xpixelpermeter; 28 | uint32_t numcolorspallette; 29 | uint32_t mostimpcolor; 30 | } bitmapinfoheader; 31 | typedef struct { 32 | fileheader fileheader; 33 | bitmapinfoheader bitmapinfoheader; 34 | } bitmap_header_t; 35 | 36 | bitmap_header_t *bmp_create_header(int w, int h); 37 | #endif 38 | -------------------------------------------------------------------------------- /components/lcd/include/WProgram.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef _WPROGRAM_H_ 15 | #define _WPROGRAM_H_ 16 | 17 | #include "string.h" 18 | #include "esp_types.h" 19 | #include "freertos/FreeRTOS.h" 20 | 21 | #define abs(x) ((x)<0 ? -(x) : (x)) 22 | #define swap(x, y) do { typeof(x) temp##x##y = x; x = y; y = temp##x##y; } while (0) 23 | 24 | typedef bool boolean; 25 | typedef char __FlashStringHelper; 26 | 27 | class Print{ 28 | public: 29 | void print(char* s); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /components/camera/bitmap.c: -------------------------------------------------------------------------------- 1 | //https://stackoverflow.com/a/23303847 2 | #include "bitmap.h" 3 | #include 4 | #include 5 | 6 | 7 | bitmap_header_t *bmp_create_header(int w, int h) 8 | { 9 | bitmap_header_t *pbitmap = (bitmap_header_t*)calloc(1, sizeof(bitmap_header_t)); 10 | int _pixelbytesize = w * h * _bitsperpixel/8; 11 | int _filesize = _pixelbytesize+sizeof(bitmap_header_t); 12 | strcpy((char*)pbitmap->fileheader.signature, "BM"); 13 | pbitmap->fileheader.filesize = _filesize; 14 | pbitmap->fileheader.fileoffset_to_pixelarray = sizeof(bitmap_header_t); 15 | pbitmap->bitmapinfoheader.dibheadersize = sizeof(bitmapinfoheader); 16 | pbitmap->bitmapinfoheader.width = w; 17 | pbitmap->bitmapinfoheader.height = h; 18 | pbitmap->bitmapinfoheader.planes = _planes; 19 | pbitmap->bitmapinfoheader.bitsperpixel = _bitsperpixel; 20 | pbitmap->bitmapinfoheader.compression = _compression; 21 | pbitmap->bitmapinfoheader.imagesize = _pixelbytesize; 22 | pbitmap->bitmapinfoheader.ypixelpermeter = _ypixelpermeter ; 23 | pbitmap->bitmapinfoheader.xpixelpermeter = _xpixelpermeter ; 24 | pbitmap->bitmapinfoheader.numcolorspallette = 0; 25 | return pbitmap; 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ESPRESSIF MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case, 6 | it is free of charge, to any person obtaining a copy of this software and associated 7 | documentation files (the "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished 10 | to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all copies or 13 | substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/fontconvert/makefonts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Ugly little Bash script, generates a set of .h files for GFX using 4 | # GNU FreeFont sources. There are three fonts: 'Mono' (Courier-like), 5 | # 'Sans' (Helvetica-like) and 'Serif' (Times-like); four styles: regular, 6 | # bold, oblique or italic, and bold+oblique or bold+italic; and four 7 | # sizes: 9, 12, 18 and 24 point. No real error checking or anything, 8 | # this just powers through all the combinations, calling the fontconvert 9 | # utility and redirecting the output to a .h file for each combo. 10 | 11 | # Adafruit_GFX repository does not include the source outline fonts 12 | # (huge zipfile, different license) but they're easily acquired: 13 | # http://savannah.gnu.org/projects/freefont/ 14 | 15 | convert=./fontconvert 16 | inpath=~/Desktop/freefont/ 17 | outpath=../Fonts/ 18 | fonts=(FreeMono FreeSans FreeSerif) 19 | styles=("" Bold Italic BoldItalic Oblique BoldOblique) 20 | sizes=(9 12 18 24) 21 | 22 | for f in ${fonts[*]} 23 | do 24 | for index in ${!styles[*]} 25 | do 26 | st=${styles[$index]} 27 | for si in ${sizes[*]} 28 | do 29 | infile=$inpath$f$st".ttf" 30 | if [ -f $infile ] # Does source combination exist? 31 | then 32 | outfile=$outpath$f$st$si"pt7b.h" 33 | # printf "%s %s %s > %s\n" $convert $infile $si $outfile 34 | $convert $infile $si > $outfile 35 | fi 36 | done 37 | done 38 | done 39 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /components/camera/twi.h: -------------------------------------------------------------------------------- 1 | /* 2 | twi.h - Software I2C library for ESP31B 3 | 4 | Copyright (c) 2015 Hristo Gochkov. All rights reserved. 5 | This file is part of the ESP31B core for Arduino environment. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | #ifndef SI2C_h 22 | #define SI2C_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | void twi_init(unsigned char sda, unsigned char scl); 29 | void twi_stop(void); 30 | void twi_setClock(unsigned int freq); 31 | uint8_t twi_writeTo(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop); 32 | uint8_t twi_readFrom(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif -------------------------------------------------------------------------------- /components/camera/xclk.c: -------------------------------------------------------------------------------- 1 | #include "driver/gpio.h" 2 | #include "driver/ledc.h" 3 | #include "esp_err.h" 4 | #include "esp_log.h" 5 | #include "xclk.h" 6 | 7 | #if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) 8 | #include "esp32-hal-log.h" 9 | #else 10 | #include "esp_log.h" 11 | static const char* TAG = "camera_xclk"; 12 | #endif 13 | 14 | esp_err_t camera_enable_out_clock(camera_config_t* config) 15 | { 16 | periph_module_enable(PERIPH_LEDC_MODULE); 17 | 18 | ledc_timer_config_t timer_conf; 19 | timer_conf.duty_resolution = 2; 20 | timer_conf.freq_hz = config->xclk_freq_hz; 21 | timer_conf.speed_mode = LEDC_HIGH_SPEED_MODE; 22 | timer_conf.timer_num = config->ledc_timer; 23 | esp_err_t err = ledc_timer_config(&timer_conf); 24 | if (err != ESP_OK) { 25 | ESP_LOGE(TAG, "ledc_timer_config failed, rc=%x", err); 26 | return err; 27 | } 28 | 29 | ledc_channel_config_t ch_conf; 30 | ch_conf.gpio_num = config->pin_xclk; 31 | ch_conf.speed_mode = LEDC_HIGH_SPEED_MODE; 32 | ch_conf.channel = config->ledc_channel; 33 | ch_conf.intr_type = LEDC_INTR_DISABLE; 34 | ch_conf.timer_sel = config->ledc_timer; 35 | ch_conf.duty = 2; 36 | ch_conf.hpoint = 0; 37 | err = ledc_channel_config(&ch_conf); 38 | if (err != ESP_OK) { 39 | ESP_LOGE(TAG, "ledc_channel_config failed, rc=%x", err); 40 | return err; 41 | } 42 | return ESP_OK; 43 | } 44 | 45 | void camera_disable_out_clock() 46 | { 47 | periph_module_disable(PERIPH_LEDC_MODULE); 48 | } 49 | -------------------------------------------------------------------------------- /components/esp_facenet/mtmn/include/mtmn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | #include "dl_lib.h" 7 | 8 | 9 | typedef enum 10 | { 11 | PNET = 0, 12 | RNET = 1, 13 | ONET = 2, 14 | } net_type_en; 15 | 16 | typedef struct 17 | { 18 | net_type_en net_type; 19 | char *file_name; 20 | int w; 21 | int h; 22 | float score_threshold; 23 | float nms_threshold; 24 | } net_config_t; 25 | 26 | typedef struct 27 | { 28 | dl_matrix3d_t *category; 29 | dl_matrix3d_t *offset; 30 | dl_matrix3d_t *landmark; 31 | } mtmn_net_t; 32 | 33 | 34 | /** 35 | * @brief Forward the pnet process, coarse detection 36 | * 37 | * @param in Image matrix, rgb888 format, size is 320x240 38 | * @return Scores for every pixel, and box offset with respect. 39 | */ 40 | mtmn_net_t *pnet(dl_matrix3du_t *in); 41 | 42 | /** 43 | * @brief Forward the rnet process, fine determine the boxes from pnet 44 | * 45 | * @param in Image matrix, rgb888 format 46 | * @param threshold Score threshold to detect human face 47 | * @return Scores for every box, and box offset with respect. 48 | */ 49 | mtmn_net_t *rnet_with_score_verify(dl_matrix3du_t *in, float threshold); 50 | 51 | /** 52 | * @brief Forward the onet process, fine determine the boxes from rnet 53 | * 54 | * @param in Image matrix, rgb888 format 55 | * @param threshold Score threshold to detect human face 56 | * @return Scores for every box, box offset, and landmark with respect. 57 | */ 58 | mtmn_net_t *onet_with_score_verify(dl_matrix3du_t *in, float threshold); 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | -------------------------------------------------------------------------------- /components/esp_facenet/face_detection/include/face_detection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2018 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #pragma once 25 | 26 | #if __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #include "image_util.h" 31 | #include "dl_lib.h" 32 | 33 | #define MAX_DETECTION 1 34 | 35 | box_array_t *face_detect (dl_matrix3du_t *image_matrix); 36 | 37 | #if __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/main/include/app_facenet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #ifndef _APP_FACENET_H_ 25 | #define _APP_FACENET_H_ 26 | 27 | #if __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #include "face_detection.h" 32 | #include "image_util.h" 33 | #include "app_camera.h" 34 | 35 | void app_facenet_main (); 36 | 37 | #if __cplusplus 38 | } 39 | #endif 40 | #endif 41 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/main/app_facenet.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "esp_log.h" 4 | #include "esp_system.h" 5 | #include "freertos/FreeRTOS.h" 6 | #include "freertos/queue.h" 7 | #include "app_facenet.h" 8 | #include "sdkconfig.h" 9 | #include "dl_lib.h" 10 | 11 | static const char *TAG = "app_process"; 12 | extern QueueHandle_t gpst_output_queue; 13 | 14 | void *facenet_get_image () 15 | { 16 | void *buffer = NULL; 17 | xQueueReceive(gpst_input_queue, &buffer, portMAX_DELAY); 18 | return buffer; 19 | } 20 | 21 | void facenet_output_image (void *buffer) 22 | { 23 | //xQueueSend(gpst_output_queue, &buffer, portMAX_DELAY); 24 | xTaskNotifyGive(gpst_input_task); 25 | } 26 | 27 | void task_process (void *arg) 28 | {/*{{{*/ 29 | dl_matrix3du_t *image_matrix = dl_matrix3du_alloc(1, gl_input_image_width, gl_input_image_height, 3); 30 | size_t frame_num = 0; 31 | uint16_t *img_buffer = NULL; 32 | do 33 | { 34 | img_buffer = (uint16_t *)facenet_get_image(); 35 | transform_input_image(image_matrix->item, img_buffer, gl_input_image_width * gl_input_image_height); 36 | 37 | box_array_t *net_boxes = face_detect(image_matrix); 38 | 39 | if (net_boxes) 40 | { 41 | // draw_rectangle(img_buffer, net_boxes, gl_input_image_width); 42 | frame_num++; 43 | // ESP_LOGI(TAG, "DETECTED: %d\n", frame_num); 44 | ESP_LOGI(TAG, "Human Face DETECTED!!"); 45 | free(net_boxes->box); 46 | free(net_boxes); 47 | } 48 | 49 | facenet_output_image(image_matrix->item); 50 | 51 | } while(1); 52 | dl_matrix3du_free(image_matrix); 53 | }/*}}}*/ 54 | 55 | void app_facenet_main () 56 | { 57 | xTaskCreatePinnedToCore(task_process, "process", 4*1024, NULL, 5, NULL, 1); 58 | } 59 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/main/app_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2018 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | 25 | /** 26 | * CAMERA + PROCESS + OUTPUT 27 | * CONFIG_FACENET_INPUT + CONFIG_FACENET_PROCESS + CONFIG_FACENET_OUTPUT 28 | * 29 | * camera_single: 30 | * app_main.c 31 | * app_camera.c/h 32 | * app_facenet.c/h 33 | */ 34 | #include "sdkconfig.h" 35 | #include "app_camera.h" 36 | #include "app_facenet.h" 37 | 38 | extern "C" void app_main() 39 | { 40 | app_camera_main(); 41 | app_facenet_main(); 42 | xTaskNotifyGive(gpst_input_task); 43 | } 44 | -------------------------------------------------------------------------------- /components/lcd/adaptation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This is the subclass graphics library for all our displays, providing a common 3 | set of graphics primitives (points, lines, circles, etc.) 4 | 5 | Adafruit invests time and resources providing this open source code, please 6 | support Adafruit & open-source hardware by purchasing products from Adafruit! 7 | 8 | Based on ESP8266 library https://github.com/Sermus/ESP8266_Adafruit_lcd 9 | 10 | Copyright (c) 2015-2016 Andrey Filimonov. All rights reserved. 11 | 12 | Additions for ESP32 Copyright (c) 2016-2017 Espressif Systems (Shanghai) PTE LTD 13 | 14 | Copyright (c) 2013 Adafruit Industries. All rights reserved. 15 | 16 | Redistribution and use in source and binary forms, with or without 17 | modification, are permitted provided that the following conditions are met: 18 | 19 | - Redistributions of source code must retain the above copyright notice, 20 | this list of conditions and the following disclaimer. 21 | - Redistributions in binary form must reproduce the above copyright notice, 22 | this list of conditions and the following disclaimer in the documentation 23 | and/or other materials provided with the distribution. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | #include "WProgram.h" 39 | // Do nothing here 40 | void Print::print(char* s){ 41 | 42 | } -------------------------------------------------------------------------------- /components/lib/include/dl_lib_coefgetter_if.h: -------------------------------------------------------------------------------- 1 | #ifndef DL_LIB_COEFGETTER_IF_H 2 | #define DL_LIB_COEFGETTER_IF_H 3 | 4 | #include "dl_lib_matrix.h" 5 | #include "dl_lib_matrixq.h" 6 | #include "dl_lib_matrix3d.h" 7 | 8 | //Set this if the coefficient requested is a batch-normalization popvar matrix which needs to be preprocessed by 9 | //dl_batch_normalize_get_sqrtvar first. 10 | #define COEF_GETTER_HINT_BNVAR (1<<0) 11 | 12 | /* 13 | This struct describes the basic information of model data: 14 | word_num: the number of wake words or speech commands 15 | word_list: the name list of wake words or speech commands 16 | thres_list: the threshold list of wake words or speech commands 17 | info_str: the string used to reflect the version and information of model data 18 | which consist of the architecture of network, the version of model data, wake words and their threshold 19 | */ 20 | typedef struct { 21 | int word_num; 22 | char **word_list; 23 | int *win_list; 24 | float *thresh_list; 25 | char *info_str; 26 | } model_info_t; 27 | 28 | /* 29 | This struct describes a generic coefficient getter: a way to get the constant coefficients needed for a neural network. 30 | For the two getters, the name describes the name of the coefficient matrix, usually the same as the Numpy filename the 31 | coefficient was originally stored in. The arg argument can be used to optionally pass an additional user-defined argument 32 | to the getter (e.g. the directory to look for files in the case of the Numpy file loader getter). The hint argument 33 | is a bitwise OR of the COEF_GETTER_HINT_* flags or 0 when none is needed. Use the free_f/free_q functions to release the 34 | memory for the returned matrices, when applicable. 35 | */ 36 | typedef struct { 37 | const dl_matrix2d_t* (*getter_f)(const char *name, void *arg, int hint); 38 | const dl_matrix2dq_t* (*getter_q)(const char *name, void *arg, int hint); 39 | const void* (*getter_3d)(const char *name, void *arg, int hint); 40 | const void* (*getter_3dq)(const char *name, void *arg, int hint); 41 | void (*free_f)(const dl_matrix2d_t *m); 42 | void (*free_q)(const dl_matrix2dq_t *m); 43 | const model_info_t* (*getter_info)(void *arg); 44 | } model_coeff_getter_t; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /components/camera/sccb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * SCCB (I2C like) driver. 7 | * 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include "sccb.h" 13 | #include "twi.h" 14 | #include 15 | #include "sdkconfig.h" 16 | #if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) 17 | #include "esp32-hal-log.h" 18 | #else 19 | #include "esp_log.h" 20 | static const char* TAG = "sccb"; 21 | #endif 22 | 23 | 24 | #define SCCB_FREQ (100000) // We don't need fast I2C. 100KHz is fine here. 25 | #define TIMEOUT (1000) /* Can't be sure when I2C routines return. Interrupts 26 | while polling hardware may result in unknown delays. */ 27 | 28 | 29 | int SCCB_Init(int pin_sda, int pin_scl) 30 | { 31 | twi_init(pin_sda, pin_scl); 32 | return 0; 33 | } 34 | 35 | uint8_t SCCB_Probe() 36 | { 37 | uint8_t reg = 0x00; 38 | uint8_t slv_addr = 0x00; 39 | 40 | for (uint8_t i=0; i<127; i++) { 41 | if (twi_writeTo(i, ®, 1, true) == 0) { 42 | slv_addr = i; 43 | break; 44 | } 45 | 46 | if (i!=126) { 47 | vTaskDelay(1 / portTICK_PERIOD_MS); // Necessary for OV7725 camera (not for OV2640). 48 | } 49 | } 50 | return slv_addr; 51 | } 52 | 53 | uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg) 54 | { 55 | uint8_t data=0; 56 | 57 | int rc = twi_writeTo(slv_addr, ®, 1, true); 58 | if (rc != 0) { 59 | data = 0xff; 60 | } 61 | else { 62 | rc = twi_readFrom(slv_addr, &data, 1, true); 63 | if (rc != 0) { 64 | data=0xFF; 65 | } 66 | } 67 | if (rc != 0) { 68 | ESP_LOGE(TAG, "SCCB_Read [%02x] failed rc=%d\n", reg, rc); 69 | } 70 | return data; 71 | } 72 | 73 | uint8_t SCCB_Write(uint8_t slv_addr, uint8_t reg, uint8_t data) 74 | { 75 | uint8_t ret=0; 76 | uint8_t buf[] = {reg, data}; 77 | 78 | if(twi_writeTo(slv_addr, buf, 2, true) != 0) { 79 | ret=0xFF; 80 | } 81 | if (ret != 0) { 82 | printf("SCCB_Write [%02x]=%02x failed\n", reg, data); 83 | } 84 | return ret; 85 | } 86 | -------------------------------------------------------------------------------- /components/lcd/README.md: -------------------------------------------------------------------------------- 1 | ##TFT LCD Example Code for ESP32## 2 | 3 | This example is based on [Adafruit’s Library](https://github.com/adafruit/Adafruit-GFX-Library.git) for ILI9341. This component can display
4 | 1. Text
5 | 2. Bitmap Images
6 | 3. Shapes
7 | on the 320*240 TFT LCD
8 | Users can refer `ui_example.jpg` in the root folder of this example to learn more about the APIs & what they do. 9 | 10 | LCD has Serial & Parallel Interfaces, esp-wrover-kit is designed for Serial SPI interfacing. However, LCD requires some additional pins except the normal SPI pins. 11 | 12 | 13 | > Tip: TFT LCDs work on a basic bitmap, where you should tell each pixel what to do. The library is able to display data by a concept of foreground and background.
For eg: If white text is required on a black background, screen is filled with black, the foreground color is set to white. Only the bitmap pixels which define the font are cleared, and the rest are kept as they are. This is how bitmaps, fonts and shapes are printed on the screen. 14 | 15 | 16 | **Additional files required for the GUI** 17 | 18 | `components\lcd` folder
19 | 1. `Adafruit-GFX-Library`: Adafruit-GFX-Library
20 | 2. `Adafruit_lcd_fast_as.cpp`: Used for drawing pixels and some lines on the screen, and this subclass overrides most of the superclass methods in `Adafruit_GFX.cpp`
21 | 3. `Adafruit-GFX-Library/Font files`: It is the bitmap for various sizes of fonts (Prefer to only #include your desired fonts to save space)
22 | 4. `spi_lcd.c` : It has some SPI structures & functions which use the spi_master driver for sending out the data as required by Adafruit Libraries. 23 | 24 | > Note: To reduce the number of pins between the LCD & ESP32
25 | > - It is okay to leave out the MISO pin
26 | > - Short the backlight pin to always ON
27 | > - Reset pin can be shorted with the ESP32’s reset pin, but it might lead to unexpected behavior depending on the code. 28 | 29 | 30 | There have been multiple additions to the [Adafruit repository](https://github.com/adafruit/Adafruit_ILI9341) for the LCD, users can replace these files by new library if needed. Adafruit has made a good [documentation](https://cdn-learn.adafruit.com/downloads/pdf/adafruit-2-8-tft-touch-shield-v2.pdf) on TFT LCDs. 31 | 32 | If you are willing to share your User Interface for ESP32, you can do so by posting on the forum [here](http://bbs.esp32.com/). -------------------------------------------------------------------------------- /components/lcd/include/spi_lcd.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #ifndef _IOT_SPI_LCD_H_ 15 | #define _IOT_SPI_LCD_H_ 16 | 17 | #include "driver/spi_master.h" 18 | #include "iot_lcd.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** @brief Initialize the LCD by putting some data in the graphics registers 25 | * 26 | * @param pin_conf Pointer to the struct with mandatory pins required for the LCD 27 | * @param spi_wr_dev Pointer to the SPI handler for sending the data 28 | * @return lcd id 29 | */ 30 | uint32_t lcd_init(lcd_conf_t* lcd_conf, spi_device_handle_t *spi_wr_dev, lcd_dc_t *dc, int dma_chan); 31 | 32 | /*Used by adafruit functions to send data*/ 33 | void lcd_send_uint16_r(spi_device_handle_t spi, const uint16_t data, int32_t repeats, lcd_dc_t *dc); 34 | 35 | /*Send a command to the ILI9341. Uses spi_device_transmit, 36 | which waits until the transfer is complete */ 37 | void lcd_cmd(spi_device_handle_t spi, const uint8_t cmd, lcd_dc_t *dc); 38 | 39 | /*Send data to the ILI9341. Uses spi_device_transmit, 40 | which waits until the transfer is complete */ 41 | void lcd_data(spi_device_handle_t spi, const uint8_t *data, int len, lcd_dc_t *dc); 42 | 43 | /** @brief Read LCD IDs using SPI, not working yet 44 | * The 1st parameter is dummy data. 45 | * The 2nd parameter (ID1 [7:0]): LCD module's manufacturer ID. 46 | * The 3rd parameter (ID2 [7:0]): LCD module/driver version ID. 47 | * The 4th parameter (ID3 [7:0]): LCD module/driver ID. 48 | * @param spi spi handler 49 | * @param lcd_id pointer to struct for reading IDs 50 | */ 51 | void lcd_read_id(spi_device_handle_t spi, lcd_id_t *lcd_id, lcd_dc_t *dc); 52 | 53 | /** 54 | * @brief get LCD ID 55 | */ 56 | uint32_t lcd_get_id(spi_device_handle_t spi, lcd_dc_t *dc); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/main/app_camera.cpp: -------------------------------------------------------------------------------- 1 | #include "app_camera.h" 2 | 3 | static const char *TAG = "app_camera"; 4 | 5 | QueueHandle_t gpst_input_queue = NULL; 6 | TaskHandle_t gpst_input_task = NULL; 7 | int gl_input_image_width = 0; 8 | int gl_input_image_height = 0; 9 | 10 | 11 | void app_camera_init() 12 | { 13 | camera_model_t camera_model; 14 | camera_config_t config; 15 | config.ledc_channel = LEDC_CHANNEL_0; 16 | config.ledc_timer = LEDC_TIMER_0; 17 | config.pin_d0 = Y2_GPIO_NUM; 18 | config.pin_d1 = Y3_GPIO_NUM; 19 | config.pin_d2 = Y4_GPIO_NUM; 20 | config.pin_d3 = Y5_GPIO_NUM; 21 | config.pin_d4 = Y6_GPIO_NUM; 22 | config.pin_d5 = Y7_GPIO_NUM; 23 | config.pin_d6 = Y8_GPIO_NUM; 24 | config.pin_d7 = Y9_GPIO_NUM; 25 | config.pin_xclk = XCLK_GPIO_NUM; 26 | config.pin_pclk = PCLK_GPIO_NUM; 27 | config.pin_vsync = VSYNC_GPIO_NUM; 28 | config.pin_href = HREF_GPIO_NUM; 29 | config.pin_sscb_sda = SIOD_GPIO_NUM; 30 | config.pin_sscb_scl = SIOC_GPIO_NUM; 31 | config.pin_reset = RESET_GPIO_NUM;//-1; 32 | config.xclk_freq_hz = XCLK_FREQ; 33 | 34 | gl_input_image_width = resolution[CAMERA_FRAME_SIZE][0]; 35 | gl_input_image_height = resolution[CAMERA_FRAME_SIZE][1]; 36 | 37 | // camera init 38 | esp_err_t err = camera_probe(&config, &camera_model); 39 | if (err != ESP_OK) { 40 | ESP_LOGE(TAG, "Camera probe failed with error 0x%x", err); 41 | return; 42 | } 43 | 44 | config.frame_size = CAMERA_FRAME_SIZE; 45 | config.pixel_format = CAMERA_PIXEL_FORMAT; 46 | config.fb_count = 1; 47 | 48 | err = camera_init(&config); 49 | if (err != ESP_OK) { 50 | ESP_LOGE(TAG, "Camera init failed with error 0x%x", err); 51 | return; 52 | } 53 | vTaskDelay(200 / portTICK_PERIOD_MS); 54 | } 55 | 56 | void task_input (void *arg) 57 | { 58 | do 59 | { 60 | ulTaskNotifyTake(pdTRUE, portMAX_DELAY); 61 | int64_t start_time = esp_timer_get_time(); 62 | camera_fb_t *fb = camera_get_fb(); 63 | // ESP_LOGI(TAG, "Get one frame in %lld ms.", (esp_timer_get_time() - start_time)/1000); 64 | ESP_LOGI(TAG, "......."); 65 | xQueueSend(gpst_input_queue, &fb->buf, portMAX_DELAY); 66 | camera_return_fb(fb); 67 | } while (1); 68 | } 69 | 70 | void app_camera_main () 71 | { 72 | app_camera_init(); 73 | 74 | gpst_input_queue = xQueueCreate(1, sizeof(void *)); 75 | 76 | xTaskCreatePinnedToCore(task_input, "input", 4*1024, NULL, 5, &gpst_input_task, 0); 77 | } 78 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_ESPTOOLPY_PORT="/dev/ttyUSB1" 3 | CONFIG_ESPTOOLPY_BAUD_115200B= 4 | CONFIG_ESPTOOLPY_BAUD_230400B= 5 | CONFIG_ESPTOOLPY_BAUD_921600B=y 6 | CONFIG_ESPTOOLPY_BAUD_2MB= 7 | CONFIG_ESPTOOLPY_BAUD_OTHER= 8 | CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 9 | CONFIG_ESPTOOLPY_BAUD=921600 10 | CONFIG_ESPTOOLPY_COMPRESSED=y 11 | CONFIG_FLASHMODE_QIO=y 12 | CONFIG_FLASHMODE_QOUT= 13 | CONFIG_FLASHMODE_DIO= 14 | CONFIG_FLASHMODE_DOUT= 15 | CONFIG_ESPTOOLPY_FLASHMODE="dio" 16 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 17 | CONFIG_ESPTOOLPY_FLASHFREQ_40M= 18 | CONFIG_ESPTOOLPY_FLASHFREQ_26M= 19 | CONFIG_ESPTOOLPY_FLASHFREQ_20M= 20 | CONFIG_ESPTOOLPY_FLASHFREQ="80m" 21 | CONFIG_ESPTOOLPY_FLASHSIZE_1MB= 22 | CONFIG_ESPTOOLPY_FLASHSIZE_2MB= 23 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 24 | CONFIG_ESPTOOLPY_FLASHSIZE_8MB= 25 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB= 26 | CONFIG_ESPTOOLPY_FLASHSIZE="4MB" 27 | CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y 28 | CONFIG_ESPTOOLPY_BEFORE_RESET=y 29 | CONFIG_ESPTOOLPY_BEFORE_NORESET= 30 | CONFIG_ESPTOOLPY_BEFORE="default_reset" 31 | CONFIG_ESPTOOLPY_AFTER_RESET=y 32 | CONFIG_ESPTOOLPY_AFTER_NORESET= 33 | CONFIG_ESPTOOLPY_AFTER="hard_reset" 34 | CONFIG_MONITOR_BAUD_9600B= 35 | CONFIG_MONITOR_BAUD_57600B= 36 | CONFIG_MONITOR_BAUD_115200B=y 37 | CONFIG_MONITOR_BAUD_230400B= 38 | CONFIG_MONITOR_BAUD_921600B= 39 | CONFIG_MONITOR_BAUD_2MB= 40 | CONFIG_MONITOR_BAUD_OTHER= 41 | CONFIG_MONITOR_BAUD_OTHER_VAL=115200 42 | CONFIG_MONITOR_BAUD=115200 43 | 44 | CONFIG_ENABLE_TEST_PATTERN= 45 | CONFIG_OV2640_SUPPORT=y 46 | CONFIG_OV7725_SUPPORT= 47 | CONFIG_OV7670_SUPPORT= 48 | 49 | # 50 | # ESP32-specific 51 | # 52 | CONFIG_ESP32_DEFAULT_CPU_FREQ_80= 53 | CONFIG_ESP32_DEFAULT_CPU_FREQ_160= 54 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y 55 | CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240 56 | CONFIG_SPIRAM_SUPPORT=y 57 | 58 | # 59 | # SPI RAM config 60 | # 61 | CONFIG_SPIRAM_BOOT_INIT=y 62 | CONFIG_SPIRAM_IGNORE_NOTFOUND= 63 | CONFIG_SPIRAM_USE_MEMMAP= 64 | CONFIG_SPIRAM_USE_CAPS_ALLOC= 65 | CONFIG_SPIRAM_USE_MALLOC=y 66 | CONFIG_SPIRAM_TYPE_AUTO= 67 | CONFIG_SPIRAM_TYPE_ESPPSRAM32=y 68 | CONFIG_SPIRAM_TYPE_ESPPSRAM64= 69 | CONFIG_SPIRAM_SIZE=4194304 70 | CONFIG_SPIRAM_SPEED_40M= 71 | CONFIG_SPIRAM_SPEED_80M=y 72 | CONFIG_SPIRAM_MEMTEST=y 73 | CONFIG_SPIRAM_CACHE_WORKAROUND=y 74 | CONFIG_SPIRAM_BANKSWITCH_ENABLE=y 75 | CONFIG_SPIRAM_BANKSWITCH_RESERVE=8 76 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 77 | CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST= 78 | CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 79 | CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY= 80 | 81 | CONFIG_TASK_WDT= 82 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/README.md: -------------------------------------------------------------------------------- 1 | # Camera with Command Line in Single Chip 2 | 3 | This example implements Human Face Detection with a single ESP32 chip and without LCD. ESP32 gets input of image from camera and displays results in the Command Line after recognition. 4 | 5 | # Preparation 6 | 7 | To run this example, you need the following components: 8 | 9 | * ESP32 module: this example has been tested with **ESP32-WROVER**, which is highly recommended for getting started with. 10 | * Camera module: this example has been tested with **OV2640** camera module which is highly recommended for getting started with. 11 | * Set up [ESP-IDF](https://github.com/espressif/esp-idf) 12 | * Set up [ESP-WHO](https://github.com/espressif/esp-who) 13 | 14 | Any other confusions about preparation, please see general guide in the README.md of ESP-WHO. 15 | 16 | 17 | # Quick Start 18 | 19 | If preparations are ready, please follow this section to **connect** the camera to ESP32 module, flash application to ESP32, finally execute human face detection and display the **result**. 20 | 21 | ## Connect 22 | Specific pins used in this example to connect ESP32 module and camera module are listed in table below. 23 | 24 | | **Interface** | Camera Pin | Pin Mapping for ESP32-WROVER | **M5Camera** 25 | | :--- | :---: | :---: | :---: | 26 | | SCCB Clock | SIOC | IO27 | IO25 27 | | SCCB Data | SIOD | IO26 | IO23 28 | | System Clock | XCLK | IO21 | IO27 29 | | Vertical Sync | VSYNC | IO25 | IO22 30 | | Horizontal Reference | HREF | IO23 | IO26 31 | | Pixel Clock | PCLK | IO22 | IO21 32 | | Pixel Data Bit 0 | D2 | IO4 | IO32 33 | | Pixel Data Bit 1 | D3 | IO5 | IO35 34 | | Pixel Data Bit 2 | D4 | IO18 | IO34 35 | | Pixel Data Bit 3 | D5 | IO19 | IO5 36 | | Pixel Data Bit 4 | D6 | IO36 | IO39 37 | | Pixel Data Bit 5 | D7 | IO39 | IO18 38 | | Pixel Data Bit 6 | D8 | IO34 | IO36 39 | | Pixel Data Bit 7 | D9 | IO35 | IO19 40 | | Camera Reset | RESET | IO2 | IO15 41 | | Camera Power Down | PWDN | IO0 | IO0 42 | | Power Supply 3.3V | 3V3 | 3V3 | 3V3 43 | | Ground | GND | GND | GND 44 | 45 | 46 | In particular, if you have a **ESP-WROVER-KIT**, camera connector is already broken out and labeled Camera / JP4. Solder 2.54 mm / 0.1" double row, 18 pin socket in provided space and plug the camera module, OV2640 for example, right into it. Line up 3V3 and GND pins on camera module and on ESP-WROVER-KIT. D0 and D1 should be left unconnected outside the socket. The image below shows **ESP-WROVER-KIT** plugged with **OV2640** camera module. 47 | 48 | ![esp_wrover_kit_with_ov2640](../../../img/esp_wrover_kit_with_ov2640.png) 49 | 50 | ![m5camera](../../../img/m5camera.jpg) 51 | 52 | ## Results 53 | 54 | Open a serial terminal by using `make monitor` at this project, point the camera to a human face with a distance of 0.3m at least, then you will see the following information: 55 | 56 | ![detected](../../../img/detected.png) 57 | 58 | The key word **DETECTED** comes out when a human face is detected. 59 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/Adafruit_SPITFT.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _ADAFRUIT_SPITFT_ 3 | #define _ADAFRUIT_SPITFT_ 4 | 5 | 6 | #if ARDUINO >= 100 7 | #include "Arduino.h" 8 | #include "Print.h" 9 | #else 10 | #include "WProgram.h" 11 | #endif 12 | #include 13 | #include "Adafruit_GFX.h" 14 | 15 | 16 | #if defined(ARDUINO_STM32_FEATHER) 17 | typedef volatile uint32 RwReg; 18 | #endif 19 | #if defined(ARDUINO_FEATHER52) 20 | typedef volatile uint32_t RwReg; 21 | #endif 22 | 23 | class Adafruit_SPITFT : public Adafruit_GFX { 24 | protected: 25 | 26 | public: 27 | Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK, int8_t _RST = -1, int8_t _MISO = -1); 28 | Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _RST = -1); 29 | 30 | virtual void begin(uint32_t freq) = 0; 31 | void initSPI(uint32_t freq); 32 | 33 | // Required Non-Transaction 34 | void drawPixel(int16_t x, int16_t y, uint16_t color); 35 | 36 | // Transaction API 37 | void startWrite(void); 38 | void endWrite(void); 39 | void writePixel(int16_t x, int16_t y, uint16_t color); 40 | void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 41 | void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 42 | void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 43 | 44 | // Transaction API not used by GFX 45 | virtual void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) = 0; 46 | void writePixel(uint16_t color); 47 | void writePixels(uint16_t * colors, uint32_t len); 48 | void writeColor(uint16_t color, uint32_t len); 49 | void pushColor(uint16_t color); 50 | 51 | // Recommended Non-Transaction 52 | void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 53 | void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 54 | void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 55 | 56 | using Adafruit_GFX::drawRGBBitmap; // Check base class first 57 | void drawRGBBitmap(int16_t x, int16_t y, 58 | uint16_t *pcolors, int16_t w, int16_t h); 59 | 60 | uint16_t color565(uint8_t r, uint8_t g, uint8_t b); 61 | 62 | protected: 63 | uint32_t _freq; 64 | #if defined (__AVR__) || defined(TEENSYDUINO) || defined (ESP8266) || defined (ESP32) 65 | int8_t _cs, _dc, _rst, _sclk, _mosi, _miso; 66 | #else 67 | int32_t _cs, _dc, _rst, _sclk, _mosi, _miso; 68 | #endif 69 | 70 | #ifdef USE_FAST_PINIO 71 | volatile RwReg *mosiport, *misoport, *clkport, *dcport, *csport; 72 | RwReg mosipinmask, misopinmask, clkpinmask, cspinmask, dcpinmask; 73 | #endif 74 | 75 | void writeCommand(uint8_t cmd); 76 | void spiWrite(uint8_t v); 77 | uint8_t spiRead(void); 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit GFX Library 2 | 3 | This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions). 4 | 5 | Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! 6 | 7 | Written by Limor Fried/Ladyada for Adafruit Industries. 8 | BSD license, check license.txt for more information. 9 | All text above must be included in any redistribution. 10 | 11 | Recent Arduino IDE releases include the Library Manager for easy installation. Otherwise, to download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h. Place the Adafruit_GFX library folder your /Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE. 12 | 13 | # Useful Resources 14 | 15 | - Image2Code: This is a handy Java GUI utility to convert a BMP file into the array code necessary to display the image with the drawBitmap function. Check out the code at ehubin's GitHub repository: https://github.com/ehubin/Adafruit-GFX-Library/tree/master/Img2Code 16 | 17 | - drawXBitmap function: You can use the GIMP photo editor to save a .xbm file and use the array saved in the file to draw a bitmap with the drawXBitmap function. See the pull request here for more details: https://github.com/adafruit/Adafruit-GFX-Library/pull/31 18 | 19 | - 'Fonts' folder contains bitmap fonts for use with recent (1.1 and later) Adafruit_GFX. To use a font in your Arduino sketch, #include the corresponding .h file and pass address of GFXfont struct to setFont(). Pass NULL to revert to 'classic' fixed-space bitmap font. 20 | 21 | - 'fontconvert' folder contains a command-line tool for converting TTF fonts to Adafruit_GFX .h format. 22 | 23 | --- 24 | 25 | ### Roadmap 26 | 27 | The PRIME DIRECTIVE is to maintain backward compatibility with existing Arduino sketches -- many are hosted elsewhere and don't track changes here, some are in print and can never be changed! This "little" library has grown organically over time and sometimes we paint ourselves into a design corner and just have to live with it or add ungainly workarounds. 28 | 29 | Highly unlikely to merge any changes for additional or incompatible font formats (see Prime Directive above). There are already two formats and the code is quite bloaty there as it is (this also creates liabilities for tools and documentation). If you *must* have a more sophisticated font format, consider creating a fork with the features required for your project. For similar reasons, also unlikely to add any more bitmap formats, it's getting messy. 30 | 31 | Please don't reformat code for the sake of reformatting code. The resulting large "visual diff" makes it impossible to untangle actual bug fixes from merely rearranged lines. 32 | -------------------------------------------------------------------------------- /examples/single_chip/camera_with_command_line/main/include/app_camera.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #ifndef _APP_CAMERA_H_ 25 | #define _APP_CAMERA_H_ 26 | 27 | #include "esp_log.h" 28 | #include "esp_system.h" 29 | #include "freertos/FreeRTOS.h" 30 | #include "freertos/task.h" 31 | #include "freertos/queue.h" 32 | #include "camera.h" 33 | 34 | /** 35 | * CAMERA_PF_RGB565 = 0, //!< RGB, 2 bytes per pixel 36 | * CAMERA_PF_YUV422 = 1, //!< YUYV, 2 bytes per pixel 37 | * CAMERA_PF_GRAYSCALE = 2, //!< 1 byte per pixel 38 | * CAMERA_PF_JPEG = 3, //!< JPEG compressed 39 | * CAMERA_PF_RGB555 = 4, //!< RGB, 2 bytes per pixel 40 | * CAMERA_PF_RGB444 = 5, //!< RGB, 2 bytes per pixel 41 | */ 42 | #define CAMERA_PIXEL_FORMAT CAMERA_PF_RGB565 43 | 44 | /* 45 | * CAMERA_FS_QQVGA = 4, //!< 160x120 46 | * CAMERA_FS_HQVGA = 7, //!< 240x160 47 | * CAMERA_FS_QCIF = 6, //!< 176x144 48 | * CAMERA_FS_QVGA = 8, //!< 320x240 49 | * CAMERA_FS_VGA = 10, //!< 640x480 50 | * CAMERA_FS_SVGA = 11, //!< 800x600 51 | */ 52 | #define CAMERA_FRAME_SIZE CAMERA_FS_QVGA 53 | 54 | #define PWDN_GPIO_NUM 0 55 | #define RESET_GPIO_NUM 15 56 | #define Y2_GPIO_NUM 32 57 | #define Y3_GPIO_NUM 35 58 | #define Y4_GPIO_NUM 34 59 | #define Y5_GPIO_NUM 5 60 | #define Y6_GPIO_NUM 39 61 | #define Y7_GPIO_NUM 18 62 | #define Y8_GPIO_NUM 36 63 | #define Y9_GPIO_NUM 19 64 | #define XCLK_GPIO_NUM 27 65 | #define PCLK_GPIO_NUM 21 66 | #define HREF_GPIO_NUM 26 67 | #define VSYNC_GPIO_NUM 22 68 | #define SIOD_GPIO_NUM 25 69 | #define SIOC_GPIO_NUM 23 70 | 71 | #define XCLK_FREQ 20000000 72 | extern QueueHandle_t gpst_input_queue; 73 | extern TaskHandle_t gpst_input_task; 74 | extern int gl_input_image_width; 75 | extern int gl_input_image_height; 76 | 77 | void app_camera_main(); 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /components/lcd/test/lcd_refresh.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2017 5 | * 6 | * Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case, 7 | * it is free of charge, to any person obtaining a copy of this software and associated 8 | * documentation files (the "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 11 | * to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or 14 | * substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | */ 24 | #include "lwip/api.h" 25 | #include "iot_lcd.h" 26 | #include "iot_wifi_conn.h" 27 | #include "nvs_flash.h" 28 | #include "esp_event_loop.h" 29 | #include "freertos/event_groups.h" 30 | #include "lcd_image.h" 31 | 32 | #define PROGMEM 33 | #include "FreeSans9pt7b.h" 34 | #include "unity.h" 35 | 36 | static const char* TAG = "LCD_REFRESH"; 37 | static CEspLcd* tft = NULL; 38 | 39 | extern "C" void app_lcd_task(void *pvParameters) 40 | { 41 | uint8_t i = 0; 42 | uint32_t time = 0; 43 | time = xTaskGetTickCount(); 44 | 45 | while(1) { 46 | if((xTaskGetTickCount() - time) > 1000 / portTICK_RATE_MS ) { 47 | ESP_LOGI(TAG,"refresh %d fps", i); 48 | time = xTaskGetTickCount(); 49 | i = 0; 50 | } 51 | i++; 52 | tft->drawBitmap(0, 0, i > 150 ? (uint16_t *)pic1_320_240 : (uint16_t *)Status_320_240, 320, 240); 53 | } 54 | } 55 | 56 | extern "C" void app_lcd_init() 57 | { 58 | lcd_conf_t lcd_pins = { 59 | .lcd_model = LCD_MOD_AUTO_DET, 60 | .pin_num_miso = GPIO_NUM_25, 61 | .pin_num_mosi = GPIO_NUM_23, 62 | .pin_num_clk = GPIO_NUM_19, 63 | .pin_num_cs = GPIO_NUM_22, 64 | .pin_num_dc = GPIO_NUM_21, 65 | .pin_num_rst = GPIO_NUM_18, 66 | .pin_num_bckl = GPIO_NUM_5, 67 | .clk_freq = 80 * 1000 * 1000, 68 | .rst_active_level = 0, 69 | .bckl_active_level = 0, 70 | .spi_host = HSPI_HOST, 71 | .init_spi_bus = true, 72 | }; 73 | 74 | /*Initialize SPI Handler*/ 75 | if (tft == NULL) { 76 | tft = new CEspLcd(&lcd_pins); 77 | } 78 | 79 | /*screen initialize*/ 80 | tft->invertDisplay(false); 81 | tft->setRotation(1); 82 | tft->fillScreen(COLOR_GREEN); 83 | } 84 | 85 | TEST_CASE("LCD refresh test", "[lcd_refresh][iot]") 86 | { 87 | app_lcd_init(); 88 | 89 | vTaskDelay(500 / portTICK_RATE_MS); 90 | ESP_LOGI(TAG, "Free heap: %u", xPortGetFreeHeapSize()); 91 | 92 | ESP_LOGI(TAG, "get free size of 32BIT heap : %d\n", 93 | heap_caps_get_free_size(MALLOC_CAP_32BIT)); 94 | ESP_LOGD(TAG, "Starting app_lcd_task..."); 95 | xTaskCreate(&app_lcd_task, "app_lcd_task", 4096, NULL, 4, NULL); 96 | 97 | } 98 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/fontconvert/fontconvert_win.md: -------------------------------------------------------------------------------- 1 | ### A short guide to use fontconvert.c to create your own fonts using MinGW. 2 | 3 | #### STEP 1: INSTALL MinGW 4 | 5 | Install MinGW (Minimalist GNU for Windows) from [MinGW.org](http://www.mingw.org/). 6 | Please read carefully the instructions found on [Getting started page](http://www.mingw.org/wiki/Getting_Started). 7 | I suggest installing with the "Graphical User Interface Installer". 8 | To complete your initial installation you should further install some "packages". 9 | For our purpose you should only install the "Basic Setup" packages. 10 | To do that: 11 | 12 | 1. Open the MinGW Installation Manager 13 | 2. From the left panel click "Basic Setup". 14 | 3. On the right panel choose "mingw32-base", "mingw-gcc-g++", "mingw-gcc-objc" and "msys-base" 15 | and click "Mark for installation" 16 | 4. From the Menu click "Installation" and then "Apply changes". In the pop-up window select "Apply". 17 | 18 | 19 | #### STEP 2: INSTALL Freetype Library 20 | 21 | To read about the freetype project visit [freetype.org](https://www.freetype.org/). 22 | To Download the latest version of freetype go to [download page](http://download.savannah.gnu.org/releases/freetype/) 23 | and choose "freetype-2.7.tar.gz" file (or a newer version if available). 24 | To avoid long cd commands later in the command prompt, I suggest you unzip the file in the C:\ directory. 25 | (I also renamed the folder to "ft27") 26 | Before you build the library it's good to read these articles: 27 | * [Using MSYS with MinGW](http://www.mingw.org/wiki/MSYS) 28 | * [Installation and Use of Supplementary Libraries with MinGW](http://www.mingw.org/wiki/LibraryPathHOWTO) 29 | * [Include Path](http://www.mingw.org/wiki/IncludePathHOWTO) 30 | 31 | Inside the unzipped folder there is another folder named "docs". Open it and read the INSTALL.UNIX (using notepad). 32 | Pay attention to paragraph 3 (Build and Install the Library). So, let's begin the installation. 33 | To give the appropriate commands we will use the MSYS command prompt (not cmd.exe of windows) which is UNIX like. 34 | Follow the path C:\MinGW\msys\1.0 and double click "msys.bat". The command prompt environment appears. 35 | Enter "ft27" directory using the cd commands: 36 | ``` 37 | cd /c 38 | cd ft27 39 | ``` 40 | 41 | and then type one by one the commands: 42 | ``` 43 | ./configure --prefix=/mingw 44 | make 45 | make install 46 | ``` 47 | Once you're finished, go inside "C:\MinGW\include" and there should be a new folder named "freetype2". 48 | That, hopefully, means that you have installed the library correctly !! 49 | 50 | #### STEP 3: Build fontconvert.c 51 | 52 | Before proceeding I suggest you make a copy of Adafruit_GFX_library folder in C:\ directory. 53 | Then, inside "fontconvert" folder open the "makefile" with an editor ( I used notepad++). 54 | Change the commands so in the end the program looks like : 55 | ``` 56 | all: fontconvert 57 | 58 | CC = gcc 59 | CFLAGS = -Wall -I c:/mingw/include/freetype2 60 | LIBS = -lfreetype 61 | 62 | fontconvert: fontconvert.c 63 | $(CC) $(CFLAGS) $< $(LIBS) -o $@ 64 | 65 | clean: 66 | rm -f fontconvert 67 | ``` 68 | Go back in the command prompt and with a cd command enter the fontconvert directory. 69 | ``` 70 | cd /c/adafruit_gfx_library\fontconvert 71 | ``` 72 | Give the command: 73 | ``` 74 | make 75 | ``` 76 | This command will, eventually, create a "fontconvert.exe" file inside fontconvert directory. 77 | 78 | #### STEP 4: Create your own font header files 79 | 80 | Now that you have an executable file, you can use it to create your own fonts to work with Adafruit GFX lib. 81 | So, if we suppose that you already have a .ttf file with your favorite fonts, jump to the command prompt and type: 82 | ``` 83 | ./fontconvert yourfonts.ttf 9 > yourfonts9pt7b.h 84 | ``` 85 | You can read more details at: [learn.adafruit](https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts). 86 | 87 | Taraaaaaammm !! you've just created your new font header file. Put it inside the "Fonts" folder, grab a cup of coffee 88 | and start playing with your Arduino (or whatever else ....)+ display module project. 89 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - build 3 | - deploy 4 | 5 | variables: 6 | # System environment 7 | 8 | # Common parameters for the 'make' during CI tests 9 | MAKEFLAGS: "-j5 --no-keep-going" 10 | 11 | # GitLab-CI environment 12 | 13 | # more attempts for more robust 14 | GET_SOURCES_ATTEMPTS: "10" 15 | ARTIFACT_DOWNLOAD_ATTEMPTS: "10" 16 | 17 | # We use get_sources.sh script to fetch the submodules and/or re-fetch the repo 18 | # if it was corrupted (if submodule update fails this can happen) 19 | GIT_STRATEGY: clone 20 | GIT_SUBMODULE_STRATEGY: none 21 | IDF_PATH: "$CI_PROJECT_DIR/esp-idf" 22 | 23 | before_script: 24 | # add gitlab ssh key 25 | - mkdir -p ~/.ssh 26 | - chmod 700 ~/.ssh 27 | - echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64 28 | - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa 29 | - chmod 600 ~/.ssh/id_rsa 30 | - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config 31 | # replace submodule esp-idf to internal repository to speedup cloning 32 | - sed -i "s%https://github.com/espressif/esp-idf%${GITLAB_SSH_SERVER}/idf/esp-idf.git%" .gitmodules 33 | - git submodule update --init 34 | # (the same regular expressions are used to set these are used in 'only:' sections below 35 | - source esp-idf/tools/ci/configure_ci_environment.sh 36 | 37 | # fetch the submodules (& if necessary re-fetch repo) from gitlab 38 | - time ./esp-idf/tools/ci/get-full-sources.sh 39 | 40 | 41 | .add_gitlab_key_before: 42 | before_script: &add_gitlab_key_before 43 | - echo "Not fetching submodules" 44 | - source $IDF_PATH/tools/ci/configure_ci_environment.sh 45 | # add gitlab ssh key 46 | - mkdir -p ~/.ssh 47 | - chmod 700 ~/.ssh 48 | - echo -n $AUTO_KEY > ~/.ssh/id_rsa_base64 49 | - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa 50 | - chmod 600 ~/.ssh/id_rsa 51 | - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config 52 | 53 | .build_template: &build_template 54 | stage: build 55 | image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG 56 | tags: 57 | - build 58 | variables: 59 | BATCH_BUILD: "1" 60 | V: "0" 61 | 62 | .build_examples_template: &build_examples_template 63 | <<: *build_template 64 | retry: 1 65 | artifacts: 66 | when: always 67 | paths: 68 | - build_examples/*/*/*/build/*.bin 69 | - build_examples/*/*/*/build/*.elf 70 | - build_examples/*/*/*/build/*.map 71 | - build_examples/*/*/*/build/download.config 72 | - build_examples/*/*/*/build/bootloader/*.bin 73 | - $LOG_PATH 74 | expire_in: 1 week 75 | variables: 76 | IDF_CI_BUILD: "1" 77 | LOG_PATH: "$CI_PROJECT_DIR/log_examples" 78 | script: 79 | # it's not possible to build 100% out-of-tree and have the "artifacts" 80 | # mechanism work, but this is the next best thing 81 | - rm -rf build_examples 82 | - mkdir build_examples 83 | - cd build_examples 84 | # build some of examples 85 | - mkdir -p ${LOG_PATH} 86 | - ${IDF_PATH}/tools/ci/build_examples.sh "${CI_JOB_NAME}" 87 | 88 | build_facenet_test: 89 | stage: build 90 | image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG 91 | tags: 92 | - build 93 | variables: 94 | BATCH_BUILD: "1" 95 | IDF_CI_BUILD: "1" 96 | script: 97 | - cd examples/single_chip/camera_with_command_line 98 | # Test debug build (default) 99 | - make defconfig 100 | - make V=0 101 | # Now test release build 102 | - make clean 103 | - sed -i.bak -e's/CONFIG_OPTIMIZATION_LEVEL_DEBUG\=y/CONFIG_OPTIMIZATION_LEVEL_RELEASE=y/' sdkconfig 104 | - make V=0 105 | 106 | push_to_github: 107 | stage: deploy 108 | image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG 109 | tags: 110 | - deploy 111 | only: 112 | - master 113 | - /^release\/v/ 114 | - /^v\d+\.\d+(\.\d+)?($|-)/ 115 | when: on_success 116 | dependencies: [] 117 | before_script: 118 | - echo "skip default before_script" 119 | script: 120 | - mkdir -p ~/.ssh 121 | - chmod 700 ~/.ssh 122 | - echo -n $GH_PUSH_KEY > ~/.ssh/id_rsa_base64 123 | - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa 124 | - chmod 600 ~/.ssh/id_rsa 125 | - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config 126 | - git remote remove github &>/dev/null || true 127 | - git remote add github git@github.com:espressif/esp-who.git 128 | - eval $(git for-each-ref --shell bash --format 'if [ $CI_BUILD_REF == %(objectname) ]; then git checkout -B %(refname:strip=3); git push --follow-tags github %(refname:strip=3); fi;' $GITHUB_PUSH_REFS) 129 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/Adafruit_SPITFT_Macros.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Control Pins 4 | * */ 5 | 6 | #ifdef USE_FAST_PINIO 7 | #define SPI_DC_HIGH() *dcport |= dcpinmask 8 | #define SPI_DC_LOW() *dcport &= ~dcpinmask 9 | #define SPI_CS_HIGH() *csport |= cspinmask 10 | #define SPI_CS_LOW() *csport &= ~cspinmask 11 | #else 12 | #define SPI_DC_HIGH() digitalWrite(_dc, HIGH) 13 | #define SPI_DC_LOW() digitalWrite(_dc, LOW) 14 | #define SPI_CS_HIGH() digitalWrite(_cs, HIGH) 15 | #define SPI_CS_LOW() digitalWrite(_cs, LOW) 16 | #endif 17 | 18 | /* 19 | * Software SPI Macros 20 | * */ 21 | 22 | #ifdef USE_FAST_PINIO 23 | #define SSPI_MOSI_HIGH() *mosiport |= mosipinmask 24 | #define SSPI_MOSI_LOW() *mosiport &= ~mosipinmask 25 | #define SSPI_SCK_HIGH() *clkport |= clkpinmask 26 | #define SSPI_SCK_LOW() *clkport &= ~clkpinmask 27 | #define SSPI_MISO_READ() ((*misoport & misopinmask) != 0) 28 | #else 29 | #define SSPI_MOSI_HIGH() digitalWrite(_mosi, HIGH) 30 | #define SSPI_MOSI_LOW() digitalWrite(_mosi, LOW) 31 | #define SSPI_SCK_HIGH() digitalWrite(_sclk, HIGH) 32 | #define SSPI_SCK_LOW() digitalWrite(_sclk, LOW) 33 | #define SSPI_MISO_READ() digitalRead(_miso) 34 | #endif 35 | 36 | #define SSPI_BEGIN_TRANSACTION() 37 | #define SSPI_END_TRANSACTION() 38 | #define SSPI_WRITE(v) spiWrite(v) 39 | #define SSPI_WRITE16(s) SSPI_WRITE((s) >> 8); SSPI_WRITE(s) 40 | #define SSPI_WRITE32(l) SSPI_WRITE((l) >> 24); SSPI_WRITE((l) >> 16); SSPI_WRITE((l) >> 8); SSPI_WRITE(l) 41 | #define SSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ SSPI_WRITE(((uint8_t*)(c))[i+1]); SSPI_WRITE(((uint8_t*)(c))[i]); } 42 | 43 | /* 44 | * Hardware SPI Macros 45 | * */ 46 | 47 | #define SPI_OBJECT SPI 48 | 49 | #if defined (__AVR__) || defined(TEENSYDUINO) || defined(ARDUINO_ARCH_STM32F1) 50 | #define HSPI_SET_CLOCK() SPI_OBJECT.setClockDivider(SPI_CLOCK_DIV2); 51 | #elif defined (__arm__) 52 | #define HSPI_SET_CLOCK() SPI_OBJECT.setClockDivider(11); 53 | #elif defined(ESP8266) || defined(ESP32) 54 | #define HSPI_SET_CLOCK() SPI_OBJECT.setFrequency(_freq); 55 | #elif defined(RASPI) 56 | #define HSPI_SET_CLOCK() SPI_OBJECT.setClock(_freq); 57 | #elif defined(ARDUINO_ARCH_STM32F1) 58 | #define HSPI_SET_CLOCK() SPI_OBJECT.setClock(_freq); 59 | #else 60 | #define HSPI_SET_CLOCK() 61 | #endif 62 | 63 | #ifdef SPI_HAS_TRANSACTION 64 | #define HSPI_BEGIN_TRANSACTION() SPI_OBJECT.beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0)) 65 | #define HSPI_END_TRANSACTION() SPI_OBJECT.endTransaction() 66 | #else 67 | #define HSPI_BEGIN_TRANSACTION() HSPI_SET_CLOCK(); SPI_OBJECT.setBitOrder(MSBFIRST); SPI_OBJECT.setDataMode(SPI_MODE0) 68 | #define HSPI_END_TRANSACTION() 69 | #endif 70 | 71 | #ifdef ESP32 72 | #define SPI_HAS_WRITE_PIXELS 73 | #endif 74 | #if defined(ESP8266) || defined(ESP32) 75 | // Optimized SPI (ESP8266 and ESP32) 76 | #define HSPI_READ() SPI_OBJECT.transfer(0) 77 | #define HSPI_WRITE(b) SPI_OBJECT.write(b) 78 | #define HSPI_WRITE16(s) SPI_OBJECT.write16(s) 79 | #define HSPI_WRITE32(l) SPI_OBJECT.write32(l) 80 | #ifdef SPI_HAS_WRITE_PIXELS 81 | #define SPI_MAX_PIXELS_AT_ONCE 32 82 | #define HSPI_WRITE_PIXELS(c,l) SPI_OBJECT.writePixels(c,l) 83 | #else 84 | #define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<((l)/2); i++){ SPI_WRITE16(((uint16_t*)(c))[i]); } 85 | #endif 86 | #else 87 | // Standard Byte-by-Byte SPI 88 | 89 | #if defined (__AVR__) || defined(TEENSYDUINO) 90 | static inline uint8_t _avr_spi_read(void) __attribute__((always_inline)); 91 | static inline uint8_t _avr_spi_read(void) { 92 | uint8_t r = 0; 93 | SPDR = r; 94 | while(!(SPSR & _BV(SPIF))); 95 | r = SPDR; 96 | return r; 97 | } 98 | #define HSPI_WRITE(b) {SPDR = (b); while(!(SPSR & _BV(SPIF)));} 99 | #define HSPI_READ() _avr_spi_read() 100 | #else 101 | #define HSPI_WRITE(b) SPI_OBJECT.transfer((uint8_t)(b)) 102 | #define HSPI_READ() HSPI_WRITE(0) 103 | #endif 104 | #define HSPI_WRITE16(s) HSPI_WRITE((s) >> 8); HSPI_WRITE(s) 105 | #define HSPI_WRITE32(l) HSPI_WRITE((l) >> 24); HSPI_WRITE((l) >> 16); HSPI_WRITE((l) >> 8); HSPI_WRITE(l) 106 | #define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ HSPI_WRITE(((uint8_t*)(c))[i+1]); HSPI_WRITE(((uint8_t*)(c))[i]); } 107 | #endif 108 | 109 | #define SPI_BEGIN() if(_sclk < 0){SPI_OBJECT.begin();} 110 | #define SPI_BEGIN_TRANSACTION() if(_sclk < 0){HSPI_BEGIN_TRANSACTION();} 111 | #define SPI_END_TRANSACTION() if(_sclk < 0){HSPI_END_TRANSACTION();} 112 | #define SPI_WRITE16(s) if(_sclk < 0){HSPI_WRITE16(s);}else{SSPI_WRITE16(s);} 113 | #define SPI_WRITE32(l) if(_sclk < 0){HSPI_WRITE32(l);}else{SSPI_WRITE32(l);} 114 | #define SPI_WRITE_PIXELS(c,l) if(_sclk < 0){HSPI_WRITE_PIXELS(c,l);}else{SSPI_WRITE_PIXELS(c,l);} 115 | -------------------------------------------------------------------------------- /components/image_util/include/image_util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | #include 6 | #include "mtmn.h" 7 | 8 | #define BOX_LEN (80) 9 | #define MIN_FACE (12.0) 10 | #define MAX_VALID_COUNT_PER_IMAGE (30) 11 | 12 | #define DL_IMAGE_MIN(A, B) ((A) < (B) ? (A) : (B)) 13 | #define DL_IMAGE_MAX(A, B) ((A) < (B) ? (B) : (A)) 14 | 15 | #define IMAGE_WIDTH 320 16 | #define IMAGE_HEIGHT 240 17 | 18 | #define RGB565_MASK_RED 0xF800 19 | #define RGB565_MASK_GREEN 0x07E0 20 | #define RGB565_MASK_BLUE 0x001F 21 | 22 | typedef struct 23 | { 24 | fptp_t landmark_p[10]; 25 | } landmark_t; 26 | 27 | 28 | typedef struct 29 | { 30 | fptp_t box_p[4]; 31 | } box_t; 32 | 33 | typedef struct tag_box_list 34 | { 35 | box_t *box; 36 | landmark_t *landmark; 37 | int len; 38 | } box_array_t; 39 | 40 | typedef struct tag_image_box 41 | { 42 | struct tag_image_box *next; 43 | fptp_t score; 44 | box_t box; 45 | box_t offset; 46 | landmark_t landmark; 47 | } image_box_t; 48 | 49 | typedef struct tag_image_list 50 | { 51 | image_box_t *head; 52 | image_box_t *origin_head; 53 | int len; 54 | } image_list_t; 55 | 56 | 57 | static inline void image_get_width_and_height (box_t *box, float *w, float *h) 58 | { 59 | *w = box->box_p[2] - box->box_p[0] + 1; 60 | *h = box->box_p[3] - box->box_p[1] + 1; 61 | } 62 | 63 | 64 | static inline void image_get_area (box_t *box, float *area) 65 | { 66 | float w, h; 67 | image_get_width_and_height(box, &w, &h); 68 | *area = w * h; 69 | } 70 | 71 | 72 | static inline void image_calibrate_by_offset (image_list_t *image_list) 73 | { 74 | for (image_box_t *head = image_list->head; head; head = head->next) 75 | { 76 | float w, h; 77 | image_get_width_and_height(&(head->box), &w, &h); 78 | head->box.box_p[0] = DL_IMAGE_MAX(0, head->box.box_p[0] + head->offset.box_p[0] * w); 79 | head->box.box_p[1] = DL_IMAGE_MAX(0, head->box.box_p[1] + head->offset.box_p[1] * w); 80 | head->box.box_p[2] += head->offset.box_p[2] * w; 81 | if (head->box.box_p[2] > IMAGE_WIDTH) 82 | { 83 | head->box.box_p[2] = IMAGE_WIDTH - 1; 84 | head->box.box_p[0] = IMAGE_WIDTH - w; 85 | } 86 | head->box.box_p[3] += head->offset.box_p[3] * h; 87 | if (head->box.box_p[3] > IMAGE_HEIGHT) 88 | { 89 | head->box.box_p[3] = IMAGE_HEIGHT - 1; 90 | head->box.box_p[1] = IMAGE_HEIGHT - h; 91 | } 92 | } 93 | } 94 | 95 | static inline void image_landmark_calibrate (image_list_t *image_list) 96 | { 97 | for (image_box_t *head = image_list->head; head; head = head->next) 98 | { 99 | float w, h; 100 | image_get_width_and_height(&(head->box), &w, &h); 101 | head->landmark.landmark_p[0] = head->box.box_p[0] + head->landmark.landmark_p[0] * w; 102 | head->landmark.landmark_p[1] = head->box.box_p[1] + head->landmark.landmark_p[1] * h; 103 | 104 | head->landmark.landmark_p[2] = head->box.box_p[0] + head->landmark.landmark_p[2] * w; 105 | head->landmark.landmark_p[3] = head->box.box_p[1] + head->landmark.landmark_p[3] * h; 106 | 107 | head->landmark.landmark_p[4] = head->box.box_p[0] + head->landmark.landmark_p[4] * w; 108 | head->landmark.landmark_p[5] = head->box.box_p[1] + head->landmark.landmark_p[5] * h; 109 | 110 | head->landmark.landmark_p[6] = head->box.box_p[0] + head->landmark.landmark_p[6] * w; 111 | head->landmark.landmark_p[7] = head->box.box_p[1] + head->landmark.landmark_p[7] * h; 112 | 113 | head->landmark.landmark_p[8] = head->box.box_p[0] + head->landmark.landmark_p[8] * w; 114 | head->landmark.landmark_p[9] = head->box.box_p[1] + head->landmark.landmark_p[9] * h; 115 | } 116 | 117 | } 118 | 119 | static inline void image_rect2sqr (box_array_t *boxes, int width, int height) 120 | { 121 | for (int i = 0; i < boxes->len; i++) 122 | { 123 | box_t *box =&(boxes->box[i]); 124 | float w, h; 125 | image_get_width_and_height(box, &w, &h); 126 | float l = DL_IMAGE_MAX(w, h); 127 | 128 | box->box_p[0] = DL_IMAGE_MAX(0, box->box_p[0] + 0.5 * (w - l)); 129 | box->box_p[1] = DL_IMAGE_MAX(0, box->box_p[1] + 0.5 * (h - l)); 130 | box->box_p[2] = box->box_p[0] + l - 1; 131 | if (box->box_p[2] > width) 132 | { 133 | box->box_p[2] = width - 1; 134 | box->box_p[0] = width - l; 135 | } 136 | box->box_p[3] = box->box_p[1] + l - 1; 137 | if (box->box_p[3] > height) 138 | { 139 | box->box_p[3] = height - 1; 140 | box->box_p[1] = height - l; 141 | } 142 | } 143 | } 144 | 145 | static inline void rgb565_to_888(uint16_t in, uint8_t* dst) 146 | {/*{{{*/ 147 | dst[0] = (in & RGB565_MASK_BLUE) << 3; // blue 148 | dst[1] = (in & RGB565_MASK_GREEN) >> 3; // green 149 | dst[2] = (in & RGB565_MASK_RED) >> 8; // red 150 | }/*}}}*/ 151 | 152 | static inline void rgb888_to_565(uint16_t *in, uint8_t r, uint8_t g, uint8_t b) 153 | {/*{{{*/ 154 | uint16_t rgb565=0; 155 | rgb565 = ((r >> 3) << 11); 156 | rgb565 |= ((g >> 2) << 5); 157 | rgb565 |= (b >> 3); 158 | *in = rgb565; 159 | }/*}}}*/ 160 | 161 | image_list_t *image_get_valid_boxes (fptp_t *score, fptp_t *offset, int width, int height, fptp_t score_threshold, fptp_t scale); 162 | void image_sort_insert_by_score (image_list_t *image_sorted_list, const image_list_t *insert_list); 163 | void image_nms_process (image_list_t *image_list, fptp_t nms_threshold, int same_area); 164 | void image_resize_linear (uint8_t *dst_image, uint8_t *src_image, int dst_w, int dst_h, int dst_c, int src_w, int src_h); 165 | void image_cropper(uint8_t *rot_data, uint8_t *src_data, int rot_w, int rot_h, int rot_c, int src_w, int src_h, float rotate_angle, float ratio, float* center); 166 | void transform_input_image (uint8_t *m, uint16_t *bmp, int count); 167 | void transform_output_image (uint16_t *bmp, uint8_t *m, int count); 168 | void draw_rectangle(uint16_t *buf, box_array_t *boxes, int width); 169 | #ifdef __cplusplus 170 | } 171 | #endif 172 | -------------------------------------------------------------------------------- /components/camera/include/sensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * Sensor abstraction layer. 7 | * 8 | */ 9 | #ifndef __SENSOR_H__ 10 | #define __SENSOR_H__ 11 | #include 12 | 13 | #define OV9650_PID (0x96) 14 | #define OV2640_PID (0x26) 15 | #define OV7725_PID (0x77) 16 | 17 | 18 | typedef struct { 19 | uint8_t MIDH; 20 | uint8_t MIDL; 21 | uint8_t PID; 22 | uint8_t VER; 23 | } sensor_id_t; 24 | 25 | typedef enum { 26 | PIXFORMAT_RGB565, // 2BPP/RGB565 27 | PIXFORMAT_YUV422, // 2BPP/YUV422 28 | PIXFORMAT_GRAYSCALE, // 1BPP/GRAYSCALE 29 | PIXFORMAT_JPEG, // JPEG/COMPRESSED 30 | PIXFORMAT_RGB888, // 3BPP/RGB888 31 | } pixformat_t; 32 | 33 | typedef enum { 34 | FRAMESIZE_40x30, // 40x30 35 | FRAMESIZE_64x32, // 64x32 36 | FRAMESIZE_64x64, // 64x64 37 | FRAMESIZE_QQCIF, // 88x72 38 | FRAMESIZE_QQVGA, // 160x120 39 | FRAMESIZE_QQVGA2, // 128x160 40 | FRAMESIZE_QCIF, // 176x144 41 | FRAMESIZE_HQVGA, // 220x160 42 | FRAMESIZE_QVGA, // 320x240 43 | FRAMESIZE_CIF, // 400x296 44 | FRAMESIZE_VGA, // 640x480 45 | FRAMESIZE_SVGA, // 800x600 46 | FRAMESIZE_XGA, // 1024x768 47 | FRAMESIZE_SXGA, // 1280x1024 48 | FRAMESIZE_UXGA, // 1600x1200 49 | } framesize_t; 50 | 51 | typedef enum { 52 | FRAMERATE_2FPS =0x9F, 53 | FRAMERATE_8FPS =0x87, 54 | FRAMERATE_15FPS=0x83, 55 | FRAMERATE_30FPS=0x81, 56 | FRAMERATE_60FPS=0x80, 57 | } framerate_t; 58 | 59 | typedef enum { 60 | GAINCEILING_2X, 61 | GAINCEILING_4X, 62 | GAINCEILING_8X, 63 | GAINCEILING_16X, 64 | GAINCEILING_32X, 65 | GAINCEILING_64X, 66 | GAINCEILING_128X, 67 | } gainceiling_t; 68 | 69 | typedef enum { 70 | SDE_NORMAL, 71 | SDE_NEGATIVE, 72 | } sde_t; 73 | 74 | typedef enum { 75 | ATTR_CONTRAST=0, 76 | ATTR_BRIGHTNESS, 77 | ATTR_SATURATION, 78 | ATTR_GAINCEILING, 79 | } sensor_attr_t; 80 | 81 | typedef enum { 82 | ACTIVE_LOW, 83 | ACTIVE_HIGH 84 | } reset_polarity_t; 85 | 86 | typedef void (*line_filter_t) (uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, void *args); 87 | 88 | #define SENSOR_HW_FLAGS_VSYNC (0) // vertical sync polarity. 89 | #define SENSOR_HW_FLAGS_HSYNC (1) // horizontal sync polarity. 90 | #define SENSOR_HW_FLAGS_PIXCK (2) // pixel clock edge. 91 | #define SENSOR_HW_FLAGS_FSYNC (3) // hardware frame sync. 92 | #define SENSOR_HW_FLAGS_JPEGE (4) // hardware JPEG encoder. 93 | #define SENSOR_HW_FLAGS_GET(s, x) ((s)->hw_flags & (1<hw_flags |= (v<hw_flags &= ~(1<' 53 | { 54, 3, 5, 4, 0, -4 }, // 0x3F '?' 54 | { 56, 3, 5, 4, 0, -4 }, // 0x40 '@' 55 | { 58, 3, 5, 4, 0, -4 }, // 0x41 'A' 56 | { 60, 3, 5, 4, 0, -4 }, // 0x42 'B' 57 | { 62, 3, 5, 4, 0, -4 }, // 0x43 'C' 58 | { 64, 3, 5, 4, 0, -4 }, // 0x44 'D' 59 | { 66, 3, 5, 4, 0, -4 }, // 0x45 'E' 60 | { 68, 3, 5, 4, 0, -4 }, // 0x46 'F' 61 | { 70, 3, 5, 4, 0, -4 }, // 0x47 'G' 62 | { 72, 3, 5, 4, 0, -4 }, // 0x48 'H' 63 | { 74, 1, 5, 2, 0, -4 }, // 0x49 'I' 64 | { 75, 3, 5, 4, 0, -4 }, // 0x4A 'J' 65 | { 77, 3, 5, 4, 0, -4 }, // 0x4B 'K' 66 | { 79, 3, 5, 4, 0, -4 }, // 0x4C 'L' 67 | { 81, 5, 5, 6, 0, -4 }, // 0x4D 'M' 68 | { 85, 4, 5, 5, 0, -4 }, // 0x4E 'N' 69 | { 88, 3, 5, 4, 0, -4 }, // 0x4F 'O' 70 | { 90, 3, 5, 4, 0, -4 }, // 0x50 'P' 71 | { 92, 3, 6, 4, 0, -4 }, // 0x51 'Q' 72 | { 95, 3, 5, 4, 0, -4 }, // 0x52 'R' 73 | { 97, 3, 5, 4, 0, -4 }, // 0x53 'S' 74 | { 99, 3, 5, 4, 0, -4 }, // 0x54 'T' 75 | { 101, 3, 5, 4, 0, -4 }, // 0x55 'U' 76 | { 103, 3, 5, 4, 0, -4 }, // 0x56 'V' 77 | { 105, 5, 5, 6, 0, -4 }, // 0x57 'W' 78 | { 109, 3, 5, 4, 0, -4 }, // 0x58 'X' 79 | { 111, 3, 5, 4, 0, -4 }, // 0x59 'Y' 80 | { 113, 3, 5, 4, 0, -4 }, // 0x5A 'Z' 81 | { 115, 2, 5, 3, 0, -4 }, // 0x5B '[' 82 | { 117, 3, 5, 4, 0, -4 }, // 0x5C '\' 83 | { 119, 2, 5, 3, 0, -4 }, // 0x5D ']' 84 | { 121, 3, 2, 4, 0, -4 }, // 0x5E '^' 85 | { 122, 4, 1, 4, 0, 1 }, // 0x5F '_' 86 | { 123, 2, 2, 3, 0, -4 }, // 0x60 '`' 87 | { 124, 3, 4, 4, 0, -3 }, // 0x61 'a' 88 | { 126, 3, 5, 4, 0, -4 }, // 0x62 'b' 89 | { 128, 3, 3, 4, 0, -2 }, // 0x63 'c' 90 | { 130, 3, 5, 4, 0, -4 }, // 0x64 'd' 91 | { 132, 3, 4, 4, 0, -3 }, // 0x65 'e' 92 | { 134, 2, 5, 3, 0, -4 }, // 0x66 'f' 93 | { 136, 3, 5, 4, 0, -3 }, // 0x67 'g' 94 | { 138, 3, 5, 4, 0, -4 }, // 0x68 'h' 95 | { 140, 1, 5, 2, 0, -4 }, // 0x69 'i' 96 | { 141, 2, 6, 3, 0, -4 }, // 0x6A 'j' 97 | { 143, 3, 5, 4, 0, -4 }, // 0x6B 'k' 98 | { 145, 2, 5, 3, 0, -4 }, // 0x6C 'l' 99 | { 147, 5, 3, 6, 0, -2 }, // 0x6D 'm' 100 | { 149, 3, 3, 4, 0, -2 }, // 0x6E 'n' 101 | { 151, 3, 3, 4, 0, -2 }, // 0x6F 'o' 102 | { 153, 3, 4, 4, 0, -2 }, // 0x70 'p' 103 | { 155, 3, 4, 4, 0, -2 }, // 0x71 'q' 104 | { 157, 2, 3, 3, 0, -2 }, // 0x72 'r' 105 | { 158, 3, 4, 4, 0, -3 }, // 0x73 's' 106 | { 160, 2, 5, 3, 0, -4 }, // 0x74 't' 107 | { 162, 3, 3, 4, 0, -2 }, // 0x75 'u' 108 | { 164, 3, 3, 4, 0, -2 }, // 0x76 'v' 109 | { 166, 5, 3, 6, 0, -2 }, // 0x77 'w' 110 | { 168, 3, 3, 4, 0, -2 }, // 0x78 'x' 111 | { 170, 3, 4, 4, 0, -2 }, // 0x79 'y' 112 | { 172, 3, 4, 4, 0, -3 }, // 0x7A 'z' 113 | { 174, 3, 5, 4, 0, -4 }, // 0x7B '{' 114 | { 176, 1, 6, 2, 0, -4 }, // 0x7C '|' 115 | { 177, 3, 5, 4, 0, -4 }, // 0x7D '}' 116 | { 179, 4, 2, 5, 0, -3 } }; // 0x7E '~' 117 | 118 | const GFXfont Picopixel PROGMEM = { 119 | (uint8_t *)PicopixelBitmaps, 120 | (GFXglyph *)PicopixelGlyphs, 121 | 0x20, 0x7E, 7 }; 122 | 123 | // Approx. 852 bytes 124 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/Fonts/Tiny3x3a2pt7b: -------------------------------------------------------------------------------- 1 | /** 2 | ** The FontStruction “Tiny3x3a” 3 | ** (https://fontstruct.com/fontstructions/show/670512) by “Michaelangel007” is 4 | ** licensed under a Creative Commons Attribution Non-commercial Share Alike license 5 | ** (http://creativecommons.org/licenses/by-nc-sa/3.0/). 6 | ** “Tiny3x3a” was originally cloned (copied) from the FontStruction 7 | ** “CHECKER” (https://fontstruct.com/fontstructions/show/2391) by Wolf grant 8 | ** Grant, which is licensed under a Creative Commons Attribution Non-commercial 9 | ** Share Alike license (http://creativecommons.org/licenses/by-nc-sa/3.0/). 10 | * 11 | * Converted by eadmaster with fontconvert 12 | **/ 13 | 14 | const uint8_t Tiny3x3a2pt7bBitmaps[] PROGMEM = { 15 | 0xC0, 0xB4, 0xBF, 0x80, 0x6B, 0x00, 0xDD, 0x80, 0x59, 0x80, 0x80, 0x64, 16 | 0x98, 0xF0, 0x5D, 0x00, 0xC0, 0xE0, 0x80, 0x2A, 0x00, 0x55, 0x00, 0x94, 17 | 0xC9, 0x80, 0xEF, 0x80, 0xBC, 0x80, 0x6B, 0x00, 0x9F, 0x80, 0xE4, 0x80, 18 | 0x7F, 0x00, 0xFC, 0x80, 0xA0, 0x58, 0x64, 0xE3, 0x80, 0x98, 0xD8, 0xD8, 19 | 0x80, 0x5E, 0x80, 0xDF, 0x80, 0x71, 0x80, 0xD7, 0x00, 0xFB, 0x80, 0xFA, 20 | 0x00, 0xD7, 0x80, 0xBE, 0x80, 0xE0, 0x27, 0x00, 0xBA, 0x80, 0x93, 0x80, 21 | 0xFE, 0x80, 0xF6, 0x80, 0xF7, 0x80, 0xFE, 0x00, 0xF7, 0x00, 0xDE, 0x80, 22 | 0x6B, 0x00, 0xE9, 0x00, 0xB7, 0x80, 0xB5, 0x00, 0xBF, 0x80, 0xAA, 0x80, 23 | 0xA9, 0x00, 0xEB, 0x80, 0xEC, 0x88, 0x80, 0xDC, 0x54, 0xE0, 0x90, 0x70, 24 | 0xBC, 0xF0, 0x7C, 0xB0, 0x68, 0xFC, 0xBC, 0xC0, 0x58, 0x9A, 0x80, 0xA4, 25 | 0xDC, 0xD4, 0xF0, 0xF8, 0xF4, 0xE0, 0x60, 0x59, 0x80, 0xBC, 0xA8, 0xEC, 26 | 0xF0, 0xAC, 0x80, 0x90, 0x79, 0x80, 0xF0, 0xCF, 0x00, 0x78 }; 27 | 28 | const GFXglyph Tiny3x3a2pt7bGlyphs[] PROGMEM = { 29 | { 0, 0, 0, 4, 0, 1 }, // 0x20 ' ' 30 | { 0, 1, 2, 3, 1, -2 }, // 0x21 '!' 31 | { 1, 3, 2, 4, 0, -2 }, // 0x22 '"' 32 | { 2, 3, 3, 4, 0, -2 }, // 0x23 '#' 33 | { 4, 3, 3, 4, 0, -2 }, // 0x24 '$' 34 | { 6, 3, 3, 4, 0, -2 }, // 0x25 '%' 35 | { 8, 3, 3, 4, 0, -2 }, // 0x26 '&' 36 | { 10, 1, 1, 3, 1, -2 }, // 0x27 ''' 37 | { 11, 2, 3, 3, 0, -2 }, // 0x28 '(' 38 | { 12, 2, 3, 4, 1, -2 }, // 0x29 ')' 39 | { 13, 2, 2, 4, 1, -2 }, // 0x2A '*' 40 | { 14, 3, 3, 4, 0, -2 }, // 0x2B '+' 41 | { 16, 1, 2, 2, 0, 0 }, // 0x2C ',' 42 | { 17, 3, 1, 4, 0, -1 }, // 0x2D '-' 43 | { 18, 1, 1, 2, 0, 0 }, // 0x2E '.' 44 | { 19, 3, 3, 4, 0, -2 }, // 0x2F '/' 45 | { 21, 3, 3, 4, 0, -2 }, // 0x30 '0' 46 | { 23, 2, 3, 3, 0, -2 }, // 0x31 '1' 47 | { 24, 3, 3, 4, 0, -2 }, // 0x32 '2' 48 | { 26, 3, 3, 4, 0, -2 }, // 0x33 '3' 49 | { 28, 3, 3, 4, 0, -2 }, // 0x34 '4' 50 | { 30, 3, 3, 4, 0, -2 }, // 0x35 '5' 51 | { 32, 3, 3, 4, 0, -2 }, // 0x36 '6' 52 | { 34, 3, 3, 4, 0, -2 }, // 0x37 '7' 53 | { 36, 3, 3, 4, 0, -2 }, // 0x38 '8' 54 | { 38, 3, 3, 4, 0, -2 }, // 0x39 '9' 55 | { 40, 1, 3, 3, 1, -2 }, // 0x3A ':' 56 | { 41, 2, 3, 3, 0, -1 }, // 0x3B ';' 57 | { 42, 2, 3, 3, 0, -2 }, // 0x3C '<' 58 | { 43, 3, 3, 4, 0, -2 }, // 0x3D '=' 59 | { 45, 2, 3, 4, 1, -2 }, // 0x3E '>' 60 | { 46, 2, 3, 4, 1, -2 }, // 0x3F '?' 61 | { 47, 3, 3, 4, 0, -2 }, // 0x40 '@' 62 | { 49, 3, 3, 4, 0, -2 }, // 0x41 'A' 63 | { 51, 3, 3, 4, 0, -2 }, // 0x42 'B' 64 | { 53, 3, 3, 4, 0, -2 }, // 0x43 'C' 65 | { 55, 3, 3, 4, 0, -2 }, // 0x44 'D' 66 | { 57, 3, 3, 4, 0, -2 }, // 0x45 'E' 67 | { 59, 3, 3, 4, 0, -2 }, // 0x46 'F' 68 | { 61, 3, 3, 4, 0, -2 }, // 0x47 'G' 69 | { 63, 3, 3, 4, 0, -2 }, // 0x48 'H' 70 | { 65, 1, 3, 3, 1, -2 }, // 0x49 'I' 71 | { 66, 3, 3, 4, 0, -2 }, // 0x4A 'J' 72 | { 68, 3, 3, 4, 0, -2 }, // 0x4B 'K' 73 | { 70, 3, 3, 4, 0, -2 }, // 0x4C 'L' 74 | { 72, 3, 3, 4, 0, -2 }, // 0x4D 'M' 75 | { 74, 3, 3, 4, 0, -2 }, // 0x4E 'N' 76 | { 76, 3, 3, 4, 0, -2 }, // 0x4F 'O' 77 | { 78, 3, 3, 4, 0, -2 }, // 0x50 'P' 78 | { 80, 3, 3, 4, 0, -2 }, // 0x51 'Q' 79 | { 82, 3, 3, 4, 0, -2 }, // 0x52 'R' 80 | { 84, 3, 3, 4, 0, -2 }, // 0x53 'S' 81 | { 86, 3, 3, 4, 0, -2 }, // 0x54 'T' 82 | { 88, 3, 3, 4, 0, -2 }, // 0x55 'U' 83 | { 90, 3, 3, 4, 0, -2 }, // 0x56 'V' 84 | { 92, 3, 3, 4, 0, -2 }, // 0x57 'W' 85 | { 94, 3, 3, 4, 0, -2 }, // 0x58 'X' 86 | { 96, 3, 3, 4, 0, -2 }, // 0x59 'Y' 87 | { 98, 3, 3, 4, 0, -2 }, // 0x5A 'Z' 88 | { 100, 2, 3, 3, 0, -2 }, // 0x5B '[' 89 | { 101, 3, 3, 4, 0, -2 }, // 0x5C '\' 90 | { 103, 2, 3, 4, 1, -2 }, // 0x5D ']' 91 | { 104, 3, 2, 4, 0, -2 }, // 0x5E '^' 92 | { 105, 3, 1, 4, 0, 0 }, // 0x5F '_' 93 | { 106, 2, 2, 3, 0, -2 }, // 0x60 '`' 94 | { 107, 2, 2, 3, 0, -1 }, // 0x61 'a' 95 | { 108, 2, 3, 3, 0, -2 }, // 0x62 'b' 96 | { 109, 2, 2, 3, 0, -1 }, // 0x63 'c' 97 | { 110, 2, 3, 3, 0, -2 }, // 0x64 'd' 98 | { 111, 2, 2, 3, 0, -1 }, // 0x65 'e' 99 | { 112, 2, 3, 3, 0, -2 }, // 0x66 'f' 100 | { 113, 2, 3, 3, 0, -1 }, // 0x67 'g' 101 | { 114, 2, 3, 3, 0, -2 }, // 0x68 'h' 102 | { 115, 1, 2, 2, 0, -1 }, // 0x69 'i' 103 | { 116, 2, 3, 3, 0, -1 }, // 0x6A 'j' 104 | { 117, 3, 3, 4, 0, -2 }, // 0x6B 'k' 105 | { 119, 2, 3, 3, 0, -2 }, // 0x6C 'l' 106 | { 120, 3, 2, 4, 0, -1 }, // 0x6D 'm' 107 | { 121, 3, 2, 4, 0, -1 }, // 0x6E 'n' 108 | { 122, 2, 2, 3, 0, -1 }, // 0x6F 'o' 109 | { 123, 2, 3, 3, 0, -1 }, // 0x70 'p' 110 | { 124, 2, 3, 3, 0, -1 }, // 0x71 'q' 111 | { 125, 2, 2, 3, 0, -1 }, // 0x72 'r' 112 | { 126, 2, 2, 3, 0, -1 }, // 0x73 's' 113 | { 127, 3, 3, 4, 0, -2 }, // 0x74 't' 114 | { 129, 3, 2, 4, 0, -1 }, // 0x75 'u' 115 | { 130, 3, 2, 4, 0, -1 }, // 0x76 'v' 116 | { 131, 3, 2, 4, 0, -1 }, // 0x77 'w' 117 | { 132, 2, 2, 3, 0, -1 }, // 0x78 'x' 118 | { 133, 3, 3, 4, 0, -1 }, // 0x79 'y' 119 | { 135, 2, 2, 3, 0, -1 }, // 0x7A 'z' 120 | { 136, 3, 3, 4, 0, -2 }, // 0x7B '{' 121 | { 138, 1, 4, 3, 1, -2 }, // 0x7C '|' 122 | { 139, 3, 3, 4, 0, -2 }, // 0x7D '}' 123 | { 141, 3, 2, 4, 0, -2 } }; // 0x7E '~' 124 | 125 | const GFXfont Tiny3x3a2pt7b PROGMEM = { 126 | (uint8_t *)Tiny3x3a2pt7bBitmaps, 127 | (GFXglyph *)Tiny3x3a2pt7bGlyphs, 128 | 0x20, 0x7E, 4 }; 129 | 130 | // Approx. 814 bytes 131 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/Fonts/Org_01.h: -------------------------------------------------------------------------------- 1 | // Org_v01 by Orgdot (www.orgdot.com/aliasfonts). A tiny, 2 | // stylized font with all characters within a 6 pixel height. 3 | 4 | const uint8_t Org_01Bitmaps[] PROGMEM = { 5 | 0xE8, 0xA0, 0x57, 0xD5, 0xF5, 0x00, 0xFD, 0x3E, 0x5F, 0x80, 0x88, 0x88, 6 | 0x88, 0x80, 0xF4, 0xBF, 0x2E, 0x80, 0x80, 0x6A, 0x40, 0x95, 0x80, 0xAA, 7 | 0x80, 0x5D, 0x00, 0xC0, 0xF0, 0x80, 0x08, 0x88, 0x88, 0x00, 0xFC, 0x63, 8 | 0x1F, 0x80, 0xF8, 0xF8, 0x7F, 0x0F, 0x80, 0xF8, 0x7E, 0x1F, 0x80, 0x8C, 9 | 0x7E, 0x10, 0x80, 0xFC, 0x3E, 0x1F, 0x80, 0xFC, 0x3F, 0x1F, 0x80, 0xF8, 10 | 0x42, 0x10, 0x80, 0xFC, 0x7F, 0x1F, 0x80, 0xFC, 0x7E, 0x1F, 0x80, 0x90, 11 | 0xB0, 0x2A, 0x22, 0xF0, 0xF0, 0x88, 0xA8, 0xF8, 0x4E, 0x02, 0x00, 0xFD, 12 | 0x6F, 0x0F, 0x80, 0xFC, 0x7F, 0x18, 0x80, 0xF4, 0x7D, 0x1F, 0x00, 0xFC, 13 | 0x21, 0x0F, 0x80, 0xF4, 0x63, 0x1F, 0x00, 0xFC, 0x3F, 0x0F, 0x80, 0xFC, 14 | 0x3F, 0x08, 0x00, 0xFC, 0x2F, 0x1F, 0x80, 0x8C, 0x7F, 0x18, 0x80, 0xF9, 15 | 0x08, 0x4F, 0x80, 0x78, 0x85, 0x2F, 0x80, 0x8D, 0xB1, 0x68, 0x80, 0x84, 16 | 0x21, 0x0F, 0x80, 0xFD, 0x6B, 0x5A, 0x80, 0xFC, 0x63, 0x18, 0x80, 0xFC, 17 | 0x63, 0x1F, 0x80, 0xFC, 0x7F, 0x08, 0x00, 0xFC, 0x63, 0x3F, 0x80, 0xFC, 18 | 0x7F, 0x29, 0x00, 0xFC, 0x3E, 0x1F, 0x80, 0xF9, 0x08, 0x42, 0x00, 0x8C, 19 | 0x63, 0x1F, 0x80, 0x8C, 0x62, 0xA2, 0x00, 0xAD, 0x6B, 0x5F, 0x80, 0x8A, 20 | 0x88, 0xA8, 0x80, 0x8C, 0x54, 0x42, 0x00, 0xF8, 0x7F, 0x0F, 0x80, 0xEA, 21 | 0xC0, 0x82, 0x08, 0x20, 0x80, 0xD5, 0xC0, 0x54, 0xF8, 0x80, 0xF1, 0xFF, 22 | 0x8F, 0x99, 0xF0, 0xF8, 0x8F, 0x1F, 0x99, 0xF0, 0xFF, 0x8F, 0x6B, 0xA4, 23 | 0xF9, 0x9F, 0x10, 0x8F, 0x99, 0x90, 0xF0, 0x55, 0xC0, 0x8A, 0xF9, 0x90, 24 | 0xF8, 0xFD, 0x63, 0x10, 0xF9, 0x99, 0xF9, 0x9F, 0xF9, 0x9F, 0x80, 0xF9, 25 | 0x9F, 0x20, 0xF8, 0x88, 0x47, 0x1F, 0x27, 0xC8, 0x42, 0x00, 0x99, 0x9F, 26 | 0x99, 0x97, 0x8C, 0x6B, 0xF0, 0x96, 0x69, 0x99, 0x9F, 0x10, 0x2E, 0x8F, 27 | 0x2B, 0x22, 0xF8, 0x89, 0xA8, 0x0F, 0xE0 }; 28 | 29 | const GFXglyph Org_01Glyphs[] PROGMEM = { 30 | { 0, 0, 0, 6, 0, 1 }, // 0x20 ' ' 31 | { 0, 1, 5, 2, 0, -4 }, // 0x21 '!' 32 | { 1, 3, 1, 4, 0, -4 }, // 0x22 '"' 33 | { 2, 5, 5, 6, 0, -4 }, // 0x23 '#' 34 | { 6, 5, 5, 6, 0, -4 }, // 0x24 '$' 35 | { 10, 5, 5, 6, 0, -4 }, // 0x25 '%' 36 | { 14, 5, 5, 6, 0, -4 }, // 0x26 '&' 37 | { 18, 1, 1, 2, 0, -4 }, // 0x27 ''' 38 | { 19, 2, 5, 3, 0, -4 }, // 0x28 '(' 39 | { 21, 2, 5, 3, 0, -4 }, // 0x29 ')' 40 | { 23, 3, 3, 4, 0, -3 }, // 0x2A '*' 41 | { 25, 3, 3, 4, 0, -3 }, // 0x2B '+' 42 | { 27, 1, 2, 2, 0, 0 }, // 0x2C ',' 43 | { 28, 4, 1, 5, 0, -2 }, // 0x2D '-' 44 | { 29, 1, 1, 2, 0, 0 }, // 0x2E '.' 45 | { 30, 5, 5, 6, 0, -4 }, // 0x2F '/' 46 | { 34, 5, 5, 6, 0, -4 }, // 0x30 '0' 47 | { 38, 1, 5, 2, 0, -4 }, // 0x31 '1' 48 | { 39, 5, 5, 6, 0, -4 }, // 0x32 '2' 49 | { 43, 5, 5, 6, 0, -4 }, // 0x33 '3' 50 | { 47, 5, 5, 6, 0, -4 }, // 0x34 '4' 51 | { 51, 5, 5, 6, 0, -4 }, // 0x35 '5' 52 | { 55, 5, 5, 6, 0, -4 }, // 0x36 '6' 53 | { 59, 5, 5, 6, 0, -4 }, // 0x37 '7' 54 | { 63, 5, 5, 6, 0, -4 }, // 0x38 '8' 55 | { 67, 5, 5, 6, 0, -4 }, // 0x39 '9' 56 | { 71, 1, 4, 2, 0, -3 }, // 0x3A ':' 57 | { 72, 1, 4, 2, 0, -3 }, // 0x3B ';' 58 | { 73, 3, 5, 4, 0, -4 }, // 0x3C '<' 59 | { 75, 4, 3, 5, 0, -3 }, // 0x3D '=' 60 | { 77, 3, 5, 4, 0, -4 }, // 0x3E '>' 61 | { 79, 5, 5, 6, 0, -4 }, // 0x3F '?' 62 | { 83, 5, 5, 6, 0, -4 }, // 0x40 '@' 63 | { 87, 5, 5, 6, 0, -4 }, // 0x41 'A' 64 | { 91, 5, 5, 6, 0, -4 }, // 0x42 'B' 65 | { 95, 5, 5, 6, 0, -4 }, // 0x43 'C' 66 | { 99, 5, 5, 6, 0, -4 }, // 0x44 'D' 67 | { 103, 5, 5, 6, 0, -4 }, // 0x45 'E' 68 | { 107, 5, 5, 6, 0, -4 }, // 0x46 'F' 69 | { 111, 5, 5, 6, 0, -4 }, // 0x47 'G' 70 | { 115, 5, 5, 6, 0, -4 }, // 0x48 'H' 71 | { 119, 5, 5, 6, 0, -4 }, // 0x49 'I' 72 | { 123, 5, 5, 6, 0, -4 }, // 0x4A 'J' 73 | { 127, 5, 5, 6, 0, -4 }, // 0x4B 'K' 74 | { 131, 5, 5, 6, 0, -4 }, // 0x4C 'L' 75 | { 135, 5, 5, 6, 0, -4 }, // 0x4D 'M' 76 | { 139, 5, 5, 6, 0, -4 }, // 0x4E 'N' 77 | { 143, 5, 5, 6, 0, -4 }, // 0x4F 'O' 78 | { 147, 5, 5, 6, 0, -4 }, // 0x50 'P' 79 | { 151, 5, 5, 6, 0, -4 }, // 0x51 'Q' 80 | { 155, 5, 5, 6, 0, -4 }, // 0x52 'R' 81 | { 159, 5, 5, 6, 0, -4 }, // 0x53 'S' 82 | { 163, 5, 5, 6, 0, -4 }, // 0x54 'T' 83 | { 167, 5, 5, 6, 0, -4 }, // 0x55 'U' 84 | { 171, 5, 5, 6, 0, -4 }, // 0x56 'V' 85 | { 175, 5, 5, 6, 0, -4 }, // 0x57 'W' 86 | { 179, 5, 5, 6, 0, -4 }, // 0x58 'X' 87 | { 183, 5, 5, 6, 0, -4 }, // 0x59 'Y' 88 | { 187, 5, 5, 6, 0, -4 }, // 0x5A 'Z' 89 | { 191, 2, 5, 3, 0, -4 }, // 0x5B '[' 90 | { 193, 5, 5, 6, 0, -4 }, // 0x5C '\' 91 | { 197, 2, 5, 3, 0, -4 }, // 0x5D ']' 92 | { 199, 3, 2, 4, 0, -4 }, // 0x5E '^' 93 | { 200, 5, 1, 6, 0, 1 }, // 0x5F '_' 94 | { 201, 1, 1, 2, 0, -4 }, // 0x60 '`' 95 | { 202, 4, 4, 5, 0, -3 }, // 0x61 'a' 96 | { 204, 4, 5, 5, 0, -4 }, // 0x62 'b' 97 | { 207, 4, 4, 5, 0, -3 }, // 0x63 'c' 98 | { 209, 4, 5, 5, 0, -4 }, // 0x64 'd' 99 | { 212, 4, 4, 5, 0, -3 }, // 0x65 'e' 100 | { 214, 3, 5, 4, 0, -4 }, // 0x66 'f' 101 | { 216, 4, 5, 5, 0, -3 }, // 0x67 'g' 102 | { 219, 4, 5, 5, 0, -4 }, // 0x68 'h' 103 | { 222, 1, 4, 2, 0, -3 }, // 0x69 'i' 104 | { 223, 2, 5, 3, 0, -3 }, // 0x6A 'j' 105 | { 225, 4, 5, 5, 0, -4 }, // 0x6B 'k' 106 | { 228, 1, 5, 2, 0, -4 }, // 0x6C 'l' 107 | { 229, 5, 4, 6, 0, -3 }, // 0x6D 'm' 108 | { 232, 4, 4, 5, 0, -3 }, // 0x6E 'n' 109 | { 234, 4, 4, 5, 0, -3 }, // 0x6F 'o' 110 | { 236, 4, 5, 5, 0, -3 }, // 0x70 'p' 111 | { 239, 4, 5, 5, 0, -3 }, // 0x71 'q' 112 | { 242, 4, 4, 5, 0, -3 }, // 0x72 'r' 113 | { 244, 4, 4, 5, 0, -3 }, // 0x73 's' 114 | { 246, 5, 5, 6, 0, -4 }, // 0x74 't' 115 | { 250, 4, 4, 5, 0, -3 }, // 0x75 'u' 116 | { 252, 4, 4, 5, 0, -3 }, // 0x76 'v' 117 | { 254, 5, 4, 6, 0, -3 }, // 0x77 'w' 118 | { 257, 4, 4, 5, 0, -3 }, // 0x78 'x' 119 | { 259, 4, 5, 5, 0, -3 }, // 0x79 'y' 120 | { 262, 4, 4, 5, 0, -3 }, // 0x7A 'z' 121 | { 264, 3, 5, 4, 0, -4 }, // 0x7B '{' 122 | { 266, 1, 5, 2, 0, -4 }, // 0x7C '|' 123 | { 267, 3, 5, 4, 0, -4 }, // 0x7D '}' 124 | { 269, 5, 3, 6, 0, -3 } }; // 0x7E '~' 125 | 126 | const GFXfont Org_01 PROGMEM = { 127 | (uint8_t *)Org_01Bitmaps, 128 | (GFXglyph *)Org_01Glyphs, 129 | 0x20, 0x7E, 7 }; 130 | 131 | // Approx. 943 bytes 132 | -------------------------------------------------------------------------------- /components/camera/ov2640_regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * OV2640 register definitions. 7 | */ 8 | #ifndef __REG_REGS_H__ 9 | #define __REG_REGS_H__ 10 | /* DSP register bank FF=0x00*/ 11 | #define R_BYPASS 0x05 12 | #define QS 0x44 13 | #define CTRLI 0x50 14 | #define HSIZE 0x51 15 | #define VSIZE 0x52 16 | #define XOFFL 0x53 17 | #define YOFFL 0x54 18 | #define VHYX 0x55 19 | #define DPRP 0x56 20 | #define TEST 0x57 21 | #define ZMOW 0x5A 22 | #define ZMOH 0x5B 23 | #define ZMHH 0x5C 24 | #define BPADDR 0x7C 25 | #define BPDATA 0x7D 26 | #define CTRL2 0x86 27 | #define CTRL3 0x87 28 | #define SIZEL 0x8C 29 | #define HSIZE8 0xC0 30 | #define VSIZE8 0xC1 31 | #define CTRL0 0xC2 32 | #define CTRL1 0xC3 33 | #define R_DVP_SP 0xD3 34 | #define IMAGE_MODE 0xDA 35 | #define RESET 0xE0 36 | #define MS_SP 0xF0 37 | #define SS_ID 0xF7 38 | #define SS_CTRL 0xF7 39 | #define MC_BIST 0xF9 40 | #define MC_AL 0xFA 41 | #define MC_AH 0xFB 42 | #define MC_D 0xFC 43 | #define P_CMD 0xFD 44 | #define P_STATUS 0xFE 45 | #define BANK_SEL 0xFF 46 | 47 | #define CTRLI_LP_DP 0x80 48 | #define CTRLI_ROUND 0x40 49 | 50 | #define CTRL0_AEC_EN 0x80 51 | #define CTRL0_AEC_SEL 0x40 52 | #define CTRL0_STAT_SEL 0x20 53 | #define CTRL0_VFIRST 0x10 54 | #define CTRL0_YUV422 0x08 55 | #define CTRL0_YUV_EN 0x04 56 | #define CTRL0_RGB_EN 0x02 57 | #define CTRL0_RAW_EN 0x01 58 | 59 | #define CTRL2_DCW_EN 0x20 60 | #define CTRL2_SDE_EN 0x10 61 | #define CTRL2_UV_ADJ_EN 0x08 62 | #define CTRL2_UV_AVG_EN 0x04 63 | #define CTRL2_CMX_EN 0x01 64 | 65 | #define CTRL3_BPC_EN 0x80 66 | #define CTRL3_WPC_EN 0x40 67 | 68 | #define R_DVP_SP_AUTO_MODE 0x80 69 | 70 | #define R_BYPASS_DSP_EN 0x00 71 | #define R_BYPASS_DSP_BYPAS 0x01 72 | 73 | #define IMAGE_MODE_Y8_DVP_EN 0x40 74 | #define IMAGE_MODE_JPEG_EN 0x10 75 | #define IMAGE_MODE_YUV422 0x00 76 | #define IMAGE_MODE_RAW10 0x04 77 | #define IMAGE_MODE_RGB565 0x08 78 | #define IMAGE_MODE_HREF_VSYNC 0x02 79 | #define IMAGE_MODE_LBYTE_FIRST 0x01 80 | 81 | #define RESET_MICROC 0x40 82 | #define RESET_SCCB 0x20 83 | #define RESET_JPEG 0x10 84 | #define RESET_DVP 0x04 85 | #define RESET_IPU 0x02 86 | #define RESET_CIF 0x01 87 | 88 | #define MC_BIST_RESET 0x80 89 | #define MC_BIST_BOOT_ROM_SEL 0x40 90 | #define MC_BIST_12KB_SEL 0x20 91 | #define MC_BIST_12KB_MASK 0x30 92 | #define MC_BIST_512KB_SEL 0x08 93 | #define MC_BIST_512KB_MASK 0x0C 94 | #define MC_BIST_BUSY_BIT_R 0x02 95 | #define MC_BIST_MC_RES_ONE_SH_W 0x02 96 | #define MC_BIST_LAUNCH 0x01 97 | 98 | #define BANK_SEL_DSP 0x00 99 | #define BANK_SEL_SENSOR 0x01 100 | 101 | /* Sensor register bank FF=0x01*/ 102 | #define GAIN 0x00 103 | #define COM1 0x03 104 | #define REG04 0x04 105 | #define REG08 0x08 106 | #define COM2 0x09 107 | #define REG_PID 0x0A 108 | #define REG_VER 0x0B 109 | #define COM3 0x0C 110 | #define COM4 0x0D 111 | #define AEC 0x10 112 | #define CLKRC 0x11 113 | #define COM7 0x12 114 | #define COM8 0x13 115 | #define COM9 0x14 /* AGC gain ceiling */ 116 | #define COM10 0x15 117 | #define HSTART 0x17 118 | #define HSTOP 0x18 119 | #define VSTART 0x19 120 | #define VSTOP 0x1A 121 | #define MIDH 0x1C 122 | #define MIDL 0x1D 123 | #define AEW 0x24 124 | #define AEB 0x25 125 | #define VV 0x26 126 | #define REG2A 0x2A 127 | #define FRARL 0x2B 128 | #define ADDVSL 0x2D 129 | #define ADDVSH 0x2E 130 | #define YAVG 0x2F 131 | #define HSDY 0x30 132 | #define HEDY 0x31 133 | #define REG32 0x32 134 | #define ARCOM2 0x34 135 | #define REG45 0x45 136 | #define FLL 0x46 137 | #define FLH 0x47 138 | #define COM19 0x48 139 | #define ZOOMS 0x49 140 | #define COM22 0x4B 141 | #define COM25 0x4E 142 | #define BD50 0x4F 143 | #define BD60 0x50 144 | #define REG5D 0x5D 145 | #define REG5E 0x5E 146 | #define REG5F 0x5F 147 | #define REG60 0x60 148 | #define HISTO_LOW 0x61 149 | #define HISTO_HIGH 0x62 150 | 151 | #define REG04_DEFAULT 0x28 152 | #define REG04_HFLIP_IMG 0x80 153 | #define REG04_VFLIP_IMG 0x40 154 | #define REG04_VREF_EN 0x10 155 | #define REG04_HREF_EN 0x08 156 | #define REG04_SET(x) (REG04_DEFAULT|x) 157 | 158 | #define COM2_STDBY 0x10 159 | #define COM2_OUT_DRIVE_1x 0x00 160 | #define COM2_OUT_DRIVE_2x 0x01 161 | #define COM2_OUT_DRIVE_3x 0x02 162 | #define COM2_OUT_DRIVE_4x 0x03 163 | 164 | #define COM3_DEFAULT 0x38 165 | #define COM3_BAND_50Hz 0x04 166 | #define COM3_BAND_60Hz 0x00 167 | #define COM3_BAND_AUTO 0x02 168 | #define COM3_BAND_SET(x) (COM3_DEFAULT|x) 169 | 170 | #define COM7_SRST 0x80 171 | #define COM7_RES_UXGA 0x00 /* UXGA */ 172 | #define COM7_RES_SVGA 0x40 /* SVGA */ 173 | #define COM7_RES_CIF 0x20 /* CIF */ 174 | #define COM7_ZOOM_EN 0x04 /* Enable Zoom */ 175 | #define COM7_COLOR_BAR 0x02 /* Enable Color Bar Test */ 176 | 177 | #define COM8_DEFAULT 0xC0 178 | #define COM8_BNDF_EN 0x20 /* Enable Banding filter */ 179 | #define COM8_AGC_EN 0x04 /* AGC Auto/Manual control selection */ 180 | #define COM8_AEC_EN 0x01 /* Auto/Manual Exposure control */ 181 | #define COM8_SET(x) (COM8_DEFAULT|x) 182 | 183 | #define COM9_DEFAULT 0x08 184 | #define COM9_AGC_GAIN_2x 0x00 /* AGC: 2x */ 185 | #define COM9_AGC_GAIN_4x 0x01 /* AGC: 4x */ 186 | #define COM9_AGC_GAIN_8x 0x02 /* AGC: 8x */ 187 | #define COM9_AGC_GAIN_16x 0x03 /* AGC: 16x */ 188 | #define COM9_AGC_GAIN_32x 0x04 /* AGC: 32x */ 189 | #define COM9_AGC_GAIN_64x 0x05 /* AGC: 64x */ 190 | #define COM9_AGC_GAIN_128x 0x06 /* AGC: 128x */ 191 | #define COM9_AGC_SET(x) (COM9_DEFAULT|(x<<5)) 192 | 193 | #define COM10_HREF_EN 0x80 /* HSYNC changes to HREF */ 194 | #define COM10_HSYNC_EN 0x40 /* HREF changes to HSYNC */ 195 | #define COM10_PCLK_FREE 0x20 /* PCLK output option: free running PCLK */ 196 | #define COM10_PCLK_EDGE 0x10 /* Data is updated at the rising edge of PCLK */ 197 | #define COM10_HREF_NEG 0x08 /* HREF negative */ 198 | #define COM10_VSYNC_NEG 0x02 /* VSYNC negative */ 199 | #define COM10_HSYNC_NEG 0x01 /* HSYNC negative */ 200 | 201 | #define CTRL1_AWB 0x08 /* Enable AWB */ 202 | 203 | #define VV_AGC_TH_SET(h,l) ((h<<4)|(l&0x0F)) 204 | 205 | #define REG32_UXGA 0x36 206 | #define REG32_SVGA 0x09 207 | #define REG32_CIF 0x89 208 | 209 | #define CLKRC_2X 0x80 210 | 211 | #endif //__REG_REGS_H__ 212 | -------------------------------------------------------------------------------- /components/lib/include/dl_lib_matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef DL_LIB_MATRIX_H 2 | #define DL_LIB_MATRIX_H 3 | 4 | typedef float fptp_t; 5 | 6 | 7 | //Flags for matrices 8 | #define DL_MF_FOREIGNDATA (1<<0) /*< Matrix *item data actually points to another matrix and should not be freed */ 9 | 10 | //'Normal' float matrix 11 | typedef struct { 12 | int w; /*< Width */ 13 | int h; /*< Height */ 14 | int stride; /*< Row stride, essentially how many items to skip to get to the same position in the next row */ 15 | int flags; /*< Flags. OR of DL_MF_* values */ 16 | fptp_t *item; /*< Pointer to item array */ 17 | } dl_matrix2d_t; 18 | 19 | //Macro to quickly access the raw items in a matrix 20 | #define DL_ITM(m, x, y) m->item[(x)+(y)*m->stride] 21 | 22 | 23 | //#define DL_ITM3D(m, n, x, y, z) (m)->item[(n) * (m)->stride * (m)->c + (z) * (m)->stride + (y) * (m)->w + (x)] 24 | 25 | /** 26 | * @brief Allocate a matrix 27 | * 28 | * @param w Width of the matrix 29 | * @param h Height of the matrix 30 | * @return The matrix, or NULL if out of memory 31 | */ 32 | dl_matrix2d_t *dl_matrix_alloc(int w, int h); 33 | 34 | 35 | /** 36 | * @brief Free a matrix 37 | * Frees the matrix structure and (if it doesn't have the DL_MF_FOREIGNDATA flag set) the m->items space as well. 38 | * 39 | * @param m Matrix to free 40 | */ 41 | void dl_matrix_free(dl_matrix2d_t *m); 42 | 43 | /** 44 | * @brief Zero out the matrix 45 | * Sets all entries in the matrix to 0. 46 | * 47 | * @param m Matrix to zero 48 | */ 49 | void dl_matrix_zero(dl_matrix2d_t *m); 50 | 51 | /** 52 | * @brief Generate a new matrix using a range of items from an existing matrix. 53 | * When using this, the data of the new matrix is not allocated/copied but it re-uses a pointer 54 | * to the existing data. Changing the data in the resulting matrix, as a result, will also change 55 | * the data in the existing matrix that has been sliced. 56 | * 57 | * @param x X-offset of the origin of the returned matrix within the sliced matrix 58 | * @param y Y-offset of the origin of the returned matrix within the sliced matrix 59 | * @param w Width of the resulting matrix 60 | * @param h Height of the resulting matrix 61 | * @param in Old matrix (with foreign data) to re-use. Passing NULL will allocate a new matrix. 62 | * @return The resulting slice matrix, or NULL if out of memory 63 | */ 64 | dl_matrix2d_t *dl_matrix_slice(const dl_matrix2d_t *src, int x, int y, int w, int h, dl_matrix2d_t *in); 65 | 66 | /** 67 | * @brief select a range of items from an existing matrix and flatten them into one dimension. 68 | * 69 | * @Warning The results are flattened in row-major order. 70 | * 71 | * @param x X-offset of the origin of the returned matrix within the sliced matrix 72 | * @param y Y-offset of the origin of the returned matrix within the sliced matrix 73 | * @param w Width of the resulting matrix 74 | * @param h Height of the resulting matrix 75 | * @param in Old matrix to re-use. Passing NULL will allocate a new matrix. 76 | * @return The resulting flatten matrix, or NULL if out of memory 77 | */ 78 | dl_matrix2d_t *dl_matrix_flatten(const dl_matrix2d_t *src, int x, int y, int w, int h, dl_matrix2d_t *in); 79 | 80 | /** 81 | * @brief Generate a matrix from existing floating-point data 82 | * 83 | * @param w Width of resulting matrix 84 | * @param h Height of resulting matrix 85 | * @param data Data to populate matrix with 86 | * @return A newaly allocated matrix populated with the given input data, or NULL if out of memory. 87 | */ 88 | dl_matrix2d_t *dl_matrix_from_data(int w, int h, int stride, const void *data); 89 | 90 | 91 | /** 92 | * @brief Multiply a pair of matrices item-by-item: res=a*b 93 | * 94 | * @param a First multiplicand 95 | * @param b Second multiplicand 96 | * @param res Multiplicated data. Can be equal to a or b to overwrite that. 97 | */ 98 | void dl_matrix_mul(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *res); 99 | 100 | /** 101 | * @brief Do a dotproduct of two matrices : res=a.b 102 | * 103 | * @param a First multiplicand 104 | * @param b Second multiplicand 105 | * @param res Dotproduct data. *Must* be a *different* matrix from a or b! 106 | */ 107 | void dl_matrix_dot(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *res); 108 | 109 | /** 110 | * @brief Add a pair of matrices item-by-item: res=a-b 111 | * 112 | * @param a First matrix 113 | * @param b Second matrix 114 | * @param res Added data. Can be equal to a or b to overwrite that. 115 | */ 116 | void dl_matrix_add(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *out); 117 | 118 | 119 | /** 120 | * @brief Divide a pair of matrices item-by-item: res=a/b 121 | * 122 | * @param a First matrix 123 | * @param b Second matrix 124 | * @param res Divided data. Can be equal to a or b to overwrite that. 125 | */ 126 | void dl_matrix_div(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *out); 127 | 128 | /** 129 | * @brief Subtract a matrix from another, item-by-item: res=a-b 130 | * 131 | * @param a First matrix 132 | * @param b Second matrix 133 | * @param res Subtracted data. Can be equal to a or b to overwrite that. 134 | */ 135 | void dl_matrix_sub(const dl_matrix2d_t *a, const dl_matrix2d_t *b, dl_matrix2d_t *out); 136 | 137 | /** 138 | * @brief Add a constant to every item of the matrix 139 | * 140 | * @param subj Matrix to add the constant to 141 | * @param add The constant 142 | */ 143 | void dl_matrix_add_const(dl_matrix2d_t *subj, const fptp_t add); 144 | 145 | 146 | /** 147 | * @brief Concatenate the rows of two matrices into a new matrix 148 | * 149 | * @param a First matrix 150 | * @param b Second matrix 151 | * @return A newly allocated array with as avlues a|b 152 | */ 153 | dl_matrix2d_t *dl_matrix_concat(const dl_matrix2d_t *a, const dl_matrix2d_t *b); 154 | 155 | 156 | /** 157 | * @brief Print the contents of a matrix to stdout. Used for debugging. 158 | * 159 | * @param a The matrix to print. 160 | */ 161 | void dl_printmatrix(const dl_matrix2d_t *a); 162 | 163 | /** 164 | * @brief Return the average square error given a correct and a test matrix. 165 | * 166 | * ...Well, more or less. If anything, it gives an indication of the error between 167 | * the two. Check the code for the exact implementation. 168 | * 169 | * @param a First of the two matrices to compare 170 | * @param b Second of the two matrices to compare 171 | * @return value indicating the relative difference between matrices 172 | */ 173 | float dl_matrix_get_avg_sq_err(const dl_matrix2d_t *a, const dl_matrix2d_t *b); 174 | 175 | 176 | 177 | /** 178 | * @brief Check if two matrices have the same shape, that is, the same amount of rows and columns 179 | * 180 | * @param a First of the two matrices to compare 181 | * @param b Second of the two matrices to compare 182 | * @return true if the two matrices are shaped the same, false otherwise. 183 | */ 184 | int dl_matrix_same_shape(const dl_matrix2d_t *a, const dl_matrix2d_t *b); 185 | 186 | 187 | /** 188 | * @brief Get a specific item from the matrix 189 | * 190 | * Please use these for external matrix access instead of DL_ITM 191 | * 192 | * @param m Matrix to access 193 | * @param x Column address 194 | * @param y Row address 195 | * @return Value in that position 196 | */ 197 | inline static fptp_t dl_matrix_get(const dl_matrix2d_t *m, const int x, const int y) { 198 | return DL_ITM(m, x, y); 199 | } 200 | 201 | /** 202 | * @brief Set a specific item in the matrix to the given value 203 | * 204 | * Please use these for external matrix access instead of DL_ITM 205 | * 206 | * @param m Matrix to access 207 | * @param x Column address 208 | * @param y Row address 209 | * @param val Value to write to that position 210 | */ 211 | inline static void dl_matrix_set(dl_matrix2d_t *m, const int x, const int y, fptp_t val) { 212 | DL_ITM(m, x, y)=val; 213 | } 214 | 215 | #endif 216 | 217 | -------------------------------------------------------------------------------- /components/camera/ov2640.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * OV2640 driver. 7 | * 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include "sccb.h" 13 | #include "ov2640.h" 14 | #include "ov2640_regs.h" 15 | #include "ov2640_settings.h" 16 | #include "freertos/FreeRTOS.h" 17 | #include "freertos/task.h" 18 | 19 | #if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) 20 | #include "esp32-hal-log.h" 21 | #else 22 | #include "esp_log.h" 23 | static const char* TAG = "ov2640"; 24 | #endif 25 | 26 | static void write_regs(sensor_t *sensor, const uint8_t (*regs)[2]){ 27 | int i=0; 28 | while (regs[i][0]) { 29 | SCCB_Write(sensor->slv_addr, regs[i][0], regs[i][1]); 30 | i++; 31 | } 32 | } 33 | 34 | static int write_reg(sensor_t *sensor, uint8_t bank, uint8_t reg, uint8_t value) 35 | { 36 | int ret=0; 37 | 38 | /* Switch to the given register bank */ 39 | ret |= SCCB_Write(sensor->slv_addr, BANK_SEL, bank); 40 | 41 | /* Write the register value */ 42 | ret |= SCCB_Write(sensor->slv_addr, reg, value); 43 | 44 | return ret; 45 | } 46 | 47 | static int write_reg_bits(sensor_t *sensor, uint8_t bank, uint8_t reg, uint8_t mask, int enable) 48 | { 49 | int ret=0; 50 | uint8_t old; 51 | 52 | /* Switch to SENSOR register bank */ 53 | ret |= SCCB_Write(sensor->slv_addr, BANK_SEL, bank); 54 | 55 | /* Update REG04 */ 56 | old = SCCB_Read(sensor->slv_addr, reg); 57 | 58 | if (enable) { 59 | old |= mask; 60 | } else { 61 | old &= ~mask; 62 | } 63 | 64 | ret |= SCCB_Write(sensor->slv_addr, reg, old); 65 | return ret; 66 | } 67 | 68 | static int write_level_regs(sensor_t *sensor, const uint8_t** regs, uint8_t num_levels, int level) 69 | { 70 | int ret=0; 71 | 72 | level += (num_levels / 2 + 1); 73 | if (level < 0 || level > num_levels) { 74 | return -1; 75 | } 76 | 77 | /* Switch to DSP register bank */ 78 | ret |= SCCB_Write(sensor->slv_addr, BANK_SEL, BANK_SEL_DSP); 79 | 80 | /* Write contrast registers */ 81 | for (int i=0; islv_addr, regs[0][i], regs[level][i]); 83 | } 84 | 85 | return ret; 86 | } 87 | 88 | static int reset(sensor_t *sensor) 89 | { 90 | /* Reset all registers */ 91 | SCCB_Write(sensor->slv_addr, BANK_SEL, BANK_SEL_SENSOR); 92 | SCCB_Write(sensor->slv_addr, COM7, COM7_SRST); 93 | 94 | /* delay n ms */ 95 | vTaskDelay(10 / portTICK_PERIOD_MS); 96 | 97 | /* Write initial registers */ 98 | write_regs(sensor, ov2640_settings_cif); 99 | 100 | return 0; 101 | } 102 | 103 | static int set_framesize(sensor_t *sensor, framesize_t framesize) 104 | { 105 | int ret=0; 106 | uint16_t w = resolution[framesize][0]; 107 | uint16_t h = resolution[framesize][1]; 108 | const uint8_t (*regs)[2]; 109 | 110 | if (framesize <= FRAMESIZE_CIF) { 111 | regs = ov2640_settings_to_cif; 112 | } else if (framesize <= FRAMESIZE_SVGA) { 113 | regs = ov2640_settings_to_svga; 114 | } else { 115 | regs = ov2640_settings_to_uxga; 116 | } 117 | 118 | /* Disable DSP */ 119 | 120 | //ret |= SCCB_Write(sensor->slv_addr, BANK_SEL, BANK_SEL_DSP); 121 | //ret |= SCCB_Write(sensor->slv_addr, R_BYPASS, R_BYPASS_DSP_BYPAS); 122 | 123 | /* Write DSP input regsiters */ 124 | write_regs(sensor, regs); 125 | 126 | /* Write output width */ 127 | ret |= SCCB_Write(sensor->slv_addr, ZMOW, (w>>2)&0xFF); // OUTW[7:0] (real/4) 128 | ret |= SCCB_Write(sensor->slv_addr, ZMOH, (h>>2)&0xFF); // OUTH[7:0] (real/4) 129 | ret |= SCCB_Write(sensor->slv_addr, ZMHH, ((h>>8)&0x04)|((w>>10)&0x03)); // OUTH[8]/OUTW[9:8] 130 | 131 | /* Reset DSP */ 132 | ret |= SCCB_Write(sensor->slv_addr, RESET, 0x00); 133 | 134 | /* Enable DSP */ 135 | //ret |= SCCB_Write(sensor->slv_addr, BANK_SEL, BANK_SEL_DSP); 136 | //ret |= SCCB_Write(sensor->slv_addr, R_BYPASS, R_BYPASS_DSP_EN); 137 | /* delay n ms */ 138 | vTaskDelay(10 / portTICK_PERIOD_MS); 139 | 140 | return ret; 141 | } 142 | 143 | static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) 144 | { 145 | /* read pixel format reg */ 146 | switch (pixformat) { 147 | case PIXFORMAT_RGB565: 148 | write_regs(sensor, ov2640_settings_rgb565); 149 | break; 150 | case PIXFORMAT_YUV422: 151 | case PIXFORMAT_GRAYSCALE: 152 | write_regs(sensor, ov2640_settings_yuv422); 153 | break; 154 | case PIXFORMAT_JPEG: 155 | write_regs(sensor, ov2640_settings_jpeg3); 156 | break; 157 | default: 158 | return -1; 159 | } 160 | 161 | /* delay n ms */ 162 | vTaskDelay(10 / portTICK_PERIOD_MS); 163 | 164 | return 0; 165 | } 166 | 167 | static int set_contrast(sensor_t *sensor, int level) 168 | { 169 | return write_level_regs(sensor, contrast_regs, NUM_CONTRAST_LEVELS, level); 170 | } 171 | 172 | static int set_brightness(sensor_t *sensor, int level) 173 | { 174 | return write_level_regs(sensor, brightness_regs, NUM_BRIGHTNESS_LEVELS, level); 175 | } 176 | 177 | static int set_saturation(sensor_t *sensor, int level) 178 | { 179 | return write_level_regs(sensor, saturation_regs, NUM_SATURATION_LEVELS, level); 180 | } 181 | 182 | static int set_gainceiling(sensor_t *sensor, gainceiling_t gainceiling) 183 | { 184 | return write_reg(sensor, BANK_SEL_SENSOR, COM9, COM9_AGC_SET(gainceiling)); 185 | } 186 | 187 | static int set_quality(sensor_t *sensor, int qs) 188 | { 189 | return write_reg(sensor, BANK_SEL_DSP, QS, qs); 190 | } 191 | 192 | static int set_colorbar(sensor_t *sensor, int enable) 193 | { 194 | return write_reg_bits(sensor, BANK_SEL_SENSOR, COM7, COM7_COLOR_BAR, enable); 195 | } 196 | 197 | static int set_whitebal(sensor_t *sensor, int enable) 198 | { 199 | return write_reg_bits(sensor, BANK_SEL_DSP, CTRL1, CTRL1_AWB, enable); 200 | } 201 | 202 | static int set_gain_ctrl(sensor_t *sensor, int enable) 203 | { 204 | return write_reg_bits(sensor, BANK_SEL_SENSOR, COM8, COM8_AGC_EN, enable); 205 | } 206 | 207 | static int set_exposure_ctrl(sensor_t *sensor, int enable) 208 | { 209 | return write_reg_bits(sensor, BANK_SEL_SENSOR, COM8, COM8_AEC_EN, enable); 210 | } 211 | 212 | static int set_hmirror(sensor_t *sensor, int enable) 213 | { 214 | return write_reg_bits(sensor, BANK_SEL_SENSOR, REG04, REG04_HFLIP_IMG, enable); 215 | } 216 | 217 | static int set_vflip(sensor_t *sensor, int enable) 218 | { 219 | return write_reg_bits(sensor, BANK_SEL_SENSOR, REG04, REG04_VFLIP_IMG, enable); 220 | } 221 | 222 | static int set_framerate(sensor_t *sensor, framerate_t framerate) 223 | { 224 | return 0; 225 | } 226 | 227 | int ov2640_init(sensor_t *sensor) 228 | { 229 | /* set function pointers */ 230 | sensor->reset = reset; 231 | sensor->set_pixformat = set_pixformat; 232 | sensor->set_framesize = set_framesize; 233 | sensor->set_framerate = set_framerate; 234 | sensor->set_contrast = set_contrast; 235 | sensor->set_brightness= set_brightness; 236 | sensor->set_saturation= set_saturation; 237 | sensor->set_gainceiling = set_gainceiling; 238 | sensor->set_quality = set_quality; 239 | sensor->set_colorbar = set_colorbar; 240 | sensor->set_gain_ctrl = set_gain_ctrl; 241 | sensor->set_exposure_ctrl = set_exposure_ctrl; 242 | sensor->set_whitebal = set_whitebal; 243 | sensor->set_hmirror = set_hmirror; 244 | sensor->set_vflip = set_vflip; 245 | 246 | // Set sensor flags 247 | SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_VSYNC, 1); 248 | SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_HSYNC, 0); 249 | SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_PIXCK, 1); 250 | SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 1); 251 | SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_JPEGE, 0); 252 | 253 | return 0; 254 | } 255 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/Adafruit_GFX.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAFRUIT_GFX_H 2 | #define _ADAFRUIT_GFX_H 3 | 4 | #if ARDUINO >= 100 5 | #include "Arduino.h" 6 | #include "Print.h" 7 | #else 8 | #include "WProgram.h" 9 | #endif 10 | #include "gfxfont.h" 11 | 12 | class Adafruit_GFX : public Print { 13 | 14 | public: 15 | 16 | Adafruit_GFX(int16_t w, int16_t h); // Constructor 17 | 18 | // This MUST be defined by the subclass: 19 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; 20 | 21 | // TRANSACTION API / CORE DRAW API 22 | // These MAY be overridden by the subclass to provide device-specific 23 | // optimized code. Otherwise 'generic' versions are used. 24 | virtual void startWrite(void); 25 | virtual void writePixel(int16_t x, int16_t y, uint16_t color); 26 | virtual void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 27 | virtual void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 28 | virtual void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 29 | virtual void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); 30 | virtual void endWrite(void); 31 | 32 | // CONTROL API 33 | // These MAY be overridden by the subclass to provide device-specific 34 | // optimized code. Otherwise 'generic' versions are used. 35 | virtual void setRotation(uint8_t r); 36 | virtual void invertDisplay(boolean i); 37 | 38 | // BASIC DRAW API 39 | // These MAY be overridden by the subclass to provide device-specific 40 | // optimized code. Otherwise 'generic' versions are used. 41 | virtual void 42 | // It's good to implement those, even if using transaction API 43 | drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), 44 | drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), 45 | fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 46 | fillScreen(uint16_t color), 47 | // Optional and probably not necessary to change 48 | drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), 49 | drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 50 | 51 | // These exist only with Adafruit_GFX (no subclass overrides) 52 | void 53 | drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 54 | drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 55 | uint16_t color), 56 | fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 57 | fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 58 | int16_t delta, uint16_t color), 59 | drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 60 | int16_t x2, int16_t y2, uint16_t color), 61 | fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 62 | int16_t x2, int16_t y2, uint16_t color), 63 | drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 64 | int16_t radius, uint16_t color), 65 | fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 66 | int16_t radius, uint16_t color), 67 | drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], 68 | int16_t w, int16_t h, uint16_t color), 69 | drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], 70 | int16_t w, int16_t h, uint16_t color, uint16_t bg), 71 | drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, 72 | int16_t w, int16_t h, uint16_t color), 73 | drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, 74 | int16_t w, int16_t h, uint16_t color, uint16_t bg), 75 | drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[], 76 | int16_t w, int16_t h, uint16_t color), 77 | drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[], 78 | int16_t w, int16_t h), 79 | drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap, 80 | int16_t w, int16_t h), 81 | drawGrayscaleBitmap(int16_t x, int16_t y, 82 | const uint8_t bitmap[], const uint8_t mask[], 83 | int16_t w, int16_t h), 84 | drawGrayscaleBitmap(int16_t x, int16_t y, 85 | uint8_t *bitmap, uint8_t *mask, int16_t w, int16_t h), 86 | drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[], 87 | int16_t w, int16_t h), 88 | drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, 89 | int16_t w, int16_t h), 90 | drawRGBBitmap(int16_t x, int16_t y, 91 | const uint16_t bitmap[], const uint8_t mask[], 92 | int16_t w, int16_t h), 93 | drawRGBBitmap(int16_t x, int16_t y, 94 | uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h), 95 | drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, 96 | uint16_t bg, uint8_t size), 97 | setCursor(int16_t x, int16_t y), 98 | setTextColor(uint16_t c), 99 | setTextColor(uint16_t c, uint16_t bg), 100 | setTextSize(uint8_t s), 101 | setTextWrap(boolean w), 102 | cp437(boolean x=true), 103 | setFont(const GFXfont *f = NULL), 104 | getTextBounds(char *string, int16_t x, int16_t y, 105 | int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h), 106 | getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y, 107 | int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h); 108 | 109 | #if ARDUINO >= 100 110 | virtual size_t write(uint8_t); 111 | #else 112 | virtual void write(uint8_t); 113 | #endif 114 | 115 | int16_t height(void) const; 116 | int16_t width(void) const; 117 | 118 | uint8_t getRotation(void) const; 119 | 120 | // get current cursor position (get rotation safe maximum values, using: width() for x, height() for y) 121 | int16_t getCursorX(void) const; 122 | int16_t getCursorY(void) const; 123 | 124 | protected: 125 | void 126 | charBounds(char c, int16_t *x, int16_t *y, 127 | int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy); 128 | const int16_t 129 | WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes 130 | int16_t 131 | _width, _height, // Display w/h as modified by current rotation 132 | cursor_x, cursor_y; 133 | uint16_t 134 | textcolor, textbgcolor; 135 | uint8_t 136 | textsize, 137 | rotation; 138 | boolean 139 | wrap, // If set, 'wrap' text at right edge of display 140 | _cp437; // If set, use correct CP437 charset (default is off) 141 | GFXfont 142 | *gfxFont; 143 | }; 144 | 145 | class Adafruit_GFX_Button { 146 | 147 | public: 148 | Adafruit_GFX_Button(void); 149 | // "Classic" initButton() uses center & size 150 | void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, 151 | uint16_t w, uint16_t h, uint16_t outline, uint16_t fill, 152 | uint16_t textcolor, char *label, uint8_t textsize); 153 | // New/alt initButton() uses upper-left corner & size 154 | void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1, 155 | uint16_t w, uint16_t h, uint16_t outline, uint16_t fill, 156 | uint16_t textcolor, char *label, uint8_t textsize); 157 | void drawButton(boolean inverted = false); 158 | boolean contains(int16_t x, int16_t y); 159 | 160 | void press(boolean p); 161 | boolean isPressed(); 162 | boolean justPressed(); 163 | boolean justReleased(); 164 | 165 | private: 166 | Adafruit_GFX *_gfx; 167 | int16_t _x1, _y1; // Coordinates of top-left corner 168 | uint16_t _w, _h; 169 | uint8_t _textsize; 170 | uint16_t _outlinecolor, _fillcolor, _textcolor; 171 | char _label[10]; 172 | 173 | boolean currstate, laststate; 174 | }; 175 | 176 | class GFXcanvas1 : public Adafruit_GFX { 177 | public: 178 | GFXcanvas1(uint16_t w, uint16_t h); 179 | ~GFXcanvas1(void); 180 | void drawPixel(int16_t x, int16_t y, uint16_t color), 181 | fillScreen(uint16_t color); 182 | uint8_t *getBuffer(void); 183 | private: 184 | uint8_t *buffer; 185 | }; 186 | 187 | class GFXcanvas8 : public Adafruit_GFX { 188 | public: 189 | GFXcanvas8(uint16_t w, uint16_t h); 190 | ~GFXcanvas8(void); 191 | void drawPixel(int16_t x, int16_t y, uint16_t color), 192 | fillScreen(uint16_t color), 193 | writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 194 | 195 | uint8_t *getBuffer(void); 196 | private: 197 | uint8_t *buffer; 198 | }; 199 | 200 | class GFXcanvas16 : public Adafruit_GFX { 201 | public: 202 | GFXcanvas16(uint16_t w, uint16_t h); 203 | ~GFXcanvas16(void); 204 | void drawPixel(int16_t x, int16_t y, uint16_t color), 205 | fillScreen(uint16_t color); 206 | uint16_t *getBuffer(void); 207 | private: 208 | uint16_t *buffer; 209 | }; 210 | 211 | #endif // _ADAFRUIT_GFX_H 212 | -------------------------------------------------------------------------------- /components/esp_facenet/face_detection/face_detection.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "esp_system.h" 4 | #include "face_detection.h" 5 | 6 | static const char *TAG = "face_detection"; 7 | 8 | box_array_t *pnet_forward(dl_matrix3du_t *image) 9 | {/*{{{*/ 10 | mtmn_net_t *out; 11 | fptp_t scale = 1.0f * MIN_FACE / BOX_LEN; 12 | fptp_t scale_rev = 1.0f * BOX_LEN / MIN_FACE; 13 | image_list_t sorted_list[4] = {NULL}; 14 | image_list_t *origin_head[4] = {NULL}; // store original point to free 15 | image_list_t all_box_list = {NULL}; 16 | box_array_t *pnet_box_list = NULL; 17 | box_t *pnet_box = NULL; 18 | 19 | int width = round(image->w * scale); 20 | int height = round(image->h * scale); 21 | 22 | for (int i = 0; i < 4; i++) 23 | { 24 | if (DL_IMAGE_MIN(width, height) <= MIN_FACE) 25 | break; 26 | 27 | dl_matrix3du_t *in = dl_matrix3du_alloc(1, width, height, image->c); 28 | image_resize_linear(in->item, image->item, width, height, in->c, image->w, image->h); 29 | 30 | out = pnet(in); 31 | 32 | if (out) 33 | { 34 | do 35 | { 36 | origin_head[i] = image_get_valid_boxes(out->category->item, out->offset->item, out->category->w, out->category->h, 0.7, scale_rev); 37 | 38 | dl_matrix3d_free(out->category); 39 | dl_matrix3d_free(out->offset); 40 | dl_matrix3d_free(out->landmark); 41 | free(out); 42 | 43 | if (NULL == origin_head[i]) 44 | break; 45 | 46 | image_sort_insert_by_score(&sorted_list[i], origin_head[i]); 47 | 48 | image_nms_process(&sorted_list[i], 0.5, true); 49 | } while(0); 50 | } 51 | dl_matrix3du_free(in); 52 | 53 | scale *= 0.7; 54 | scale_rev *= 10.0f/7; 55 | width = round(image->w * scale); 56 | height = round(image->h * scale); 57 | } 58 | for (int i = 0; i < 4; i++) 59 | image_sort_insert_by_score(&all_box_list, &sorted_list[i]); 60 | 61 | do 62 | { 63 | image_nms_process(&all_box_list, 0.6, false); 64 | if (0 == all_box_list.len) 65 | break; 66 | 67 | image_calibrate_by_offset(&all_box_list); 68 | 69 | pnet_box_list = (box_array_t *)calloc(1, sizeof(box_array_t)); 70 | pnet_box = (box_t *)calloc(all_box_list.len, sizeof(box_t)); 71 | 72 | image_box_t *t = all_box_list.head; 73 | 74 | // no need to store landmark 75 | for (int i = 0; i < all_box_list.len; i++, t = t->next) 76 | pnet_box[i] = t->box; 77 | 78 | pnet_box_list->box = pnet_box; 79 | pnet_box_list->len = all_box_list.len; 80 | 81 | } while(0); 82 | 83 | for (int i = 0; i < 4; i++) 84 | { 85 | if (origin_head[i]) 86 | { 87 | free(origin_head[i]->origin_head); 88 | free(origin_head[i]); 89 | } 90 | } 91 | return pnet_box_list; 92 | }/*}}}*/ 93 | 94 | box_array_t *ro_net_forward(dl_matrix3du_t *image, box_array_t *net_boxes, net_config_t *config) 95 | {/*{{{*/ 96 | int valid_count = 0; 97 | image_list_t valid_list = {NULL}; 98 | image_list_t sorted_list = {NULL}; 99 | dl_matrix3du_t *resize_image[2]; 100 | image_box_t valid_box[4] = {NULL}; 101 | box_t *net_box = NULL; 102 | landmark_t *net_landmark = NULL; 103 | box_array_t *net_box_list = NULL; 104 | 105 | if (NULL == net_boxes) 106 | return NULL; 107 | 108 | image_rect2sqr(net_boxes, image->w, image->h); 109 | for (int i = 0; i < net_boxes->len; i++) 110 | { 111 | int x = round(net_boxes->box[i].box_p[0]); 112 | int y = round(net_boxes->box[i].box_p[1]); 113 | int w = round(net_boxes->box[i].box_p[2]) - x + 1; 114 | int h = round(net_boxes->box[i].box_p[3]) - y + 1; 115 | resize_image[0] = dl_matrix3du_alloc(1, w, h, image->c); 116 | resize_image[1] = dl_matrix3du_alloc(1, config->w, config->h, image->c); 117 | 118 | dl_matrix3du_slice_copy(resize_image[0], image, x, y, w, h); 119 | 120 | image_resize_linear(resize_image[1]->item, resize_image[0]->item, config->w, config->h, image->c, w, h); 121 | mtmn_net_t *out = NULL; 122 | if (RNET == config->net_type) 123 | { 124 | out = rnet_with_score_verify(resize_image[1], config->score_threshold); 125 | } 126 | else if (ONET == config->net_type) 127 | { 128 | out = onet_with_score_verify(resize_image[1], config->score_threshold); 129 | } 130 | if (out) 131 | { 132 | assert(out->category->stride == 2); 133 | assert(out->offset->stride == 4); 134 | assert(out->offset->c == 4); 135 | valid_box[valid_count].score = out->category->item[1]; 136 | valid_box[valid_count].box = net_boxes->box[i]; 137 | valid_box[valid_count].offset.box_p[0] = out->offset->item[0]; 138 | valid_box[valid_count].offset.box_p[1] = out->offset->item[1]; 139 | valid_box[valid_count].offset.box_p[2] = out->offset->item[2]; 140 | valid_box[valid_count].offset.box_p[3] = out->offset->item[3]; 141 | if (ONET == config->net_type) 142 | { 143 | assert(out->landmark->stride == 10); 144 | memcpy(&(valid_box[valid_count].landmark), out->landmark->item, sizeof(landmark_t)); 145 | } 146 | valid_box[valid_count].next = &(valid_box[valid_count + 1]); 147 | valid_count++; 148 | 149 | dl_matrix3d_free(out->category); 150 | dl_matrix3d_free(out->offset); 151 | dl_matrix3d_free(out->landmark); 152 | free(out); 153 | } 154 | dl_matrix3du_free(resize_image[0]); 155 | dl_matrix3du_free(resize_image[1]); 156 | if (RNET == config->net_type) 157 | { 158 | if (valid_count > 3) 159 | { 160 | break; 161 | } 162 | } 163 | else if (ONET == config->net_type) 164 | { 165 | if (valid_count > MAX_DETECTION - 1) 166 | break; 167 | } 168 | } 169 | valid_box[valid_count - 1].next = NULL; 170 | valid_list.head = valid_box; 171 | valid_list.len = valid_count; 172 | image_sort_insert_by_score(&sorted_list, &valid_list); 173 | 174 | do 175 | { 176 | image_nms_process(&sorted_list, config->nms_threshold, false); 177 | if (0 == sorted_list.len) 178 | break; 179 | 180 | if (ONET == config->net_type) 181 | image_landmark_calibrate(&sorted_list); 182 | image_calibrate_by_offset(&sorted_list); 183 | 184 | 185 | net_box_list = (box_array_t *)calloc(1, sizeof(box_array_t)); 186 | net_box = (box_t *)calloc(sorted_list.len, sizeof(box_t)); 187 | if (ONET == config->net_type) 188 | net_landmark = (landmark_t *)calloc(sorted_list.len, sizeof(landmark_t)); 189 | 190 | image_box_t *t = sorted_list.head; 191 | 192 | for (int i = 0; i < sorted_list.len; i++, t = t->next) 193 | { 194 | net_box[i] = t->box; 195 | if (ONET == config->net_type) 196 | net_landmark[i] = t->landmark; 197 | } 198 | 199 | net_box_list->box = net_box; 200 | net_box_list->landmark = net_landmark; 201 | net_box_list->len = sorted_list.len; 202 | 203 | } while(0); 204 | 205 | return net_box_list; 206 | }/*}}}*/ 207 | 208 | box_array_t *face_detect (dl_matrix3du_t *image_matrix) 209 | {/*{{{*/ 210 | box_array_t *pnet_boxes = pnet_forward(image_matrix); 211 | if (NULL == pnet_boxes) 212 | return NULL; 213 | 214 | net_config_t rnet_config = {0}; 215 | rnet_config.net_type = RNET; 216 | rnet_config.file_name = "rnet_in"; 217 | rnet_config.w = 24; 218 | rnet_config.h = 24; 219 | rnet_config.score_threshold = 0.7; 220 | rnet_config.nms_threshold = 0.7; 221 | 222 | box_array_t *rnet_boxes = ro_net_forward(image_matrix, pnet_boxes, &rnet_config); 223 | 224 | free(pnet_boxes->box); 225 | free(pnet_boxes); 226 | 227 | if (NULL == rnet_boxes) 228 | return NULL; 229 | 230 | net_config_t onet_config = {0}; 231 | onet_config.net_type = ONET; 232 | onet_config.file_name = "onet_in"; 233 | onet_config.w = 48; 234 | onet_config.h = 48; 235 | onet_config.score_threshold = 0.7; 236 | onet_config.nms_threshold = 0.4; 237 | 238 | box_array_t *onet_boxes = ro_net_forward(image_matrix, rnet_boxes, &onet_config); 239 | 240 | free(rnet_boxes->box); 241 | free(rnet_boxes); 242 | 243 | return onet_boxes; 244 | 245 | }/*}}}*/ 246 | 247 | 248 | -------------------------------------------------------------------------------- /components/camera/include/camera.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include "esp_err.h" 18 | #include "driver/ledc.h" 19 | #include "sensor.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | //#define DETECT_BAD_FRAME 26 | 27 | typedef enum { 28 | CAMERA_PF_RGB565 = 0, //!< RGB, 2 bytes per pixel 29 | CAMERA_PF_YUV422 = 1, //!< YUYV, 2 bytes per pixel 30 | CAMERA_PF_GRAYSCALE = 2, //!< 1 byte per pixel 31 | CAMERA_PF_JPEG = 3, //!< JPEG compressed 32 | CAMERA_PF_RGB888 = 4, //!< RGB, 3 bytes per pixel 33 | } camera_pixelformat_t; 34 | 35 | typedef enum { 36 | CAMERA_FS_QQVGA = 4, //!< 160x120 37 | CAMERA_FS_QCIF = 6, //!< 176x144 38 | CAMERA_FS_HQVGA = 7, //!< 240x160 39 | CAMERA_FS_QVGA = 8, //!< 320x240 40 | CAMERA_FS_CIF = 9, //!< 400x296 41 | 42 | CAMERA_FS_VGA = 10, //!< 640x480 43 | CAMERA_FS_SVGA = 11, //!< 800x600 44 | 45 | CAMERA_FS_XGA = 12, //!< 1024x768 46 | CAMERA_FS_SXGA = 13, //!< 1280x1024 47 | CAMERA_FS_UXGA = 14, //!< 1600x1200 48 | } camera_framesize_t; 49 | 50 | typedef enum { 51 | CAMERA_NONE = 0, 52 | CAMERA_UNKNOWN = 1, 53 | CAMERA_OV7725 = 7725, 54 | CAMERA_OV2640 = 2640, 55 | } camera_model_t; 56 | 57 | typedef struct { 58 | int pin_reset; /*!< GPIO pin for camera reset line */ 59 | int pin_xclk; /*!< GPIO pin for camera XCLK line */ 60 | int pin_sscb_sda; /*!< GPIO pin for camera SDA line */ 61 | int pin_sscb_scl; /*!< GPIO pin for camera SCL line */ 62 | int pin_d7; /*!< GPIO pin for camera D7 line */ 63 | int pin_d6; /*!< GPIO pin for camera D6 line */ 64 | int pin_d5; /*!< GPIO pin for camera D5 line */ 65 | int pin_d4; /*!< GPIO pin for camera D4 line */ 66 | int pin_d3; /*!< GPIO pin for camera D3 line */ 67 | int pin_d2; /*!< GPIO pin for camera D2 line */ 68 | int pin_d1; /*!< GPIO pin for camera D1 line */ 69 | int pin_d0; /*!< GPIO pin for camera D0 line */ 70 | int pin_vsync; /*!< GPIO pin for camera VSYNC line */ 71 | int pin_href; /*!< GPIO pin for camera HREF line */ 72 | int pin_pclk; /*!< GPIO pin for camera PCLK line */ 73 | 74 | int xclk_freq_hz; /*!< Frequency of XCLK signal, in Hz. Either 10KHz or 20KHz */ 75 | 76 | ledc_timer_t ledc_timer; /*!< LEDC timer to be used for generating XCLK */ 77 | ledc_channel_t ledc_channel; /*!< LEDC channel to be used for generating XCLK */ 78 | 79 | camera_pixelformat_t pixel_format; /*!< Format of the pixel data: CAMERA_PF_ + YUV422|GRAYSCALE|RGB565|RGB888|JPEG */ 80 | camera_framesize_t frame_size; /*!< Size of the output image: CAMERA_FS_ + QVGA|VGA|SVGA|SXGA|UXGA */ 81 | 82 | int jpeg_quality; /*!< Quality of JPEG output. 0-255 lower means higher quality */ 83 | size_t fb_count; /*!< Number of frame buffers to be allocated. If more than one, then each frame will be acquired (double speed) */ 84 | } camera_config_t; 85 | 86 | typedef struct { 87 | uint8_t * buf; 88 | size_t len; 89 | size_t width; 90 | size_t height; 91 | } camera_fb_t; 92 | 93 | #define ESP_ERR_CAMERA_BASE 0x20000 94 | #define ESP_ERR_CAMERA_NOT_DETECTED (ESP_ERR_CAMERA_BASE + 1) 95 | #define ESP_ERR_CAMERA_FAILED_TO_SET_FRAME_SIZE (ESP_ERR_CAMERA_BASE + 2) 96 | #define ESP_ERR_CAMERA_NOT_SUPPORTED (ESP_ERR_CAMERA_BASE + 3) 97 | 98 | /** 99 | * @brief Probe the camera 100 | * This function enables LEDC peripheral to generate XCLK signal, 101 | * detects the camera I2C address and detects camera model. 102 | * 103 | * @param config camera configuration parameters 104 | * @param[out] out_camera_model output, detected camera model 105 | * @return ESP_OK if camera was detected 106 | */ 107 | esp_err_t camera_probe(const camera_config_t* config, camera_model_t* out_camera_model); 108 | 109 | /** 110 | * @brief Initialize the camera driver 111 | * 112 | * @note call camera_probe before calling this function 113 | * 114 | * This function configures camera over I2C interface, 115 | * allocates framebuffer and DMA buffers, 116 | * initializes parallel I2S input, and sets up DMA descriptors. 117 | * 118 | * Currently this function can only be called once and there is 119 | * no way to de-initialize this module. 120 | * 121 | * @param config Camera configuration parameters 122 | * @return ESP_OK on success 123 | */ 124 | esp_err_t camera_init(const camera_config_t* config); 125 | 126 | /** 127 | * Deinitialize the camera driver 128 | * 129 | * @return 130 | * - ESP_OK on success 131 | * - ESP_ERR_INVALID_STATE if the driver hasn't been initialized yet 132 | */ 133 | esp_err_t camera_deinit(); 134 | 135 | /** 136 | * @brief Obtain pointer to a frame buffer. 137 | * 138 | * @return pointer to the frame buffer 139 | */ 140 | camera_fb_t* camera_get_fb(); 141 | 142 | /** 143 | * @brief Return the frame buffer to be reused again. 144 | * 145 | * @param fb Pointer to the frame buffer 146 | */ 147 | void camera_return_fb(camera_fb_t * fb); 148 | 149 | /** 150 | * @brief Get the current width of the frame, in pixels. 151 | * 152 | * @return width of frame, in pixels 153 | */ 154 | int camera_get_width(); 155 | 156 | /** 157 | * @brief Get the current height of the frame, in pixels. 158 | * 159 | * @return height of frame, in pixels 160 | */ 161 | int camera_get_height(); 162 | 163 | /** 164 | * @brief Get a pointer to the image sensor. 165 | * @return pointer to the sensor 166 | */ 167 | sensor_t * camera_sensor_get(); 168 | 169 | /* 170 | * Example Use 171 | * 172 | static camera_config_t camera_example_config = { 173 | .pin_reset = PIN_RESET, 174 | .pin_xclk = PIN_XCLK, 175 | .pin_sscb_sda = PIN_SIOD, 176 | .pin_sscb_scl = PIN_SIOC, 177 | .pin_d7 = PIN_D7, 178 | .pin_d6 = PIN_D6, 179 | .pin_d5 = PIN_D5, 180 | .pin_d4 = PIN_D4, 181 | .pin_d3 = PIN_D3, 182 | .pin_d2 = PIN_D2, 183 | .pin_d1 = PIN_D1, 184 | .pin_d0 = PIN_D0, 185 | .pin_vsync = PIN_VSYNC, 186 | .pin_href = PIN_HREF, 187 | .pin_pclk = PIN_PCLK, 188 | 189 | .xclk_freq_hz = 20000000, 190 | .ledc_timer = LEDC_TIMER_0, 191 | .ledc_channel = LEDC_CHANNEL_0, 192 | .pixel_format = CAMERA_PF_RGB565,//YUV422,GRAYSCALE,RGB565,JPEG 193 | .frame_size = CAMERA_FS_QVGA, 194 | .jpeg_quality = 12, 195 | .fb_count = 2 196 | }; 197 | 198 | esp_err_t camera_example_init(){ 199 | camera_model_t camera_model = CAMERA_NONE; 200 | esp_err_t err = camera_probe(&camera_example_config, &camera_model); 201 | if (err != ESP_OK) { 202 | ESP_LOGE(TAG, "Camera probe failed with error 0x%x", err); 203 | return err; 204 | } 205 | if (camera_model == CAMERA_OV7725) { 206 | ESP_LOGD(TAG, "Detected OV7725 camera"); 207 | } else if (camera_model == CAMERA_OV2640) { 208 | ESP_LOGD(TAG, "Detected OV2640 camera"); 209 | } else { 210 | ESP_LOGE(TAG, "Camera not supported"); 211 | return ESP_FAIL; 212 | } 213 | err = camera_init(&camera_example_config); 214 | if (err != ESP_OK) { 215 | ESP_LOGE(TAG, "Camera init failed with error 0x%x", err); 216 | return err; 217 | } 218 | return ESP_OK; 219 | } 220 | 221 | esp_err_t camera_example_capture(){ 222 | //capture a frame 223 | camera_fb_t * fb = camera_get_fb(); 224 | if (!fb) { 225 | ESP_LOGE(TAG, "Frame buffer could not be acquired"); 226 | return ESP_FAIL; 227 | } 228 | 229 | //replace this with your own function 230 | display_image(fb->width, fb->height, fb->buf, fb->len); 231 | 232 | //return the frame buffer back to be reused 233 | camera_return_fb(fb); 234 | 235 | return ESP_OK; 236 | } 237 | */ 238 | 239 | 240 | #ifdef __cplusplus 241 | } 242 | #endif 243 | -------------------------------------------------------------------------------- /components/camera/ov7725.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the OpenMV project. 3 | * Copyright (c) 2013/2014 Ibrahim Abdelkader 4 | * This work is licensed under the MIT license, see the file LICENSE for details. 5 | * 6 | * OV7725 driver. 7 | * 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include "sccb.h" 13 | #include "ov7725.h" 14 | #include "ov7725_regs.h" 15 | #include 16 | //#include "esp32-hal.h" 17 | 18 | #define delay(x) 19 | static const uint8_t default_regs[][2] = { 20 | {COM3, COM3_SWAP_YUV}, 21 | {COM7, COM7_RES_QVGA | COM7_FMT_YUV}, 22 | 23 | {COM4, 0x01}, /* bypass PLL */ 24 | {CLKRC, 0xC0}, /* Res/Bypass pre-scalar */ 25 | 26 | // QVGA Window Size 27 | {HSTART, 0x3F}, 28 | {HSIZE, 0x50}, 29 | {VSTART, 0x03}, 30 | {VSIZE, 0x78}, 31 | {HREF, 0x00}, 32 | 33 | // Scale down to QVGA Resolution 34 | {HOUTSIZE, 0x50}, 35 | {VOUTSIZE, 0x78}, 36 | 37 | {COM12, 0x03}, 38 | {EXHCH, 0x00}, 39 | {TGT_B, 0x7F}, 40 | {FIXGAIN, 0x09}, 41 | {AWB_CTRL0, 0xE0}, 42 | {DSP_CTRL1, 0xFF}, 43 | 44 | {DSP_CTRL2, DSP_CTRL2_VDCW_EN | DSP_CTRL2_HDCW_EN | DSP_CTRL2_HZOOM_EN | DSP_CTRL2_VZOOM_EN}, 45 | 46 | {DSP_CTRL3, 0x00}, 47 | {DSP_CTRL4, 0x00}, 48 | {DSPAUTO, 0xFF}, 49 | 50 | {COM8, 0xF0}, 51 | {COM6, 0xC5}, 52 | {COM9, 0x11}, 53 | {COM10, COM10_VSYNC_NEG | COM10_PCLK_MASK}, //Invert VSYNC and MASK PCLK 54 | {BDBASE, 0x7F}, 55 | {DBSTEP, 0x03}, 56 | {AEW, 0x96}, 57 | {AEB, 0x64}, 58 | {VPT, 0xA1}, 59 | {EXHCL, 0x00}, 60 | {AWB_CTRL3, 0xAA}, 61 | {COM8, 0xFF}, 62 | 63 | //Gamma 64 | {GAM1, 0x0C}, 65 | {GAM2, 0x16}, 66 | {GAM3, 0x2A}, 67 | {GAM4, 0x4E}, 68 | {GAM5, 0x61}, 69 | {GAM6, 0x6F}, 70 | {GAM7, 0x7B}, 71 | {GAM8, 0x86}, 72 | {GAM9, 0x8E}, 73 | {GAM10, 0x97}, 74 | {GAM11, 0xA4}, 75 | {GAM12, 0xAF}, 76 | {GAM13, 0xC5}, 77 | {GAM14, 0xD7}, 78 | {GAM15, 0xE8}, 79 | 80 | {SLOP, 0x20}, 81 | {EDGE1, 0x05}, 82 | {EDGE2, 0x03}, 83 | {EDGE3, 0x00}, 84 | {DNSOFF, 0x01}, 85 | 86 | {MTX1, 0xB0}, 87 | {MTX2, 0x9D}, 88 | {MTX3, 0x13}, 89 | {MTX4, 0x16}, 90 | {MTX5, 0x7B}, 91 | {MTX6, 0x91}, 92 | {MTX_CTRL, 0x1E}, 93 | 94 | {BRIGHTNESS, 0x08}, 95 | {CONTRAST, 0x30}, 96 | {UVADJ0, 0x81}, 97 | {SDE, (SDE_CONT_BRIGHT_EN | SDE_SATURATION_EN)}, 98 | 99 | // For 30 fps/60Hz 100 | {DM_LNL, 0x00}, 101 | {DM_LNH, 0x00}, 102 | {BDBASE, 0x7F}, 103 | {DBSTEP, 0x03}, 104 | 105 | // Lens Correction, should be tuned with real camera module 106 | {LC_RADI, 0x10}, 107 | {LC_COEF, 0x10}, 108 | {LC_COEFB, 0x14}, 109 | {LC_COEFR, 0x17}, 110 | {LC_CTR, 0x05}, 111 | {COM5, 0xF5}, //0x65 112 | 113 | {0x00, 0x00}, 114 | }; 115 | 116 | 117 | static int reset(sensor_t *sensor) 118 | { 119 | int i=0; 120 | const uint8_t (*regs)[2]; 121 | 122 | // Reset all registers 123 | SCCB_Write(sensor->slv_addr, COM7, COM7_RESET); 124 | 125 | // Delay 10 ms 126 | delay(10); 127 | 128 | // Write default regsiters 129 | for (i=0, regs = default_regs; regs[i][0]; i++) { 130 | SCCB_Write(sensor->slv_addr, regs[i][0], regs[i][1]); 131 | } 132 | 133 | // Delay 134 | delay(30); 135 | 136 | return 0; 137 | } 138 | 139 | 140 | static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) 141 | { 142 | int ret=0; 143 | // Read register COM7 144 | uint8_t reg = SCCB_Read(sensor->slv_addr, COM7); 145 | 146 | switch (pixformat) { 147 | case PIXFORMAT_RGB565: 148 | reg = COM7_SET_RGB(reg, COM7_FMT_RGB565); 149 | break; 150 | case PIXFORMAT_YUV422: 151 | case PIXFORMAT_GRAYSCALE: 152 | reg = COM7_SET_FMT(reg, COM7_FMT_YUV); 153 | break; 154 | default: 155 | return -1; 156 | } 157 | 158 | // Write back register COM7 159 | ret = SCCB_Write(sensor->slv_addr, COM7, reg); 160 | 161 | // Delay 162 | delay(30); 163 | 164 | return ret; 165 | } 166 | 167 | static int set_framesize(sensor_t *sensor, framesize_t framesize) 168 | { 169 | int ret=0; 170 | uint16_t w = resolution[framesize][0]; 171 | uint16_t h = resolution[framesize][1]; 172 | 173 | // Write MSBs 174 | ret |= SCCB_Write(sensor->slv_addr, HOUTSIZE, w>>2); 175 | ret |= SCCB_Write(sensor->slv_addr, VOUTSIZE, h>>1); 176 | 177 | // Write LSBs 178 | ret |= SCCB_Write(sensor->slv_addr, EXHCH, ((w&0x3) | ((h&0x1) << 2))); 179 | 180 | if (framesize < FRAMESIZE_VGA) { 181 | // Enable auto-scaling/zooming factors 182 | ret |= SCCB_Write(sensor->slv_addr, DSPAUTO, 0xFF); 183 | } else { 184 | // Disable auto-scaling/zooming factors 185 | ret |= SCCB_Write(sensor->slv_addr, DSPAUTO, 0xF3); 186 | 187 | // Clear auto-scaling/zooming factors 188 | ret |= SCCB_Write(sensor->slv_addr, SCAL0, 0x00); 189 | ret |= SCCB_Write(sensor->slv_addr, SCAL1, 0x00); 190 | ret |= SCCB_Write(sensor->slv_addr, SCAL2, 0x00); 191 | } 192 | 193 | // Delay 194 | delay(30); 195 | 196 | if (ret == 0) { 197 | sensor->framesize = framesize; 198 | } 199 | 200 | return ret; 201 | } 202 | 203 | static int set_colorbar(sensor_t *sensor, int enable) 204 | { 205 | int ret=0; 206 | uint8_t reg; 207 | 208 | // Read reg COM3 209 | reg = SCCB_Read(sensor->slv_addr, COM3); 210 | // Enable colorbar test pattern output 211 | reg = COM3_SET_CBAR(reg, enable); 212 | // Write back COM3 213 | ret |= SCCB_Write(sensor->slv_addr, COM3, reg); 214 | 215 | // Read reg DSP_CTRL3 216 | reg = SCCB_Read(sensor->slv_addr, DSP_CTRL3); 217 | // Enable DSP colorbar output 218 | reg = DSP_CTRL3_SET_CBAR(reg, enable); 219 | // Write back DSP_CTRL3 220 | ret |= SCCB_Write(sensor->slv_addr, DSP_CTRL3, reg); 221 | 222 | return ret; 223 | } 224 | 225 | static int set_whitebal(sensor_t *sensor, int enable) 226 | { 227 | // Read register COM8 228 | uint8_t reg = SCCB_Read(sensor->slv_addr, COM8); 229 | 230 | // Set white bal on/off 231 | reg = COM8_SET_AWB(reg, enable); 232 | 233 | // Write back register COM8 234 | return SCCB_Write(sensor->slv_addr, COM8, reg); 235 | } 236 | 237 | static int set_gain_ctrl(sensor_t *sensor, int enable) 238 | { 239 | // Read register COM8 240 | uint8_t reg = SCCB_Read(sensor->slv_addr, COM8); 241 | 242 | // Set white bal on/off 243 | reg = COM8_SET_AGC(reg, enable); 244 | 245 | // Write back register COM8 246 | return SCCB_Write(sensor->slv_addr, COM8, reg); 247 | } 248 | 249 | static int set_exposure_ctrl(sensor_t *sensor, int enable) 250 | { 251 | // Read register COM8 252 | uint8_t reg = SCCB_Read(sensor->slv_addr, COM8); 253 | 254 | // Set white bal on/off 255 | reg = COM8_SET_AEC(reg, enable); 256 | 257 | // Write back register COM8 258 | return SCCB_Write(sensor->slv_addr, COM8, reg); 259 | } 260 | 261 | static int set_hmirror(sensor_t *sensor, int enable) 262 | { 263 | // Read register COM3 264 | uint8_t reg = SCCB_Read(sensor->slv_addr, COM3); 265 | 266 | // Set mirror on/off 267 | reg = COM3_SET_MIRROR(reg, enable); 268 | 269 | // Write back register COM3 270 | return SCCB_Write(sensor->slv_addr, COM3, reg); 271 | } 272 | 273 | static int set_vflip(sensor_t *sensor, int enable) 274 | { 275 | // Read register COM3 276 | uint8_t reg = SCCB_Read(sensor->slv_addr, COM3); 277 | 278 | // Set mirror on/off 279 | reg = COM3_SET_FLIP(reg, enable); 280 | 281 | // Write back register COM3 282 | return SCCB_Write(sensor->slv_addr, COM3, reg); 283 | } 284 | 285 | int ov7725_init(sensor_t *sensor) 286 | { 287 | // Set function pointers 288 | sensor->reset = reset; 289 | sensor->set_pixformat = set_pixformat; 290 | sensor->set_framesize = set_framesize; 291 | sensor->set_colorbar = set_colorbar; 292 | sensor->set_whitebal = set_whitebal; 293 | sensor->set_gain_ctrl = set_gain_ctrl; 294 | sensor->set_exposure_ctrl = set_exposure_ctrl; 295 | sensor->set_hmirror = set_hmirror; 296 | sensor->set_vflip = set_vflip; 297 | 298 | // Retrieve sensor's signature 299 | sensor->id.MIDH = SCCB_Read(sensor->slv_addr, REG_MIDH); 300 | sensor->id.MIDL = SCCB_Read(sensor->slv_addr, REG_MIDL); 301 | sensor->id.PID = SCCB_Read(sensor->slv_addr, REG_PID); 302 | sensor->id.VER = SCCB_Read(sensor->slv_addr, REG_VER); 303 | 304 | // Set sensor flags 305 | SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_VSYNC, 1); 306 | SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_HSYNC, 0); 307 | SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_PIXCK, 1); 308 | SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 1); 309 | SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_JPEGE, 0); 310 | 311 | return 0; 312 | } 313 | -------------------------------------------------------------------------------- /components/lib/include/dl_lib_matrix3d.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef float fptp_t; 4 | typedef uint8_t uc_t; 5 | 6 | typedef enum 7 | { 8 | DL_C_IMPL = 0, 9 | DL_XTENSA_IMPL = 1 10 | } dl_conv_mode; 11 | 12 | typedef enum 13 | { 14 | INPUT_UINT8 = 0, 15 | INPUT_FLOAT = 1, 16 | } dl_op_type; 17 | 18 | typedef enum 19 | { 20 | PADDING_VALID = 0, 21 | PADDING_SAME = 1, 22 | } dl_padding_type; 23 | 24 | /* 25 | * Matrix for 3d 26 | * @Warning: the sequence of variables is fixed, cannot be modified, otherwise there will be errors in esp_dsp_dot_float 27 | */ 28 | typedef struct 29 | { 30 | /******* fix start *******/ 31 | int w; // Width 32 | int h; // Height 33 | int c; // Channel 34 | int n; // Number, to record filter's out_channels. input and output must be 1 35 | int stride; 36 | fptp_t *item; 37 | /******* fix end *******/ 38 | } dl_matrix3d_t; 39 | 40 | typedef struct 41 | { 42 | int w; // Width 43 | int h; // Height 44 | int c; // Channel 45 | int n; // Number, to record filter's out_channels. input and output must be 1 46 | int stride; 47 | uc_t *item; 48 | } dl_matrix3du_t; 49 | 50 | 51 | typedef struct 52 | { 53 | int stride_x; 54 | int stride_y; 55 | dl_padding_type padding; 56 | dl_conv_mode mode; 57 | dl_op_type type; 58 | } dl_matrix3d_conv_config_t; 59 | 60 | /* 61 | * @brief Allocate a 3D matrix with float items, the access sequence is NHWC 62 | * 63 | * @param n Number of matrix3d, for filters it is out channels, for others it is 1 64 | * @param w Width of matrix3d 65 | * @param h Height of matrix3d 66 | * @param c Channel of matrix3d 67 | * @return 3d matrix 68 | */ 69 | dl_matrix3d_t *dl_matrix3d_alloc(int n, int w, int h, int c); 70 | 71 | /* 72 | * @brief Allocate a 3D matrix with 8-bits items, the access sequence is NHWC 73 | * 74 | * @param n Number of matrix3d, for filters it is out channels, for others it is 1 75 | * @param w Width of matrix3d 76 | * @param h Height of matrix3d 77 | * @param c Channel of matrix3d 78 | * @return 3d matrix 79 | */ 80 | dl_matrix3du_t *dl_matrix3du_alloc(int n, int w, int h, int c); 81 | 82 | /* 83 | * @brief Free a matrix3d 84 | * 85 | * @param m matrix3d with float items 86 | */ 87 | void dl_matrix3d_free(dl_matrix3d_t *m); 88 | 89 | /* 90 | * @brief Free a matrix3d 91 | * 92 | * @param m matrix3d with 8-bits items 93 | */ 94 | void dl_matrix3du_free(dl_matrix3du_t *m); 95 | 96 | /** 97 | * @brief Do a relu (Rectifier Linear Unit) operation, update the input matrix3d 98 | * 99 | * @param in Floating point input matrix3d 100 | * @param clip If value is higher than this, it will be clipped to this value 101 | */ 102 | void dl_matrix3d_relu (dl_matrix3d_t *m, fptp_t clip); 103 | 104 | /** 105 | * @brief Do a leaky relu (Rectifier Linear Unit) operation, update the input matrix3d 106 | * 107 | * @param in Floating point input matrix3d 108 | * @param clip If value is higher than this, it will be clipped to this value 109 | * @param alpha If value is less than zero, it will be updated by multiplying this factor 110 | */ 111 | void dl_matrix3d_leaky_relu (dl_matrix3d_t *m, fptp_t clip, fptp_t alpha); 112 | 113 | /** 114 | * @brief Do a softmax operation on a matrix3d 115 | * 116 | * @param in Input matrix3d 117 | */ 118 | void dl_matrix3d_softmax (dl_matrix3d_t *m); 119 | 120 | 121 | /** 122 | * @brief Do a general fully connected layer pass, dimension is (number, width, height, channel) 123 | * 124 | * @param in Input matrix3d, size is (1, w, 1, 1) 125 | * @param filter Weights of the neurons, size is (1, w, h, 1) 126 | * @param bias Bias for the fc layer, size is (1, 1, 1, h) 127 | * @return The result of fc layer, size is (1, 1, 1, h) 128 | */ 129 | dl_matrix3d_t *dl_matrix3d_fc (dl_matrix3d_t *in, dl_matrix3d_t *filter, dl_matrix3d_t *bias); 130 | 131 | 132 | /** 133 | * @brief Copy a range of float items from an existing matrix to a preallocated matrix 134 | * 135 | * @param dst The destination slice matrix 136 | * @param src The source matrix to slice 137 | * @param x X-offset of the origin of the returned matrix within the sliced matrix 138 | * @param y Y-offset of the origin of the returned matrix within the sliced matrix 139 | * @param w Width of the resulting matrix 140 | * @param h Height of the resulting matrix 141 | */ 142 | void dl_matrix3d_slice_copy (dl_matrix3d_t *dst, dl_matrix3d_t *src, int x, int y, int w, int h); 143 | 144 | /** 145 | * @brief Copy a range of 8-bits items from an existing matrix to a preallocated matrix 146 | * 147 | * @param dst The destination slice matrix 148 | * @param src The source matrix to slice 149 | * @param x X-offset of the origin of the returned matrix within the sliced matrix 150 | * @param y Y-offset of the origin of the returned matrix within the sliced matrix 151 | * @param w Width of the resulting matrix 152 | * @param h Height of the resulting matrix 153 | */ 154 | void dl_matrix3du_slice_copy (dl_matrix3du_t *dst, dl_matrix3du_t *src, int x, int y, int w, int h); 155 | 156 | 157 | /** 158 | * @brief Do a general CNN layer pass, dimension is (number, width, height, channel) 159 | * 160 | * @param in Input matrix3d 161 | * @param filter Weights of the neurons 162 | * @param bias Bias for the CNN layer 163 | * @param stride_x The step length of the convolution window in x(width) direction 164 | * @param stride_y The step length of the convolution window in y(height) direction 165 | * @param padding One of VALID or SAME 166 | * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect 167 | * If ESP_PLATFORM is not defined, this value is not used. Default is 0 168 | * @return The result of CNN layer 169 | */ 170 | dl_matrix3d_t *dl_matrix3d_conv (dl_matrix3d_t *in, dl_matrix3d_t *filter, dl_matrix3d_t *bias, 171 | int stride_x, int stride_y, int padding, int mode); 172 | 173 | /** 174 | * @brief Do a general CNN layer pass, dimension is (number, width, height, channel) 175 | * 176 | * @param in Input matrix3d 177 | * @param filter Weights of the neurons 178 | * @param bias Bias for the CNN layer 179 | * @param stride_x The step length of the convolution window in x(width) direction 180 | * @param stride_y The step length of the convolution window in y(height) direction 181 | * @param padding One of VALID or SAME 182 | * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect 183 | * If ESP_PLATFORM is not defined, this value is not used. Default is 0 184 | * @return The result of CNN layer 185 | */ 186 | dl_matrix3d_t *dl_matrix3du_conv (dl_matrix3du_t *in, dl_matrix3d_t *filter, dl_matrix3d_t *bias, 187 | int stride_x, int stride_y, int padding, int mode); 188 | 189 | 190 | /** 191 | * @brief Do a depthwise CNN layer pass, dimension is (number, width, height, channel) 192 | * 193 | * @param in Input matrix3d 194 | * @param filter Weights of the neurons 195 | * @param stride_x The step length of the convolution window in x(width) direction 196 | * @param stride_y The step length of the convolution window in y(height) direction 197 | * @param padding One of VALID or SAME 198 | * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect 199 | * If ESP_PLATFORM is not defined, this value is not used. Default is 0 200 | * @return The result of depthwise CNN layer 201 | */ 202 | dl_matrix3d_t *dl_matrix3d_depthwise_conv (dl_matrix3d_t *in, dl_matrix3d_t *filter, 203 | int stride_x, int stride_y, int padding, int mode); 204 | 205 | /** 206 | * @brief Do a mobilenet block forward, dimension is (number, width, height, channel) 207 | * 208 | * @param in Input matrix3d 209 | * @param filter Weights of the neurons 210 | * @param stride_x The step length of the convolution window in x(width) direction 211 | * @param stride_y The step length of the convolution window in y(height) direction 212 | * @param padding One of VALID or SAME 213 | * @param mode Do convolution using C implement or xtensa implement, 0 or 1, with respect 214 | * If ESP_PLATFORM is not defined, this value is not used. Default is 0 215 | * @return The result of depthwise CNN layer 216 | */ 217 | dl_matrix3d_t *dl_matrix3d_mobilenet (void *in, dl_matrix3d_t *dilate, dl_matrix3d_t *depthwise, 218 | dl_matrix3d_t *compress, dl_matrix3d_t *bias, dl_matrix3d_t *prelu, 219 | dl_matrix3d_conv_config_t *config); 220 | 221 | 222 | /** 223 | * @brief Print the matrix3d items 224 | * 225 | * @param m dl_matrix3d_t to be printed 226 | * @param message name of matrix 227 | */ 228 | void dl_matrix3d_print (dl_matrix3d_t *m, char *message); 229 | 230 | /** 231 | * @brief Print the matrix3du items 232 | * 233 | * @param m dl_matrix3du_t to be printed 234 | * @param message name of matrix 235 | */ 236 | void dl_matrix3du_print (dl_matrix3du_t *m, char *message); 237 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/glcdfont.c: -------------------------------------------------------------------------------- 1 | // This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. 2 | // See gfxfont.h for newer custom bitmap font info. 3 | 4 | #ifndef FONT5X7_H 5 | #define FONT5X7_H 6 | 7 | #ifdef __AVR__ 8 | #include 9 | #include 10 | #elif defined(ESP8266) 11 | #include 12 | #else 13 | #define PROGMEM 14 | #endif 15 | 16 | // Standard ASCII 5x7 font 17 | 18 | static const unsigned char font[] PROGMEM = { 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 20 | 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 21 | 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 22 | 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 23 | 0x18, 0x3C, 0x7E, 0x3C, 0x18, 24 | 0x1C, 0x57, 0x7D, 0x57, 0x1C, 25 | 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 26 | 0x00, 0x18, 0x3C, 0x18, 0x00, 27 | 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 28 | 0x00, 0x18, 0x24, 0x18, 0x00, 29 | 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 30 | 0x30, 0x48, 0x3A, 0x06, 0x0E, 31 | 0x26, 0x29, 0x79, 0x29, 0x26, 32 | 0x40, 0x7F, 0x05, 0x05, 0x07, 33 | 0x40, 0x7F, 0x05, 0x25, 0x3F, 34 | 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 35 | 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 36 | 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 37 | 0x14, 0x22, 0x7F, 0x22, 0x14, 38 | 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 39 | 0x06, 0x09, 0x7F, 0x01, 0x7F, 40 | 0x00, 0x66, 0x89, 0x95, 0x6A, 41 | 0x60, 0x60, 0x60, 0x60, 0x60, 42 | 0x94, 0xA2, 0xFF, 0xA2, 0x94, 43 | 0x08, 0x04, 0x7E, 0x04, 0x08, 44 | 0x10, 0x20, 0x7E, 0x20, 0x10, 45 | 0x08, 0x08, 0x2A, 0x1C, 0x08, 46 | 0x08, 0x1C, 0x2A, 0x08, 0x08, 47 | 0x1E, 0x10, 0x10, 0x10, 0x10, 48 | 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 49 | 0x30, 0x38, 0x3E, 0x38, 0x30, 50 | 0x06, 0x0E, 0x3E, 0x0E, 0x06, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 52 | 0x00, 0x00, 0x5F, 0x00, 0x00, 53 | 0x00, 0x07, 0x00, 0x07, 0x00, 54 | 0x14, 0x7F, 0x14, 0x7F, 0x14, 55 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, 56 | 0x23, 0x13, 0x08, 0x64, 0x62, 57 | 0x36, 0x49, 0x56, 0x20, 0x50, 58 | 0x00, 0x08, 0x07, 0x03, 0x00, 59 | 0x00, 0x1C, 0x22, 0x41, 0x00, 60 | 0x00, 0x41, 0x22, 0x1C, 0x00, 61 | 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 62 | 0x08, 0x08, 0x3E, 0x08, 0x08, 63 | 0x00, 0x80, 0x70, 0x30, 0x00, 64 | 0x08, 0x08, 0x08, 0x08, 0x08, 65 | 0x00, 0x00, 0x60, 0x60, 0x00, 66 | 0x20, 0x10, 0x08, 0x04, 0x02, 67 | 0x3E, 0x51, 0x49, 0x45, 0x3E, 68 | 0x00, 0x42, 0x7F, 0x40, 0x00, 69 | 0x72, 0x49, 0x49, 0x49, 0x46, 70 | 0x21, 0x41, 0x49, 0x4D, 0x33, 71 | 0x18, 0x14, 0x12, 0x7F, 0x10, 72 | 0x27, 0x45, 0x45, 0x45, 0x39, 73 | 0x3C, 0x4A, 0x49, 0x49, 0x31, 74 | 0x41, 0x21, 0x11, 0x09, 0x07, 75 | 0x36, 0x49, 0x49, 0x49, 0x36, 76 | 0x46, 0x49, 0x49, 0x29, 0x1E, 77 | 0x00, 0x00, 0x14, 0x00, 0x00, 78 | 0x00, 0x40, 0x34, 0x00, 0x00, 79 | 0x00, 0x08, 0x14, 0x22, 0x41, 80 | 0x14, 0x14, 0x14, 0x14, 0x14, 81 | 0x00, 0x41, 0x22, 0x14, 0x08, 82 | 0x02, 0x01, 0x59, 0x09, 0x06, 83 | 0x3E, 0x41, 0x5D, 0x59, 0x4E, 84 | 0x7C, 0x12, 0x11, 0x12, 0x7C, 85 | 0x7F, 0x49, 0x49, 0x49, 0x36, 86 | 0x3E, 0x41, 0x41, 0x41, 0x22, 87 | 0x7F, 0x41, 0x41, 0x41, 0x3E, 88 | 0x7F, 0x49, 0x49, 0x49, 0x41, 89 | 0x7F, 0x09, 0x09, 0x09, 0x01, 90 | 0x3E, 0x41, 0x41, 0x51, 0x73, 91 | 0x7F, 0x08, 0x08, 0x08, 0x7F, 92 | 0x00, 0x41, 0x7F, 0x41, 0x00, 93 | 0x20, 0x40, 0x41, 0x3F, 0x01, 94 | 0x7F, 0x08, 0x14, 0x22, 0x41, 95 | 0x7F, 0x40, 0x40, 0x40, 0x40, 96 | 0x7F, 0x02, 0x1C, 0x02, 0x7F, 97 | 0x7F, 0x04, 0x08, 0x10, 0x7F, 98 | 0x3E, 0x41, 0x41, 0x41, 0x3E, 99 | 0x7F, 0x09, 0x09, 0x09, 0x06, 100 | 0x3E, 0x41, 0x51, 0x21, 0x5E, 101 | 0x7F, 0x09, 0x19, 0x29, 0x46, 102 | 0x26, 0x49, 0x49, 0x49, 0x32, 103 | 0x03, 0x01, 0x7F, 0x01, 0x03, 104 | 0x3F, 0x40, 0x40, 0x40, 0x3F, 105 | 0x1F, 0x20, 0x40, 0x20, 0x1F, 106 | 0x3F, 0x40, 0x38, 0x40, 0x3F, 107 | 0x63, 0x14, 0x08, 0x14, 0x63, 108 | 0x03, 0x04, 0x78, 0x04, 0x03, 109 | 0x61, 0x59, 0x49, 0x4D, 0x43, 110 | 0x00, 0x7F, 0x41, 0x41, 0x41, 111 | 0x02, 0x04, 0x08, 0x10, 0x20, 112 | 0x00, 0x41, 0x41, 0x41, 0x7F, 113 | 0x04, 0x02, 0x01, 0x02, 0x04, 114 | 0x40, 0x40, 0x40, 0x40, 0x40, 115 | 0x00, 0x03, 0x07, 0x08, 0x00, 116 | 0x20, 0x54, 0x54, 0x78, 0x40, 117 | 0x7F, 0x28, 0x44, 0x44, 0x38, 118 | 0x38, 0x44, 0x44, 0x44, 0x28, 119 | 0x38, 0x44, 0x44, 0x28, 0x7F, 120 | 0x38, 0x54, 0x54, 0x54, 0x18, 121 | 0x00, 0x08, 0x7E, 0x09, 0x02, 122 | 0x18, 0xA4, 0xA4, 0x9C, 0x78, 123 | 0x7F, 0x08, 0x04, 0x04, 0x78, 124 | 0x00, 0x44, 0x7D, 0x40, 0x00, 125 | 0x20, 0x40, 0x40, 0x3D, 0x00, 126 | 0x7F, 0x10, 0x28, 0x44, 0x00, 127 | 0x00, 0x41, 0x7F, 0x40, 0x00, 128 | 0x7C, 0x04, 0x78, 0x04, 0x78, 129 | 0x7C, 0x08, 0x04, 0x04, 0x78, 130 | 0x38, 0x44, 0x44, 0x44, 0x38, 131 | 0xFC, 0x18, 0x24, 0x24, 0x18, 132 | 0x18, 0x24, 0x24, 0x18, 0xFC, 133 | 0x7C, 0x08, 0x04, 0x04, 0x08, 134 | 0x48, 0x54, 0x54, 0x54, 0x24, 135 | 0x04, 0x04, 0x3F, 0x44, 0x24, 136 | 0x3C, 0x40, 0x40, 0x20, 0x7C, 137 | 0x1C, 0x20, 0x40, 0x20, 0x1C, 138 | 0x3C, 0x40, 0x30, 0x40, 0x3C, 139 | 0x44, 0x28, 0x10, 0x28, 0x44, 140 | 0x4C, 0x90, 0x90, 0x90, 0x7C, 141 | 0x44, 0x64, 0x54, 0x4C, 0x44, 142 | 0x00, 0x08, 0x36, 0x41, 0x00, 143 | 0x00, 0x00, 0x77, 0x00, 0x00, 144 | 0x00, 0x41, 0x36, 0x08, 0x00, 145 | 0x02, 0x01, 0x02, 0x04, 0x02, 146 | 0x3C, 0x26, 0x23, 0x26, 0x3C, 147 | 0x1E, 0xA1, 0xA1, 0x61, 0x12, 148 | 0x3A, 0x40, 0x40, 0x20, 0x7A, 149 | 0x38, 0x54, 0x54, 0x55, 0x59, 150 | 0x21, 0x55, 0x55, 0x79, 0x41, 151 | 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut 152 | 0x21, 0x55, 0x54, 0x78, 0x40, 153 | 0x20, 0x54, 0x55, 0x79, 0x40, 154 | 0x0C, 0x1E, 0x52, 0x72, 0x12, 155 | 0x39, 0x55, 0x55, 0x55, 0x59, 156 | 0x39, 0x54, 0x54, 0x54, 0x59, 157 | 0x39, 0x55, 0x54, 0x54, 0x58, 158 | 0x00, 0x00, 0x45, 0x7C, 0x41, 159 | 0x00, 0x02, 0x45, 0x7D, 0x42, 160 | 0x00, 0x01, 0x45, 0x7C, 0x40, 161 | 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut 162 | 0xF0, 0x28, 0x25, 0x28, 0xF0, 163 | 0x7C, 0x54, 0x55, 0x45, 0x00, 164 | 0x20, 0x54, 0x54, 0x7C, 0x54, 165 | 0x7C, 0x0A, 0x09, 0x7F, 0x49, 166 | 0x32, 0x49, 0x49, 0x49, 0x32, 167 | 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut 168 | 0x32, 0x4A, 0x48, 0x48, 0x30, 169 | 0x3A, 0x41, 0x41, 0x21, 0x7A, 170 | 0x3A, 0x42, 0x40, 0x20, 0x78, 171 | 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 172 | 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut 173 | 0x3D, 0x40, 0x40, 0x40, 0x3D, 174 | 0x3C, 0x24, 0xFF, 0x24, 0x24, 175 | 0x48, 0x7E, 0x49, 0x43, 0x66, 176 | 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 177 | 0xFF, 0x09, 0x29, 0xF6, 0x20, 178 | 0xC0, 0x88, 0x7E, 0x09, 0x03, 179 | 0x20, 0x54, 0x54, 0x79, 0x41, 180 | 0x00, 0x00, 0x44, 0x7D, 0x41, 181 | 0x30, 0x48, 0x48, 0x4A, 0x32, 182 | 0x38, 0x40, 0x40, 0x22, 0x7A, 183 | 0x00, 0x7A, 0x0A, 0x0A, 0x72, 184 | 0x7D, 0x0D, 0x19, 0x31, 0x7D, 185 | 0x26, 0x29, 0x29, 0x2F, 0x28, 186 | 0x26, 0x29, 0x29, 0x29, 0x26, 187 | 0x30, 0x48, 0x4D, 0x40, 0x20, 188 | 0x38, 0x08, 0x08, 0x08, 0x08, 189 | 0x08, 0x08, 0x08, 0x08, 0x38, 190 | 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 191 | 0x2F, 0x10, 0x28, 0x34, 0xFA, 192 | 0x00, 0x00, 0x7B, 0x00, 0x00, 193 | 0x08, 0x14, 0x2A, 0x14, 0x22, 194 | 0x22, 0x14, 0x2A, 0x14, 0x08, 195 | 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code 196 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block 197 | 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block 198 | 0x00, 0x00, 0x00, 0xFF, 0x00, 199 | 0x10, 0x10, 0x10, 0xFF, 0x00, 200 | 0x14, 0x14, 0x14, 0xFF, 0x00, 201 | 0x10, 0x10, 0xFF, 0x00, 0xFF, 202 | 0x10, 0x10, 0xF0, 0x10, 0xF0, 203 | 0x14, 0x14, 0x14, 0xFC, 0x00, 204 | 0x14, 0x14, 0xF7, 0x00, 0xFF, 205 | 0x00, 0x00, 0xFF, 0x00, 0xFF, 206 | 0x14, 0x14, 0xF4, 0x04, 0xFC, 207 | 0x14, 0x14, 0x17, 0x10, 0x1F, 208 | 0x10, 0x10, 0x1F, 0x10, 0x1F, 209 | 0x14, 0x14, 0x14, 0x1F, 0x00, 210 | 0x10, 0x10, 0x10, 0xF0, 0x00, 211 | 0x00, 0x00, 0x00, 0x1F, 0x10, 212 | 0x10, 0x10, 0x10, 0x1F, 0x10, 213 | 0x10, 0x10, 0x10, 0xF0, 0x10, 214 | 0x00, 0x00, 0x00, 0xFF, 0x10, 215 | 0x10, 0x10, 0x10, 0x10, 0x10, 216 | 0x10, 0x10, 0x10, 0xFF, 0x10, 217 | 0x00, 0x00, 0x00, 0xFF, 0x14, 218 | 0x00, 0x00, 0xFF, 0x00, 0xFF, 219 | 0x00, 0x00, 0x1F, 0x10, 0x17, 220 | 0x00, 0x00, 0xFC, 0x04, 0xF4, 221 | 0x14, 0x14, 0x17, 0x10, 0x17, 222 | 0x14, 0x14, 0xF4, 0x04, 0xF4, 223 | 0x00, 0x00, 0xFF, 0x00, 0xF7, 224 | 0x14, 0x14, 0x14, 0x14, 0x14, 225 | 0x14, 0x14, 0xF7, 0x00, 0xF7, 226 | 0x14, 0x14, 0x14, 0x17, 0x14, 227 | 0x10, 0x10, 0x1F, 0x10, 0x1F, 228 | 0x14, 0x14, 0x14, 0xF4, 0x14, 229 | 0x10, 0x10, 0xF0, 0x10, 0xF0, 230 | 0x00, 0x00, 0x1F, 0x10, 0x1F, 231 | 0x00, 0x00, 0x00, 0x1F, 0x14, 232 | 0x00, 0x00, 0x00, 0xFC, 0x14, 233 | 0x00, 0x00, 0xF0, 0x10, 0xF0, 234 | 0x10, 0x10, 0xFF, 0x10, 0xFF, 235 | 0x14, 0x14, 0x14, 0xFF, 0x14, 236 | 0x10, 0x10, 0x10, 0x1F, 0x00, 237 | 0x00, 0x00, 0x00, 0xF0, 0x10, 238 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 239 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 240 | 0xFF, 0xFF, 0xFF, 0x00, 0x00, 241 | 0x00, 0x00, 0x00, 0xFF, 0xFF, 242 | 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 243 | 0x38, 0x44, 0x44, 0x38, 0x44, 244 | 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta 245 | 0x7E, 0x02, 0x02, 0x06, 0x06, 246 | 0x02, 0x7E, 0x02, 0x7E, 0x02, 247 | 0x63, 0x55, 0x49, 0x41, 0x63, 248 | 0x38, 0x44, 0x44, 0x3C, 0x04, 249 | 0x40, 0x7E, 0x20, 0x1E, 0x20, 250 | 0x06, 0x02, 0x7E, 0x02, 0x02, 251 | 0x99, 0xA5, 0xE7, 0xA5, 0x99, 252 | 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 253 | 0x4C, 0x72, 0x01, 0x72, 0x4C, 254 | 0x30, 0x4A, 0x4D, 0x4D, 0x30, 255 | 0x30, 0x48, 0x78, 0x48, 0x30, 256 | 0xBC, 0x62, 0x5A, 0x46, 0x3D, 257 | 0x3E, 0x49, 0x49, 0x49, 0x00, 258 | 0x7E, 0x01, 0x01, 0x01, 0x7E, 259 | 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 260 | 0x44, 0x44, 0x5F, 0x44, 0x44, 261 | 0x40, 0x51, 0x4A, 0x44, 0x40, 262 | 0x40, 0x44, 0x4A, 0x51, 0x40, 263 | 0x00, 0x00, 0xFF, 0x01, 0x03, 264 | 0xE0, 0x80, 0xFF, 0x00, 0x00, 265 | 0x08, 0x08, 0x6B, 0x6B, 0x08, 266 | 0x36, 0x12, 0x36, 0x24, 0x36, 267 | 0x06, 0x0F, 0x09, 0x0F, 0x06, 268 | 0x00, 0x00, 0x18, 0x18, 0x00, 269 | 0x00, 0x00, 0x10, 0x10, 0x00, 270 | 0x30, 0x40, 0xFF, 0x01, 0x01, 271 | 0x00, 0x1F, 0x01, 0x01, 0x1E, 272 | 0x00, 0x19, 0x1D, 0x17, 0x12, 273 | 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 274 | 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP 275 | }; 276 | #endif // FONT5X7_H 277 | -------------------------------------------------------------------------------- /components/lcd/Adafruit-GFX-Library/Adafruit_SPITFT.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is our library for generic SPI TFT Displays with 3 | address windows and 16 bit color (e.g. ILI9341, HX8357D, ST7735...) 4 | 5 | Check out the links above for our tutorials and wiring diagrams 6 | These displays use SPI to communicate, 4 or 5 pins are required to 7 | interface (RST is optional) 8 | Adafruit invests time and resources providing this open source code, 9 | please support Adafruit and open-source hardware by purchasing 10 | products from Adafruit! 11 | 12 | Written by Limor Fried/Ladyada for Adafruit Industries. 13 | MIT license, all text above must be included in any redistribution 14 | ****************************************************/ 15 | 16 | #ifndef __AVR_ATtiny85__ // NOT A CHANCE of this stuff working on ATtiny! 17 | 18 | #include "Adafruit_SPITFT.h" 19 | #ifndef ARDUINO_STM32_FEATHER 20 | #include "pins_arduino.h" 21 | #ifndef RASPI 22 | #include "wiring_private.h" 23 | #endif 24 | #endif 25 | #include 26 | 27 | #include "Adafruit_SPITFT_Macros.h" 28 | 29 | 30 | 31 | // Pass 8-bit (each) R,G,B, get back 16-bit packed color 32 | uint16_t Adafruit_SPITFT::color565(uint8_t r, uint8_t g, uint8_t b) { 33 | return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3); 34 | } 35 | 36 | Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, 37 | int8_t cs, int8_t dc, int8_t mosi, 38 | int8_t sclk, int8_t rst, int8_t miso) 39 | : Adafruit_GFX(w, h) { 40 | _cs = cs; 41 | _dc = dc; 42 | _rst = rst; 43 | _sclk = sclk; 44 | _mosi = mosi; 45 | _miso = miso; 46 | _freq = 0; 47 | #ifdef USE_FAST_PINIO 48 | csport = portOutputRegister(digitalPinToPort(_cs)); 49 | cspinmask = digitalPinToBitMask(_cs); 50 | dcport = portOutputRegister(digitalPinToPort(_dc)); 51 | dcpinmask = digitalPinToBitMask(_dc); 52 | clkport = portOutputRegister(digitalPinToPort(_sclk)); 53 | clkpinmask = digitalPinToBitMask(_sclk); 54 | mosiport = portOutputRegister(digitalPinToPort(_mosi)); 55 | mosipinmask = digitalPinToBitMask(_mosi); 56 | if(miso >= 0){ 57 | misoport = portInputRegister(digitalPinToPort(_miso)); 58 | misopinmask = digitalPinToBitMask(_miso); 59 | } else { 60 | misoport = 0; 61 | misopinmask = 0; 62 | } 63 | #endif 64 | } 65 | 66 | Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, 67 | int8_t cs, int8_t dc, int8_t rst) 68 | : Adafruit_GFX(w, h) { 69 | _cs = cs; 70 | _dc = dc; 71 | _rst = rst; 72 | _sclk = -1; 73 | _mosi = -1; 74 | _miso = -1; 75 | _freq = 0; 76 | #ifdef USE_FAST_PINIO 77 | csport = portOutputRegister(digitalPinToPort(_cs)); 78 | cspinmask = digitalPinToBitMask(_cs); 79 | dcport = portOutputRegister(digitalPinToPort(_dc)); 80 | dcpinmask = digitalPinToBitMask(_dc); 81 | clkport = 0; 82 | clkpinmask = 0; 83 | mosiport = 0; 84 | mosipinmask = 0; 85 | misoport = 0; 86 | misopinmask = 0; 87 | #endif 88 | } 89 | 90 | 91 | void Adafruit_SPITFT::initSPI(uint32_t freq) 92 | { 93 | _freq = freq; 94 | 95 | // Control Pins 96 | pinMode(_dc, OUTPUT); 97 | digitalWrite(_dc, LOW); 98 | pinMode(_cs, OUTPUT); 99 | digitalWrite(_cs, HIGH); 100 | 101 | // Software SPI 102 | if(_sclk >= 0){ 103 | pinMode(_mosi, OUTPUT); 104 | digitalWrite(_mosi, LOW); 105 | pinMode(_sclk, OUTPUT); 106 | digitalWrite(_sclk, HIGH); 107 | if(_miso >= 0){ 108 | pinMode(_miso, INPUT); 109 | } 110 | } 111 | 112 | // Hardware SPI 113 | SPI_BEGIN(); 114 | 115 | // toggle RST low to reset 116 | if (_rst >= 0) { 117 | pinMode(_rst, OUTPUT); 118 | digitalWrite(_rst, HIGH); 119 | delay(100); 120 | digitalWrite(_rst, LOW); 121 | delay(100); 122 | digitalWrite(_rst, HIGH); 123 | delay(200); 124 | } 125 | } 126 | 127 | uint8_t Adafruit_SPITFT::spiRead() { 128 | if(_sclk < 0){ 129 | return HSPI_READ(); 130 | } 131 | if(_miso < 0){ 132 | return 0; 133 | } 134 | uint8_t r = 0; 135 | for (uint8_t i=0; i<8; i++) { 136 | SSPI_SCK_LOW(); 137 | SSPI_SCK_HIGH(); 138 | r <<= 1; 139 | if (SSPI_MISO_READ()){ 140 | r |= 0x1; 141 | } 142 | } 143 | return r; 144 | } 145 | 146 | void Adafruit_SPITFT::spiWrite(uint8_t b) { 147 | if(_sclk < 0){ 148 | HSPI_WRITE(b); 149 | return; 150 | } 151 | for(uint8_t bit = 0x80; bit; bit >>= 1){ 152 | if((b) & bit){ 153 | SSPI_MOSI_HIGH(); 154 | } else { 155 | SSPI_MOSI_LOW(); 156 | } 157 | SSPI_SCK_LOW(); 158 | SSPI_SCK_HIGH(); 159 | } 160 | } 161 | 162 | 163 | /* 164 | * Transaction API 165 | * */ 166 | 167 | void Adafruit_SPITFT::startWrite(void){ 168 | SPI_BEGIN_TRANSACTION(); 169 | SPI_CS_LOW(); 170 | } 171 | 172 | void Adafruit_SPITFT::endWrite(void){ 173 | SPI_CS_HIGH(); 174 | SPI_END_TRANSACTION(); 175 | } 176 | 177 | void Adafruit_SPITFT::writeCommand(uint8_t cmd){ 178 | SPI_DC_LOW(); 179 | spiWrite(cmd); 180 | SPI_DC_HIGH(); 181 | } 182 | 183 | void Adafruit_SPITFT::pushColor(uint16_t color) { 184 | startWrite(); 185 | SPI_WRITE16(color); 186 | endWrite(); 187 | } 188 | 189 | 190 | void Adafruit_SPITFT::writePixel(uint16_t color){ 191 | SPI_WRITE16(color); 192 | } 193 | 194 | void Adafruit_SPITFT::writePixels(uint16_t * colors, uint32_t len){ 195 | SPI_WRITE_PIXELS((uint8_t*)colors , len * 2); 196 | } 197 | 198 | void Adafruit_SPITFT::writeColor(uint16_t color, uint32_t len){ 199 | #ifdef SPI_HAS_WRITE_PIXELS 200 | if(_sclk >= 0){ 201 | for (uint32_t t=0; t SPI_MAX_PIXELS_AT_ONCE)?SPI_MAX_PIXELS_AT_ONCE:len; 208 | uint16_t tlen = 0; 209 | 210 | for (uint32_t t=0; tblen)?blen:len; 216 | writePixels(temp, tlen); 217 | len -= tlen; 218 | } 219 | #else 220 | uint8_t hi = color >> 8, lo = color; 221 | if(_sclk < 0){ //AVR Optimization 222 | for (uint32_t t=len; t; t--){ 223 | HSPI_WRITE(hi); 224 | HSPI_WRITE(lo); 225 | } 226 | return; 227 | } 228 | for (uint32_t t=len; t; t--){ 229 | spiWrite(hi); 230 | spiWrite(lo); 231 | } 232 | #endif 233 | } 234 | 235 | void Adafruit_SPITFT::writePixel(int16_t x, int16_t y, uint16_t color) { 236 | if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) return; 237 | setAddrWindow(x,y,1,1); 238 | writePixel(color); 239 | } 240 | 241 | void Adafruit_SPITFT::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color){ 242 | if((x >= _width) || (y >= _height)) return; 243 | int16_t x2 = x + w - 1, y2 = y + h - 1; 244 | if((x2 < 0) || (y2 < 0)) return; 245 | 246 | // Clip left/top 247 | if(x < 0) { 248 | x = 0; 249 | w = x2 + 1; 250 | } 251 | if(y < 0) { 252 | y = 0; 253 | h = y2 + 1; 254 | } 255 | 256 | // Clip right/bottom 257 | if(x2 >= _width) w = _width - x; 258 | if(y2 >= _height) h = _height - y; 259 | 260 | int32_t len = (int32_t)w * h; 261 | setAddrWindow(x, y, w, h); 262 | writeColor(color, len); 263 | } 264 | 265 | void Adafruit_SPITFT::writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color){ 266 | writeFillRect(x, y, 1, h, color); 267 | } 268 | 269 | void Adafruit_SPITFT::writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color){ 270 | writeFillRect(x, y, w, 1, color); 271 | } 272 | 273 | void Adafruit_SPITFT::drawPixel(int16_t x, int16_t y, uint16_t color){ 274 | startWrite(); 275 | writePixel(x, y, color); 276 | endWrite(); 277 | } 278 | 279 | void Adafruit_SPITFT::drawFastVLine(int16_t x, int16_t y, 280 | int16_t h, uint16_t color) { 281 | startWrite(); 282 | writeFastVLine(x, y, h, color); 283 | endWrite(); 284 | } 285 | 286 | void Adafruit_SPITFT::drawFastHLine(int16_t x, int16_t y, 287 | int16_t w, uint16_t color) { 288 | startWrite(); 289 | writeFastHLine(x, y, w, color); 290 | endWrite(); 291 | } 292 | 293 | void Adafruit_SPITFT::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, 294 | uint16_t color) { 295 | startWrite(); 296 | writeFillRect(x,y,w,h,color); 297 | endWrite(); 298 | } 299 | 300 | // Adapted from https://github.com/PaulStoffregen/ILI9341_t3 301 | // by Marc MERLIN. See examples/pictureEmbed to use this. 302 | // 5/6/2017: function name and arguments have changed for compatibility 303 | // with current GFX library and to avoid naming problems in prior 304 | // implementation. Formerly drawBitmap() with arguments in different order. 305 | void Adafruit_SPITFT::drawRGBBitmap(int16_t x, int16_t y, 306 | uint16_t *pcolors, int16_t w, int16_t h) { 307 | 308 | int16_t x2, y2; // Lower-right coord 309 | if(( x >= _width ) || // Off-edge right 310 | ( y >= _height) || // " top 311 | ((x2 = (x+w-1)) < 0 ) || // " left 312 | ((y2 = (y+h-1)) < 0) ) return; // " bottom 313 | 314 | int16_t bx1=0, by1=0, // Clipped top-left within bitmap 315 | saveW=w; // Save original bitmap width value 316 | if(x < 0) { // Clip left 317 | w += x; 318 | bx1 = -x; 319 | x = 0; 320 | } 321 | if(y < 0) { // Clip top 322 | h += y; 323 | by1 = -y; 324 | y = 0; 325 | } 326 | if(x2 >= _width ) w = _width - x; // Clip right 327 | if(y2 >= _height) h = _height - y; // Clip bottom 328 | 329 | pcolors += by1 * saveW + bx1; // Offset bitmap ptr to clipped top-left 330 | startWrite(); 331 | setAddrWindow(x, y, w, h); // Clipped area 332 | while(h--) { // For each (clipped) scanline... 333 | writePixels(pcolors, w); // Push one (clipped) row 334 | pcolors += saveW; // Advance pointer by one full (unclipped) line 335 | } 336 | endWrite(); 337 | } 338 | 339 | #endif // !__AVR_ATtiny85__ 340 | -------------------------------------------------------------------------------- /components/esp_facenet/mtmn/mtmn.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "mtmn.h" 4 | #include "pnet_model.h" 5 | #include "rnet_model.h" 6 | #include "onet_model.h" 7 | #include "freertos/FreeRTOS.h" 8 | 9 | static int first_time[3] = {0}; 10 | mtmn_net_t *pnet (dl_matrix3du_t *in) 11 | { 12 | #define PNET_LAYER_NUM (3) 13 | static dl_matrix3d_t *filters[PNET_LAYER_NUM * 4] = {0}; 14 | char name[50]; 15 | 16 | // Get filters 17 | if (0 == first_time[0]) 18 | { 19 | first_time[0] = 1; 20 | for (int i = 0; i < PNET_LAYER_NUM; i++) 21 | { 22 | sprintf(name, "pnet_l%d_dilate", i+1); 23 | filters[i * 4 + 0] = (dl_matrix3d_t *)get_coeff_pnet_model.getter_3d(name, NULL, 0); 24 | sprintf(name, "pnet_l%d_depth", i+1); 25 | filters[i * 4 + 1] = (dl_matrix3d_t *)get_coeff_pnet_model.getter_3d(name, NULL, 0); 26 | sprintf(name, "pnet_l%d_compress", i+1); 27 | filters[i * 4 + 2] = (dl_matrix3d_t *)get_coeff_pnet_model.getter_3d(name, NULL, 0); 28 | sprintf(name, "pnet_l%d_bias", i+1); 29 | filters[i * 4 + 3] = (dl_matrix3d_t *)get_coeff_pnet_model.getter_3d(name, NULL, 0); 30 | } 31 | } 32 | dl_matrix3d_t **l1_f = &(filters[0]); 33 | dl_matrix3d_t **l2_f = &(filters[4]); 34 | dl_matrix3d_t **l3_f = &(filters[8]); 35 | 36 | dl_matrix3d_t *l4_category_conv = (dl_matrix3d_t *)get_coeff_pnet_model.getter_3d("pnet_l4_category_weight", NULL, 0); 37 | dl_matrix3d_t *l4_category_bias = (dl_matrix3d_t *)get_coeff_pnet_model.getter_3d("pnet_l4_category_bias", NULL, 0); 38 | dl_matrix3d_t *l4_offset_conv = (dl_matrix3d_t *)get_coeff_pnet_model.getter_3d("pnet_l4_offset_weight", NULL, 0); 39 | dl_matrix3d_t *l4_offset_bias = (dl_matrix3d_t *)get_coeff_pnet_model.getter_3d("pnet_l4_offset_bias", NULL, 0); 40 | 41 | // Layer 1 42 | dl_matrix3d_conv_config_t config; 43 | config.stride_x = 2; 44 | config.stride_y = 2; 45 | config.padding = PADDING_VALID; 46 | config.mode = DL_XTENSA_IMPL; 47 | config.type = INPUT_UINT8; 48 | dl_matrix3d_t *l1 = dl_matrix3d_mobilenet(in, l1_f[0], l1_f[1], l1_f[2], l1_f[3], NULL, &config); 49 | 50 | // Layer 2 51 | config.stride_x = 1; 52 | config.stride_y = 1; 53 | config.type = INPUT_FLOAT; 54 | dl_matrix3d_t *l2 = dl_matrix3d_mobilenet(l1, l2_f[0], l2_f[1], l2_f[2], l2_f[3], NULL, &config); 55 | 56 | // Layer 3 57 | dl_matrix3d_t *l3 = dl_matrix3d_mobilenet(l2, l3_f[0], l3_f[1], l3_f[2], l3_f[3], NULL, &config); 58 | 59 | mtmn_net_t *pnet_o = (mtmn_net_t *)calloc(1, sizeof(mtmn_net_t)); 60 | // Layer 4 category 61 | pnet_o->category = dl_matrix3d_conv(l3, l4_category_conv, l4_category_bias, 1, 1, 0, 1); 62 | dl_matrix3d_softmax(pnet_o->category); 63 | 64 | // Layer 4 boxoffset 65 | pnet_o->offset = dl_matrix3d_conv(l3, l4_offset_conv, l4_offset_bias, 1, 1, 0, 1); 66 | 67 | dl_matrix3d_free(l1); 68 | dl_matrix3d_free(l2); 69 | dl_matrix3d_free(l3); 70 | 71 | return pnet_o; 72 | } 73 | 74 | 75 | 76 | mtmn_net_t *rnet_with_score_verify(dl_matrix3du_t *in, float score_threshold) 77 | { 78 | #define RNET_LAYER_NUM (4) 79 | static dl_matrix3d_t *filters[RNET_LAYER_NUM * 4]; 80 | char name[50]; 81 | 82 | // Get filters 83 | if (0 == first_time[1]) 84 | { 85 | first_time[1] = 1; 86 | for (int i = 0; i < RNET_LAYER_NUM; i++) 87 | { 88 | sprintf(name, "rnet_l%d_dilate", i+1); 89 | filters[i * 4 + 0] = (dl_matrix3d_t *)get_coeff_rnet_model.getter_3d(name, NULL, 0); 90 | sprintf(name, "rnet_l%d_depth", i+1); 91 | filters[i * 4 + 1] = (dl_matrix3d_t *)get_coeff_rnet_model.getter_3d(name, NULL, 0); 92 | sprintf(name, "rnet_l%d_compress", i+1); 93 | filters[i * 4 + 2] = (dl_matrix3d_t *)get_coeff_rnet_model.getter_3d(name, NULL, 0); 94 | sprintf(name, "rnet_l%d_bias", i+1); 95 | filters[i * 4 + 3] = (dl_matrix3d_t *)get_coeff_rnet_model.getter_3d(name, NULL, 0); 96 | } 97 | } 98 | 99 | dl_matrix3d_t **l1_f = &(filters[0]); 100 | dl_matrix3d_t **l2_f = &(filters[4]); 101 | dl_matrix3d_t **l3_f = &(filters[8]); 102 | dl_matrix3d_t **l4_f = &(filters[12]); 103 | 104 | dl_matrix3d_t *l5_category_fc = (dl_matrix3d_t *)get_coeff_rnet_model.getter_3d("rnet_l5_category_weight", NULL, 0); 105 | dl_matrix3d_t *l5_category_bias = (dl_matrix3d_t *)get_coeff_rnet_model.getter_3d("rnet_l5_category_bias", NULL, 0); 106 | dl_matrix3d_t *l5_offset_fc = (dl_matrix3d_t *)get_coeff_rnet_model.getter_3d("rnet_l5_offset_weight", NULL, 0); 107 | dl_matrix3d_t *l5_offset_bias = (dl_matrix3d_t *)get_coeff_rnet_model.getter_3d("rnet_l5_offset_bias", NULL, 0); 108 | 109 | // Layer 1 110 | dl_matrix3d_conv_config_t config; 111 | config.stride_x = 2; 112 | config.stride_y = 2; 113 | config.padding = PADDING_VALID; 114 | config.mode = DL_XTENSA_IMPL; 115 | config.type = INPUT_UINT8; 116 | dl_matrix3d_t *l1 = dl_matrix3d_mobilenet(in, l1_f[0], l1_f[1], l1_f[2], l1_f[3], NULL, &config); 117 | 118 | // Layer 2 119 | config.type = INPUT_FLOAT; 120 | dl_matrix3d_t *l2 = dl_matrix3d_mobilenet(l1, l2_f[0], l2_f[1], l2_f[2], l2_f[3], NULL, &config); 121 | 122 | // Layer 3 123 | config.stride_x = 1; 124 | config.stride_y = 1; 125 | dl_matrix3d_t *l3 = dl_matrix3d_mobilenet(l2, l3_f[0], l3_f[1], l3_f[2], l3_f[3], NULL, &config); 126 | 127 | // Layer 4 128 | dl_matrix3d_t *l4 = dl_matrix3d_mobilenet(l3, l4_f[0], l4_f[1], l4_f[2], l4_f[3], NULL, &config); 129 | 130 | mtmn_net_t *rnet_o = (mtmn_net_t *)calloc(1, sizeof(mtmn_net_t)); 131 | 132 | // Layer 5 category 133 | rnet_o->category = dl_matrix3d_fc(l4, l5_category_fc, l5_category_bias); 134 | dl_matrix3d_softmax(rnet_o->category); 135 | 136 | if (rnet_o->category->item[1] < score_threshold) 137 | { 138 | dl_matrix3d_free(rnet_o->category); 139 | free(rnet_o); 140 | rnet_o = NULL; 141 | goto rnet_exit; 142 | } 143 | // Layer 5 boxoffset 144 | rnet_o->offset = dl_matrix3d_fc(l4, l5_offset_fc, l5_offset_bias); 145 | 146 | rnet_exit: 147 | dl_matrix3d_free(l1); 148 | dl_matrix3d_free(l2); 149 | dl_matrix3d_free(l3); 150 | dl_matrix3d_free(l4); 151 | 152 | return rnet_o; 153 | } 154 | 155 | mtmn_net_t *onet_with_score_verify(dl_matrix3du_t *in, float score_threshold) 156 | { 157 | #define ONET_LAYER_NUM (5) 158 | #define ONET_COEF_PER_LAYER (5) 159 | dl_matrix3d_t *filters[ONET_LAYER_NUM * ONET_COEF_PER_LAYER]; 160 | char name[50]; 161 | 162 | // Get filters 163 | for (int i = 0; i < ONET_LAYER_NUM; i++) 164 | { 165 | sprintf(name, "onet_l%d_dilate", i+1); 166 | filters[i * ONET_COEF_PER_LAYER + 0] = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d(name, NULL, 0); 167 | sprintf(name, "onet_l%d_depth", i+1); 168 | filters[i * ONET_COEF_PER_LAYER + 1] = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d(name, NULL, 0); 169 | sprintf(name, "onet_l%d_compress", i+1); 170 | filters[i * ONET_COEF_PER_LAYER + 2] = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d(name, NULL, 0); 171 | sprintf(name, "onet_l%d_bias", i+1); 172 | filters[i * ONET_COEF_PER_LAYER + 3] = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d(name, NULL, 0); 173 | sprintf(name, "onet_l%d_prelu_alpha", i+1); 174 | filters[i * ONET_COEF_PER_LAYER + 4] = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d(name, NULL, 0); 175 | } 176 | 177 | dl_matrix3d_t **l1_f = &(filters[ONET_COEF_PER_LAYER * 0]); 178 | dl_matrix3d_t **l2_f = &(filters[ONET_COEF_PER_LAYER * 1]); 179 | dl_matrix3d_t **l3_f = &(filters[ONET_COEF_PER_LAYER * 2]); 180 | dl_matrix3d_t **l4_f = &(filters[ONET_COEF_PER_LAYER * 3]); 181 | dl_matrix3d_t **l5_f = &(filters[ONET_COEF_PER_LAYER * 4]); 182 | 183 | dl_matrix3d_t *l6_category_fc = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d("onet_l6_category_weight", NULL, 0); 184 | dl_matrix3d_t *l6_category_bias = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d("onet_l6_category_bias", NULL, 0); 185 | dl_matrix3d_t *l6_offset_fc = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d("onet_l6_offset_weight", NULL, 0); 186 | dl_matrix3d_t *l6_offset_bias = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d("onet_l6_offset_bias", NULL, 0); 187 | dl_matrix3d_t *l6_landmark_fc = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d("onet_l6_landmark_weight", NULL, 0); 188 | dl_matrix3d_t *l6_landmark_bias = (dl_matrix3d_t *)get_coeff_onet_model.getter_3d("onet_l6_landmark_bias", NULL, 0); 189 | 190 | // Layer 1 191 | dl_matrix3d_conv_config_t config; 192 | config.stride_x = 2; 193 | config.stride_y = 2; 194 | config.padding = PADDING_VALID; 195 | config.mode = DL_C_IMPL; 196 | config.type = INPUT_UINT8; 197 | 198 | dl_matrix3d_t *l1 = dl_matrix3d_mobilenet(in, l1_f[0], l1_f[1], l1_f[2], l1_f[3], l1_f[4], &config); 199 | 200 | // Layer 2 201 | config.type = INPUT_FLOAT; 202 | dl_matrix3d_t *l2 = dl_matrix3d_mobilenet(l1, l2_f[0], l2_f[1], l2_f[2], l2_f[3], l2_f[4], &config); 203 | 204 | // Layer 3 205 | dl_matrix3d_t *l3 = dl_matrix3d_mobilenet(l2, l3_f[0], l3_f[1], l3_f[2], l3_f[3], l3_f[4], &config); 206 | 207 | // Layer 4 208 | config.stride_x = 1; 209 | config.stride_y = 1; 210 | dl_matrix3d_t *l4 = dl_matrix3d_mobilenet(l3, l4_f[0], l4_f[1], l4_f[2], l4_f[3], l4_f[4], &config); 211 | 212 | // Layer 5 213 | dl_matrix3d_t *l5 = dl_matrix3d_mobilenet(l4, l5_f[0], l5_f[1], l5_f[2], l5_f[3], l5_f[4], &config); 214 | 215 | mtmn_net_t *onet_o = (mtmn_net_t *)calloc(1, sizeof(mtmn_net_t)); 216 | 217 | // Layer 6 category 218 | onet_o->category = dl_matrix3d_fc(l5, l6_category_fc, l6_category_bias); 219 | dl_matrix3d_softmax(onet_o->category); 220 | if (onet_o->category->item[1] < score_threshold) 221 | { 222 | dl_matrix3d_free(onet_o->category); 223 | free(onet_o); 224 | onet_o = NULL; 225 | goto onet_exit; 226 | } 227 | 228 | // Layer 6 boxoffset 229 | onet_o->offset = dl_matrix3d_fc(l5, l6_offset_fc, l6_offset_bias); 230 | 231 | // Layer 6 landmark 232 | onet_o->landmark = dl_matrix3d_fc(l5, l6_landmark_fc, l6_landmark_bias); 233 | 234 | 235 | onet_exit: 236 | dl_matrix3d_free(l1); 237 | dl_matrix3d_free(l2); 238 | dl_matrix3d_free(l3); 239 | dl_matrix3d_free(l4); 240 | dl_matrix3d_free(l5); 241 | 242 | return onet_o; 243 | } 244 | 245 | --------------------------------------------------------------------------------