当前位置: 首页 > 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.mmbaike.com/news/36714.html

相关文章:

  • discuz怎么做h5网站志鸿优化设计电子版
  • 外贸网站和普通网站南通seo
  • 网站诚信认证怎么做从哪里找网络推广公司
  • 嘉兴自助建站模板军事新闻最新消息
  • 黑龙江高端网站建设国外市场网站推广公司
  • 做亚马逊有什么网站可以借鉴怎么百度推广
  • java网站开发岗位职责今日新闻播报
  • 网站中链接怎么做百度手机点击排名工具
  • 做问卷调查用哪个网站好腾讯企点qq
  • wordpress站点标题删除佛山网络公司 乐云seo
  • 中文网站模板免费下载百度的营销推广
  • 包装设计网站排行榜广州百度推广开户
  • 东莞阳光热线问政平台青岛seo服务
  • 哈尔滨开发网站优化设计答案
  • wordpress网站白屏唐老鸭微信营销软件
  • 5网站建设长沙谷歌seo收费
  • wordpress用户信息界面seo自学教程
  • 衡阳市做网站黄页引流推广链接
  • 常州外贸集团 网站建设深圳创新创业大赛
  • 网站建站网站哪家好谷歌浏览器中文手机版
  • 网站百度快照更新足球联赛排名
  • 陕西住房和城乡建设部网站首页淘宝推广费用一般多少
  • 手机有办法做网站吗百度网络推广怎么收费
  • 做网站哪家比较好seo在线网站推广
  • 怎么做带网站连接的表格上海网络营销有限公司
  • 做杂志一般在哪个网站找感觉武汉网站seo
  • 怎么查公司信息seo优化报告
  • 网站建设维护实训总结哪里可以学企业管理培训
  • 怎么建设自己网站香港域名注册网站
  • 昆山张浦做网站网站搭建工具