当前位置: 首页 > news >正文

优秀企业门户网站seo链接提交入口

优秀企业门户网站,seo链接提交入口,免费开源建站系统源码,如何注册个人工作室目录 ImageReader 直接保存图片,没成功,格式是yuv420,需要转换 转opencv nv21保存图片,测试ok rgb888 data保存图片: ImageReader 直接保存图片,没成功,格式是yuv420,需要转换 …

目录

ImageReader 直接保存图片,没成功,格式是yuv420,需要转换

转opencv

nv21保存图片,测试ok

rgb888 data保存图片:


ImageReader 直接保存图片,没成功,格式是yuv420,需要转换

// 创建一个ImageReader对象
ImageReader reader = ImageReader.newInstance(width, height, ImageFormat.JPEG, 1);reader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {@Overridepublic void onImageAvailable(ImageReader reader) {Image image = null;try {image = reader.acquireLatestImage();if (image != null) {ByteBuffer buffer = image.getPlanes()[0].getBuffer();byte[] bytes = new byte[buffer.capacity()];buffer.get(bytes);saveImage(bytes);}} finally {if (image != null) {image.close();}}}
}, handler);// 保存图片
private void saveImage(byte[] bytes) {File file = new File(Environment.getExternalStorageDirectory() + "/picture.jpg");FileOutputStream output = null;try {output = new FileOutputStream(file);output.write(bytes);} catch (IOException e) {e.printStackTrace();} finally {if (null != output) {try {output.close();} catch (IOException e) {e.printStackTrace();}}}
}

转opencv

Image image = imageReader.acquireLatestImage();
Plane[] planes = image.getPlanes();
ByteBuffer bufferY = planes[0].getBuffer();
ByteBuffer bufferU = planes[1].getBuffer();
ByteBuffer bufferV = planes[2].getBuffer();
byte[] bytesY = new byte[bufferY.remaining()];
byte[] bytesU = new byte[bufferU.remaining()];
byte[] bytesV = new byte[bufferV.remaining()];
bufferY.get(bytesY);
bufferU.get(bytesU);
bufferV.get(bytesV);

c++部分:

cv::Mat imgY(height, width, CV_8UC1, bytesY);
cv::Mat imgU(height, width, CV_8UC1, bytesU);
cv::Mat imgV(height, width, CV_8UC1, bytesV);

c++部分:

cv::Mat imgYUV;
cv::merge(std::vector<cv::Mat>{imgY, imgU, imgV}, imgYUV);
cv::Mat imgRGB;
cv::cvtColor(imgYUV, imgRGB, cv::COLOR_YUV2RGB);

nv21保存图片,测试ok

     Yuv2Rgb.nativeNV21ToARGB8888(nv21, data, width[0], height[0]);long t2 = System.currentTimeMillis();// 假设你已经有了一个ARGB_8888格式的图像,存储在一个名为pixels的int数组中int width = 1920;int height = 1080;String file_name="/storage/emulated/0/Android/data/com.sandstar.jupiter.terminal.algor/files/"+mCameraId+"/"+frameIdx+"_b.jpg";YuvImage yuvImage = new YuvImage(nv21, ImageFormat.NV21, width, height, null);try {// 创建一个输出流来保存图片FileOutputStream outStream = new FileOutputStream(file_name);// 将YuvImage转换为JPEG,并保存到输出流中yuvImage.compressToJpeg(new Rect(0, 0, width, height), 100, outStream);// 关闭输出流outStream.close();} catch (IOException e) {e.printStackTrace();}

rgb888 data保存图片:

Yuv2Rgb.nativeNV21ToARGB8888(nv21, data, width[0], height[0]); // Create a Bitmap from the ARGB8888 data
Bitmap bitmap = Bitmap.createBitmap(data, width[0], height[0], Bitmap.Config.ARGB_8888);// Save the Bitmap as a JPEG file
FileOutputStream fos = null;
try {fos = new FileOutputStream("/path/to/your/file.jpg");bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
} catch (IOException e) {e.printStackTrace();
} finally {try {if (fos != null) {fos.close();}} catch (IOException e) {e.printStackTrace();}
}

http://www.yayakq.cn/news/126122/

相关文章:

  • 长沙公司网站建设网站报价明细表
  • 网站模板佳好乐云seo零基础学习做网站
  • 免费创建网站软件保山做网站
  • 如何增加网站索引量优秀网站的颜色搭配
  • 东莞数据线厂家东莞网站建设网站建设图片如何放在网站上
  • wordpress删了重装朝阳seo排名优化培训
  • 南城区网站仿做开公司怎么做网站
  • 潍坊市建设银行坊子支行网站北京华夏网站建设设计公司
  • 网站式登录页面模板下载绍兴seo计费
  • 空间设计网站公司优化方案化学
  • 公司网站开发教程源码交易网站
  • 如何做挂qq的网站百度竞价网站备案
  • 临桂建设局安全股网站拍拍网站开发
  • 品牌网站设计做模板网站简单吗
  • 网站建设后的注意问题禁止同ip网站查询
  • 高端网站建设网络设计互联网信息化服务类网站建设类型报价表
  • 哪些网站需要做分享按钮网站开发手机app
  • 做网站大概费用游戏私人服务器搭建
  • 义马网站开发网页设计与制作课程报告
  • 佛山网站建设wantsun北京网页设计公司兴田德润怎么样
  • 免费做数据采集的网站合肥房产网
  • 策划公司企业简介天津网站排名优化费用
  • 广西柳州网站建设推荐做网站推广怎么说广告词
  • 宜昌市住房和城乡建设局网站WordPress给编辑器
  • 西安 h5网站建设c asp.net网站开发书
  • 中国建设网官方网站下载e路最新版网络黄页平台网址有哪些
  • 优化网站费用做翻页电子书的网站
  • 购物网站开发公司数据库与网站建设的关系
  • 家居企业网站建设案例wordpress发布文章页面错误
  • 宁波专业做网站的公司哪家好2022年编程语言官方排行榜