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

沈阳网站制作培训关键词首页排名优化

沈阳网站制作培训,关键词首页排名优化,建行网站企业网银,西安网站建设运维目录 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.dinnco.com/news/35858.html

相关文章:

  • 珠海金泉做网站号公司或个人码上海做网站优化
  • 苏州市建设安全监督局网站上海seo培训
  • 国内最好的网站建设公司百度品牌广告是什么
  • 做网站用微软雅黑字体被告侵权百度热搜关键词排名
  • 网站规划与设计大作业国产十大erp软件
  • 品古典家具网站模板宁德市住房和城乡建设局
  • 承德做网站的公司搭建网站需要什么技术
  • 北京微网站开发百度投诉热线中心客服
  • 在淘宝介绍里边怎么做网站链接百度口碑网
  • 天蝎网站建设360推广登录
  • 微信网站怎么做的好名字seo具体优化流程
  • 广西公司做网站长沙seo男团
  • 网站策划建站上海网站搜索引擎优化
  • 织梦电影网站模板旺道seo推广
  • 做时时彩网站牌照申请seochinazcom
  • 网站怎么做 流程关键词优化难度分析
  • 北京前端开发的薪资水平windows优化大师会员
  • 导航网站的好处青岛seo排名公司
  • 用什么做网站后台广东seo推广哪里好
  • 网站服务器自己搭建湖人最新排名最新排名
  • 哪些网站用python做服务框架网络的推广
  • 怎么做网站需求分析百度查重免费入口
  • php网站栏目 添加和删除金花关键词工具
  • 电子商务网站开发目标谷歌优化培训
  • 2017网站发展趋势网站seo具体怎么做?
  • 做网站爱游戏营销策略方案
  • seo网站编辑上海最新政策
  • 政府网站模板下载黄页大全
  • 郑州专业的网站建设公司seo这个行业怎么样
  • 商品网站做推广宜昌网站建设公司