Harshvardhan Kalra
Harshvardhan Kalra

Reputation: 1

Tensorflow Android support for videos

Is there any existing support to Tensorflow on Android for locally saved videos? The demo provided is tightly coupled with the camera, and porting it to work for videos will be non-trivial and time-consuming, at the very least. The task it is intended for, is to process raw frames from a stream being broadcast live.

Upvotes: 0

Views: 261

Answers (1)

JP Kim
JP Kim

Reputation: 741

You have to take bitmaps for frame in video using MediaMetadataRetriever or something appropriate and then pass them to the tensorflow library for image recognition.

Currently there is no existing support for "video" stream itself in tensorflow AFAIK, even the demo takes screenshots of the camera preview to recognize.

If you really want to recognize video stream itself then you have to build a model of your own.

Otherwise, Process to analyze video would be as follows assuming you already have your graph and label file and playing video is not needed ( If you want to show video during the analysis, then you should implement surfaceview or textureview in your activity):

  1. Initialize tensorflow & load desired video using MediaMetadataRetriever
  2. extract bitmaps for desired frames using getFrameAtTime & scale the bitmap to appropriate size
  3. patternize the bitmap and run inference method ( you can pass the bitmap directly if you copy to use TensorflowImageClassifier.class from the demo )
  4. store the result and loop to another frame (2~4)

It's somewhat simplified overall process but I hope you can get a hint from this.

Upvotes: 1

Related Questions