将 3D 张量转换回图像 (jpg/png) [英] Convert a 3D Tensor back into an image (jpg/png)

查看:79
本文介绍了将 3D 张量转换回图像 (jpg/png)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用返回 Tensor3D 的 Tensorflow Camera 组件对于相机预览的每一帧.这对于使用 tensorflow 模型进行实时分类非常有用,但是,我希望能够将此张量转换回 jpg 或图像格式,以便与 Tesseract 等 OCR 库一起使用.

I want to use the Tensorflow Camera component which returns a Tensor3D for each frame of the camera preview. This is great for live classification with tensorflow models, however, I want to be able to convert this tensor back into a jpg or image format to be used with an OCR library like Tesseract.

有什么方法可以转换 <tf.Tensor3d>转换为更传统的图像格式以供一般用途?

Is there any way to convert a <tf.Tensor3d> into a more traditional image format for general use ?

推荐答案

您可以使用 tf.node.encodeJpegtf.node.encodePng 但他们要求传入的 3D Tensor 是 uint8 类型.

You can either use tf.node.encodeJpeg or tf.node.encodePng but they require that the 3D Tensor passed in is of type uint8.

这篇关于将 3D 张量转换回图像 (jpg/png)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆