Merge pull request #1136 from kwagyeman/kwabena/update_tv_driver

Kwabena/update tv driver
This commit is contained in:
Ibrahim Abd Elkader 2021-01-23 23:13:47 +02:00 committed by GitHub
commit d13dd3fb7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 1018 additions and 562 deletions

View File

@ -1,15 +1,23 @@
# TV Example # TV Example
# #
# Note: To run this example you will need a wireless tv shield for your OpenMV Cam. # Note: To run this example you will need a tv or wireless tv shield for your OpenMV Cam.
# #
# The wireless video tv Shield allows you to view your OpenMV Cam's frame buffer on the go. # The wireless video tv Shield allows you to view your OpenMV Cam's frame buffer on the go.
#
# The TV Shield's resolution is 352x240 (SIF). By default display output is not buffered.
# You may enable triple buffering at the cost of 372 KB to make display updates non-blocking.
import sensor, image, tv import sensor, image, tv, time
sensor.reset() # Initialize the camera sensor. sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QQVGA) sensor.set_framesize(sensor.SIF)
tv.init() # Initialize the tv. clock = time.clock()
tv.init(triple_buffer=False) # Initialize the tv.
tv.channel(8) # For wireless video transmitter shield tv.channel(8) # For wireless video transmitter shield
while(True): while(True):
clock.tick()
tv.display(sensor.snapshot()) # Take a picture and display the image. tv.display(sensor.snapshot()) # Take a picture and display the image.
print(clock.fps())

View File

@ -248,6 +248,10 @@
#define OMV_SPI_LCD_MOSI_PORT (GPIOB) #define OMV_SPI_LCD_MOSI_PORT (GPIOB)
#define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_MISO_PIN (GPIO_PIN_14)
#define OMV_SPI_LCD_MISO_PORT (GPIOB)
#define OMV_SPI_LCD_MISO_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_13) #define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_13)
#define OMV_SPI_LCD_SCLK_PORT (GPIOB) #define OMV_SPI_LCD_SCLK_PORT (GPIOB)
#define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2)

View File

@ -249,6 +249,10 @@
#define OMV_SPI_LCD_MOSI_PORT (GPIOB) #define OMV_SPI_LCD_MOSI_PORT (GPIOB)
#define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_MISO_PIN (GPIO_PIN_14)
#define OMV_SPI_LCD_MISO_PORT (GPIOB)
#define OMV_SPI_LCD_MISO_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_13) #define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_13)
#define OMV_SPI_LCD_SCLK_PORT (GPIOB) #define OMV_SPI_LCD_SCLK_PORT (GPIOB)
#define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2)

View File

@ -364,6 +364,10 @@
#define OMV_SPI_LCD_MOSI_PORT (GPIOB) #define OMV_SPI_LCD_MOSI_PORT (GPIOB)
#define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_MISO_PIN (GPIO_PIN_14)
#define OMV_SPI_LCD_MISO_PORT (GPIOB)
#define OMV_SPI_LCD_MISO_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_13) #define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_13)
#define OMV_SPI_LCD_SCLK_PORT (GPIOB) #define OMV_SPI_LCD_SCLK_PORT (GPIOB)
#define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2)

View File

@ -402,6 +402,10 @@
#define OMV_SPI_LCD_MOSI_PORT (GPIOB) #define OMV_SPI_LCD_MOSI_PORT (GPIOB)
#define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_MISO_PIN (GPIO_PIN_14)
#define OMV_SPI_LCD_MISO_PORT (GPIOB)
#define OMV_SPI_LCD_MISO_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_13) #define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_13)
#define OMV_SPI_LCD_SCLK_PORT (GPIOB) #define OMV_SPI_LCD_SCLK_PORT (GPIOB)
#define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2)

View File

@ -487,6 +487,10 @@
#define OMV_SPI_LCD_MOSI_PORT (GPIOB) #define OMV_SPI_LCD_MOSI_PORT (GPIOB)
#define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_MISO_PIN (GPIO_PIN_14)
#define OMV_SPI_LCD_MISO_PORT (GPIOB)
#define OMV_SPI_LCD_MISO_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_13) #define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_13)
#define OMV_SPI_LCD_SCLK_PORT (GPIOB) #define OMV_SPI_LCD_SCLK_PORT (GPIOB)
#define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2)

View File

@ -351,6 +351,10 @@
#define OMV_SPI_LCD_MOSI_PORT (GPIOC) #define OMV_SPI_LCD_MOSI_PORT (GPIOC)
#define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_MOSI_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_MISO_PIN (GPIO_PIN_2)
#define OMV_SPI_LCD_MISO_PORT (GPIOC)
#define OMV_SPI_LCD_MISO_ALT (GPIO_AF5_SPI2)
#define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_1) #define OMV_SPI_LCD_SCLK_PIN (GPIO_PIN_1)
#define OMV_SPI_LCD_SCLK_PORT (GPIOI) #define OMV_SPI_LCD_SCLK_PORT (GPIOI)
#define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2) #define OMV_SPI_LCD_SCLK_ALT (GPIO_AF5_SPI2)

View File

@ -429,26 +429,6 @@ int8_t imlib_rgb565_to_b(uint16_t pixel)
return fast_floorf(200 * (y-z)); return fast_floorf(200 * (y-z));
} }
int8_t imlib_rgb565_to_u(uint16_t pixel)
{
int r = COLOR_RGB565_TO_R8(pixel);
int g = COLOR_RGB565_TO_G8(pixel);
int b = COLOR_RGB565_TO_B8(pixel);
return (int8_t)(((b << 14) - (r * 5529) - (g * 10855)) >> 15); // -0.168736*r + -0.331264*g + 0.5*b
// return fast_floorf((r * -0.168736f) + (g * -0.331264f) + (b * +0.500000f));
}
int8_t imlib_rgb565_to_v(uint16_t pixel)
{
int r = COLOR_RGB565_TO_R8(pixel);
int g = COLOR_RGB565_TO_G8(pixel);
int b = COLOR_RGB565_TO_B8(pixel);
return (int8_t)(((r << 14) - (g * 13682) - (b * 2664)) >> 15); // 0.5*r + -0.418688*g + -0.081312*b
// return fast_floorf((r * +0.500000f) + (g * -0.418688f) + (b * -0.081312f));
}
// https://en.wikipedia.org/wiki/Lab_color_space -> CIELAB-CIEXYZ conversions // https://en.wikipedia.org/wiki/Lab_color_space -> CIELAB-CIEXYZ conversions
// https://en.wikipedia.org/wiki/SRGB -> Specification of the transformation // https://en.wikipedia.org/wiki/SRGB -> Specification of the transformation
uint16_t imlib_lab_to_rgb(uint8_t l, int8_t a, int8_t b) uint16_t imlib_lab_to_rgb(uint8_t l, int8_t a, int8_t b)

View File

@ -274,6 +274,26 @@ color_thresholds_list_lnk_data_t;
(__rb_pixel * 0x0801) + ((__pixel << 3) & 0x7E0); \ (__rb_pixel * 0x0801) + ((__pixel << 3) & 0x7E0); \
}) })
#define COLOR_RGB888_TO_U(r8, g8, b8) ((((r8) * -21) - ((g8) * 43) + ((b8) * 64)) >> 7) // -0.168736R - 0.331264G + 0.5B
#define COLOR_RGB565_TO_U(rgb565) \
({ \
__typeof__ (rgb565) __rgb565 = (rgb565); \
int r = COLOR_RGB565_TO_R8(__rgb565); \
int g = COLOR_RGB565_TO_G8(__rgb565); \
int b = COLOR_RGB565_TO_B8(__rgb565); \
COLOR_RGB888_TO_U(r, g, b); \
})
#define COLOR_RGB888_TO_V(r8, g8, b8) ((((r8) * 64) - ((g8) * 54) - ((b8) * 10)) >> 7) // 0.5R - 0.418688G - 0.081312B
#define COLOR_RGB565_TO_V(rgb565) \
({ \
__typeof__ (rgb565) __rgb565 = (rgb565); \
int r = COLOR_RGB565_TO_R8(__rgb565); \
int g = COLOR_RGB565_TO_G8(__rgb565); \
int b = COLOR_RGB565_TO_B8(__rgb565); \
COLOR_RGB888_TO_V(r, g, b); \
})
extern const int8_t lab_table[196608/2]; extern const int8_t lab_table[196608/2];
extern const int8_t yuv_table[196608]; extern const int8_t yuv_table[196608];
@ -287,14 +307,6 @@ extern const int8_t yuv_table[196608];
#define COLOR_RGB565_TO_B(pixel) imlib_rgb565_to_b(pixel) #define COLOR_RGB565_TO_B(pixel) imlib_rgb565_to_b(pixel)
#endif #endif
#ifdef IMLIB_ENABLE_YUV_LUT
#define COLOR_RGB565_TO_U(pixel) yuv_table[((pixel) * 3) + 1]
#define COLOR_RGB565_TO_V(pixel) yuv_table[((pixel) * 3) + 2]
#else
#define COLOR_RGB565_TO_U(pixel) imlib_rgb565_to_u(pixel)
#define COLOR_RGB565_TO_V(pixel) imlib_rgb565_to_v(pixel)
#endif
#define COLOR_LAB_TO_RGB565(l, a, b) imlib_lab_to_rgb(l, a, b) #define COLOR_LAB_TO_RGB565(l, a, b) imlib_lab_to_rgb(l, a, b)
#define COLOR_YUV_TO_RGB565(y, u, v) imlib_yuv_to_rgb((y) + 128, u, v) #define COLOR_YUV_TO_RGB565(y, u, v) imlib_yuv_to_rgb((y) + 128, u, v)
@ -1039,9 +1051,6 @@ void imlib_fill_image_from_float(image_t *img, int w, int h, float *data, float
int8_t imlib_rgb565_to_l(uint16_t pixel); int8_t imlib_rgb565_to_l(uint16_t pixel);
int8_t imlib_rgb565_to_a(uint16_t pixel); int8_t imlib_rgb565_to_a(uint16_t pixel);
int8_t imlib_rgb565_to_b(uint16_t pixel); int8_t imlib_rgb565_to_b(uint16_t pixel);
int8_t imlib_rgb565_to_y(uint16_t pixel);
int8_t imlib_rgb565_to_u(uint16_t pixel);
int8_t imlib_rgb565_to_v(uint16_t pixel);
uint16_t imlib_lab_to_rgb(uint8_t l, int8_t a, int8_t b); uint16_t imlib_lab_to_rgb(uint8_t l, int8_t a, int8_t b);
uint16_t imlib_yuv_to_rgb(uint8_t y, int8_t u, int8_t v); uint16_t imlib_yuv_to_rgb(uint8_t y, int8_t u, int8_t v);
void imlib_bayer_to_rgb565(image_t *img, int w, int h, int xoffs, int yoffs, uint16_t *rgbbuf); void imlib_bayer_to_rgb565(image_t *img, int w, int h, int xoffs, int yoffs, uint16_t *rgbbuf);

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,9 @@
/* /*
* This file is part of the OpenMV project. * This file is part of the OpenMV project.
* *
* Copyright (c) 2013-2019 Ibrahim Abdelkader <iabdalkader@openmv.io> * Copyright (c) 2013-2020 Ibrahim Abdelkader <iabdalkader@openmv.io>
* Copyright (c) 2013-2019 Kwabena W. Agyeman <kwagyeman@openmv.io> * Copyright (c) 2013-2020 Kwabena W. Agyeman <kwagyeman@openmv.io>
* Copyright (c) 2013-2020 Kaizhi Wong <kidswong999@gmail.com>
* *
* This work is licensed under the MIT license, see the file LICENSE for details. * This work is licensed under the MIT license, see the file LICENSE for details.
* *