mirror of
https://gitcode.com/gh_mirrors/es/esp32-opencv.git
synced 2025-08-06 18:24:38 +08:00
Rotated the displayed image because camera is in the back of the TTGO
This commit is contained in:
@ -237,10 +237,8 @@ static UINT tjd_output(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ESP_LOGI(TAG, "x1:%d y1:%d x2:%d y2:%d\n", dleft, dtop, dright, dbottom);
|
//ESP_LOGI(TAG, "x1:%d x2:%d y1:%d y2:%d\n", dleft, dright, dtop, dbottom);
|
||||||
tft->transmitCmdData(LCD_CASET, MAKEWORD(dleft >> 8, dleft & 0xFF, dright >> 8, dright & 0xFF));
|
tft->setAddrWindow(dleft, dtop, dright, dbottom);
|
||||||
tft->transmitCmdData(LCD_PASET, MAKEWORD(dtop >> 8, dtop & 0xFF, dbottom >> 8, dbottom & 0xFF));
|
|
||||||
tft->transmitCmd(LCD_RAMWR); // write to RAM
|
|
||||||
|
|
||||||
uint16_t *p = (uint16_t *)malloc(sizeof(uint16_t) * len);
|
uint16_t *p = (uint16_t *)malloc(sizeof(uint16_t) * len);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
@ -250,7 +248,7 @@ static UINT tjd_output(
|
|||||||
for (uint32_t i = 0; i < len; i++) {
|
for (uint32_t i = 0; i < len; i++) {
|
||||||
p[i] = tft->color565(dev->linbuf[dev->linbuf_idx][i].r, dev->linbuf[dev->linbuf_idx][i].g, dev->linbuf[dev->linbuf_idx][i].b);
|
p[i] = tft->color565(dev->linbuf[dev->linbuf_idx][i].r, dev->linbuf[dev->linbuf_idx][i].g, dev->linbuf[dev->linbuf_idx][i].b);
|
||||||
}
|
}
|
||||||
tft->_fastSendBuf(p, len);
|
tft->_fastSendBuf(p, len, true); // TODO: Swapping bytes directly in the camera register could enhance display
|
||||||
free(p);
|
free(p);
|
||||||
|
|
||||||
dev->linbuf_idx = ((dev->linbuf_idx + 1) & 1);
|
dev->linbuf_idx = ((dev->linbuf_idx + 1) & 1);
|
||||||
@ -450,7 +448,7 @@ void lvgl_lcd_hal_init()
|
|||||||
|
|
||||||
/*screen initialize*/
|
/*screen initialize*/
|
||||||
tft->invertDisplay(true);
|
tft->invertDisplay(true);
|
||||||
tft->setRotation(0);
|
tft->setRotation(2); // rotation needed if camera is on the back of the device
|
||||||
tft->fillScreen(COLOR_BLACK);
|
tft->fillScreen(COLOR_BLACK);
|
||||||
|
|
||||||
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
|
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
|
||||||
|
@ -41,17 +41,20 @@ void demo_task(void *arg) {
|
|||||||
disp_infos();
|
disp_infos();
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
auto start = esp_timer_get_time();
|
||||||
|
|
||||||
camera_fb_t *fb = esp_camera_fb_get();
|
camera_fb_t *fb = esp_camera_fb_get();
|
||||||
|
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
ESP_LOGE(TAG, "Camera capture failed");
|
ESP_LOGE(TAG, "Camera capture failed");
|
||||||
} else {
|
} else {
|
||||||
TFT_jpg_image(CENTER, 0, 0, -1, NULL, fb->buf, fb->len);
|
TFT_jpg_image(CENTER, CENTER, 0, -1, NULL, fb->buf, fb->len);
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(fb);
|
||||||
fb = NULL;
|
fb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "time taken: %lld ms", (esp_timer_get_time() - start) / 1000);
|
||||||
|
|
||||||
#if 0 // TODO: next step..
|
#if 0 // TODO: next step..
|
||||||
Mat inputImage(fb->height, fb->width, CV_8UC2, fb->buf); // rgb565 is 2 channels of 8-bit unsigned
|
Mat inputImage(fb->height, fb->width, CV_8UC2, fb->buf); // rgb565 is 2 channels of 8-bit unsigned
|
||||||
Mat outputImage;
|
Mat outputImage;
|
||||||
@ -103,6 +106,8 @@ void app_main()
|
|||||||
/* Display memory infos */
|
/* Display memory infos */
|
||||||
disp_infos();
|
disp_infos();
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Display width = %d, height = %d", tft->width(), tft->height());
|
||||||
|
|
||||||
/* Start the tasks */
|
/* Start the tasks */
|
||||||
xTaskCreatePinnedToCore(demo_task, "demo", 1024 * 9, nullptr, 24, nullptr, 0);
|
xTaskCreatePinnedToCore(demo_task, "demo", 1024 * 9, nullptr, 24, nullptr, 0);
|
||||||
}
|
}
|
Reference in New Issue
Block a user