[RK3288][Android6.0] 调试笔记 --- Camera实现Soft Resize

Platform: RK3288
OS: Android 6.0
Kernel: 3.10.92

背景:
同一型号摄像头,由于供应商的更换导致支持的分辨率不是全部一致,而其中一个分辨率320x240在项目上就有需求。这种情况下只能通过软件来实现了。

实现步骤:
1. 先在preview size中添加一个320x240的伪支持,因为不是硬件真正读到的。

+
+/* 180301, Kris, Add support which is used by software resize. {*/
+#ifdef USE_SW_RESIZE
+   if (parameterString.size() != 0)
+       parameterString.append(",320x240");
+#endif
+/* 180301, Kris, Add support which is used by software resize. }*/
+
    params.set(KEY_PREVIEW_W_FORCE,"0");
    params.set(KEY_PREVIEW_H_FORCE,"0");
    params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, parameterString.string());
    params.setPreviewSize(640,480);

2.实现soft resize算法

调用处:

int AppMsgNotifier::captureEncProcessPicture(FramInfo_s* frame){
......
#ifdef USE_SW_RESIZE
            if (......)
                rga_nv12_scale_crop(frame->frame_width, frame->frame_height,
                    (char*)(frame->vir_addr), (short int *)(tmpPreviewMemory->data),
                    mPreviewDataW,mPreviewDataH,frame->zoom_value,mDataCbFrontMirror,true,0);
            else
                useSoftResizeBuffer((char*)(frame->vir_addr), (char *)tmpPreviewMemory->data, mPreviewDataW, mPreviewDataH);
#endif
......
}

void AppMsgNotifier::useSoftResizeBuffer(char *srcbuf, char *dstbuf, int dst_width, int dst_height)
{
......
    } else if (dst_width == 320 && dst_height == 240) {
        Conv1280x720to320x240(srcbuf, dstbuf);
......
}

算法:

void AppMsgNotifier::Conv1280x720to320x240(char* pSrc, char* pDest)
{
  static const int SCALE = 196608;
  static const int SRC_WIDTH = 1280;
  static const int SRC_HEIGHT = 720;
  static const int DEST_WIDTH = 320;
  static const int DEST_HEIGHT = 240;
  static const int SRC_SIZE = SRC_WIDTH*SRC_HEIGHT;
  static const int DEST_SIZE = DEST_WIDTH*DEST_HEIGHT;

  unsigned int* pIntSrc = (unsigned int*)pSrc;
  unsigned int* pIntDest = (unsigned int*)pDest;
  unsigned int* pIntSrcUV = (unsigned int*)(pSrc + SRC_SIZE);
  unsigned int* pIntDestUV = (unsigned int*)(pDest + DEST_SIZE);

  unsigned int nRow;
  for(int i = 0; i < DEST_HEIGHT; ++i)
  {
    nRow = (SCALE*i) >> 16;
    pIntSrc = (unsigned int*)(pSrc + nRow*SRC_WIDTH);
    pIntSrcUV = (unsigned int*)(pSrc + SRC_SIZE + ((nRow >> 1)*SRC_WIDTH));
    for(int j = 0; j < 20; ++j)
    {
      SAVE_1IN4_BYTES_INT(pIntSrc, pIntDest);
      SAVE_1IN4_BYTES_INT(pIntSrc, pIntDest);
      SAVE_1IN4_BYTES_INT(pIntSrc, pIntDest);
      SAVE_1IN4_BYTES_INT(pIntSrc, pIntDest);

      if((i & 1) == 0)
      {
        SAVE_1IN4_SHORT_INT(pIntSrcUV, pIntDestUV);
        SAVE_1IN4_SHORT_INT(pIntSrcUV, pIntDestUV);
        SAVE_1IN4_SHORT_INT(pIntSrcUV, pIntDestUV);
        SAVE_1IN4_SHORT_INT(pIntSrcUV, pIntDestUV);
      }
    }
  }
}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 15
    评论
Vue-drag-resize是一个基于Vue.js的可拖拽和可调整大小的组件库。要实现达到临界值禁止缩放的效果,你可以按照以下步骤进行操作: 1. 首先,在Vue组件中引入Vue-drag-resize库,并注册该组件。 2. 在组件的模板中,使用Vue-drag-resize组件来包裹需要可调整大小的元素。 3. 在Vue-drag-resize组件上设置相应的属性和事件,以实现禁止缩放的效果。 具体实现步骤如下: 1. 安装Vue-drag-resize库: ``` npm install vue-drag-resize ``` 2. 在Vue组件中引入Vue-drag-resize库,并注册该组件: ```javascript import VueDragResize from 'vue-drag-resize'; export default { components: { VueDragResize, }, // ... } ``` 3. 在组件的模板中使用Vue-drag-resize组件来包裹需要可调整大小的元素: ```html <template> <div> <vue-drag-resize :w="200" :h="200" @resizing="handleResizing"> <!-- 可调整大小的元素内容 --> </vue-drag-resize> </div> </template> ``` 4. 在Vue-drag-resize组件上设置相应的属性和事件,以实现禁止缩放的效果。你可以通过设置`minW`和`minH`属性来限制元素的最小宽度和最小高度,当元素的宽度或高度达到临界值时,禁止继续缩放。同时,你可以通过监听`resizing`事件来实时监测元素的大小变化,并在达到临界值时进行处理: ```html <template> <div> <vue-drag-resize :w="200" :h="200" :minW="100" :minH="100" @resizing="handleResizing"> <!-- 可调整大小的元素内容 --> </vue-drag-resize> </div> </template> <script> export default { methods: { handleResizing(event) { const { width, height } = event; // 在达到临界值时进行处理 if (width <= 100 || height <= 100) { // 禁止继续缩放的逻辑处理 } }, }, }; </script> ``` 这样,当元素的宽度或高度达到临界值时,就会触发`resizing`事件,并在事件处理函数中进行相应的逻辑处理,从而实现禁止缩放的效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值