使用lv_100ask_camera_demo显示USB摄像头,显示如下图
通过图片抓拍到本地,显示如下图
代码中关键如下图
static void camera_work_timer(lv_timer_t * timer)
{
/Use the user_data/
lv_obj_t * img = (lv_obj_t *)timer->user_data;
/*Do something with LVGL*/
pthread_mutex_lock(&g_camera_100ask_mutex);
PT_VideoBuf VideoBufCur = camera_100ask_dev_get_video_buf_cur();
PT_PixelDatas ptSmallPic = &VideoBufCur->tPixelDatas;
img_dsc->data = ptSmallPic->aucPixelDatas;
//printf("%s",ptSmallPic->aucPixelDatas);
//img_dsc->data_size = (LV_COLOR_DEPTH / 8) * VideoBufCur->tPixelDatas.iWidth * VideoBufCur->tPixelDatas.iHeight;
img_dsc->data_size = (VideoBufCur->tPixelDatas.iBpp/8) * VideoBufCur->tPixelDatas.iWidth * VideoBufCur->tPixelDatas.iHeight;
// img_dsc->header.w = 400;
// img_dsc->header.h = 240;
img_dsc->header.w = VideoBufCur->tPixelDatas.iWidth;
img_dsc->header.h = VideoBufCur->tPixelDatas.iHeight;
//img_dsc->header.cf = LV_IMG_CF_TRUE_COLOR;
img_dsc->header.cf = LV_IMG_CF_TRUE_COLOR ;
lv_img_set_src(img, img_dsc);
//lv_img_set_src(img, "//mnt/UDISK/100ask-picture-19700120-164117.bmp");
pthread_mutex_unlock(&g_camera_100ask_mutex);
}