AOLI_qztl 2021-12-17 15:16 采纳率: 60%
浏览 54

android 获取的相机预览帧为什么是这个样子

processor.addPacketCallback(
"pose_landmarks",

            (packet) -> {
                Log.v(TAG, "Received Pose landmarks packet.");
                try {
                    System.out.println(packet);
                        byte[] landmarksRaw = PacketGetter.getProtoBytes(packet);
                    //byte[]转bitmap
                    YuvImage image = new YuvImage(landmarksRaw, ImageFormat.NV21, image_width, image_height, null);
                    ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    image.compressToJpeg(new Rect(0, 0, image_width,image_height), 80, stream);
                    Bitmap bmp = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size());
                    //因为图片会放生旋转,因此要对图片进行旋转到和手机在一个方向上
                    Bitmap bmp1 = rotateMyBitmap(bmp);
                    Bitmap bmp2 = turnCurrentLayer(bmp1, -1, 1);
                    FileUtils.savePaiZhaoBitmap(bmp2,landmarksRaw);
  • 写回答

3条回答 默认 最新

  • 五一编程 2021-12-17 15:23
    关注
                    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    
                    image.compressToJpeg(new Rect(0, 0, image_width,image_height), 80, stream);
    
                    Bitmap bmp = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size());
    
                    Bitmap bmp1 = rotateMyBitmap(bmp);
    

    这几句图片做了压缩的,旋转,是不是变形了

    评论

报告相同问题?

问题事件

  • 创建了问题 12月17日

悬赏问题

  • ¥15 CCF-CSP 2023 第三题 解压缩(50%)
  • ¥30 comfyui openpose报错
  • ¥20 Wpf Datarid单元格闪烁效果的实现
  • ¥15 图像分割、图像边缘提取
  • ¥15 sqlserver执行存储过程报错
  • ¥100 nuxt、uniapp、ruoyi-vue 相关发布问题
  • ¥15 浮窗和全屏应用同时存在,全屏应用输入法无法弹出
  • ¥100 matlab2009 32位一直初始化
  • ¥15 Expected type 'str | PathLike[str]…… bytes' instead
  • ¥15 三极管电路求解,已知电阻电压和三级关放大倍数