Created
October 22, 2018 19:33
-
-
Save the-dagger/278553c83f5e46eb2a27ddd62e1526f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
val objectPredictor = FritzVisionObjectPredictor.getInstance(this) | |
var fritzVisionImage: FritzVisionImage | |
cameraView.addFrameProcessor { frame -> | |
if (yuvDataLength == 0) { | |
//Run this only once | |
initializeData() | |
} | |
//Camera Preview returns NV21, so convert it to Bitmap : | |
//https://stackoverflow.com/a/43551798/5471095 | |
allocationIn.copyFrom(frame.data) //Take the NV21 format | |
yuvToRGB.forEach(allocationOut) //Convert it to Bitmap readable format | |
allocationOut.copyTo(bitmapOut) //Set it to the empty Bitmap created earlier | |
//Create a fritzVisionImage | |
fritzVisionImage = FritzVisionImage.fromBitmap(bitmapOut) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment