Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.9k views
in Technique[技术] by (71.8m points)

tensorflow lite - Flutter Camera Plugin Transformations

I am trying to use the Camera Plugin for Tensorflow image classification, but I am not understanding how to work with the CameraImage object.

I am able to see it's height, width and 'Planes', which is what eventually is passed into the Tensorflow Lite plugin as a bytelist.

  await Tflite.runModelOnFrame(
      bytesList: image.planes.map((plane) {
        return plane.bytes;
      }).toList(),
      numResults: 5,
  )

However the image is needing all sorts of transformations:

Sure that I need...

  1. Crop the top and bottom off to make a square.
  2. Scale to 200 by 200 resolution.

Not sure if I need...

  1. Remove the alpha component and get the rgb data

  2. Quantize the image data, i.e. making the images go from 0-255 to 0-1 in value

I am trying to manipulate the CameraImage but I am not really sure what the planes attribute is. It contains 3 Planes objects, which appear to bytes, which I am guessing vaguely represent pixels on a screen.

The camera readme doesn't appear to document what exactly a plane is: https://pub.dev/packages/camera

All the image manipulation plugins seem to be based around the image_picker plugin and/or Files. I can't find any that work with a CameraImage object and I am unsure of how to work with the Planes directly. I looked at the image_picker plugin but every tensorflow lite tutorial seemed to prefer camera, so I have avoided it for now.

Any advice would be appreciated, thank you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...