android-demo-app icon indicating copy to clipboard operation
android-demo-app copied to clipboard

[torchvideo] It has bug in torchvideo when "temporal > 4"

Open Le0v1n opened this issue 2 years ago • 0 comments

I modify COUNT_OF_FRAMES_PER_INFERENCE=4 -> 16 in Constants.javaand it has error when program running:

E/AndroidRuntime: FATAL EXCEPTION: ModuleActivity
    Process: org.pytorch.demo.torchvideo, PID: 6094
    java.lang.IllegalStateException: Buffer underflow

Specific in LiveVideoClassificationActivity.java:

TensorImageUtils.bitmapToFloatBuffer(centerCroppedBitmap,
                    0,
                    0,
                    Constants.TARGET_VIDEO_SIZE,
                    Constants.TARGET_VIDEO_SIZE,
                    Constants.MEAN_RGB,
                    Constants.STD_RGB,
                    inTensorBuffer,
                    (Constants.COUNT_OF_FRAMES_PER_INFERENCE - 1) * mFrameCount
                            * Constants.TARGET_VIDEO_SIZE * Constants.TARGET_VIDEO_SIZE);

mFrameCount in [0, 4] is normal, but it will have error when mFrameCount > 4.

MainActivity.javahas the same problem of Buffer underflow when COUNT_OF_FRAMES_PER_INFERENCE = 4 -> COUNT_OF_FRAMES_PER_INFERENCE > 4.

So How to solve this problem of Buffer underflow?

Thank you very much!

Le0v1n avatar Mar 08 '22 11:03 Le0v1n