I\'m adding a black (0) padding around Region of interest (center) of NV21 frame got from Android CameraPreview
callbacks in a thread.
To avoid overhead of
Obviously, the most efficient way to pass image for detection would be to pass the ROI rectangle to detector. All our image processing functions accept bounding box as a parameter.
If the black margin is used for display, consider using a black overlay mask for preview layout instead of pixel manipulation.
If pixel manipulation is inevitable, check if you can limit it to Y OK, you already do this!
If your detector works on a downscaled image (as my face recognition engine does), it may be wise to apply black out to a resized frame.
At any rate, keep your loops clean and tidy, remove all recurring calculations. Using Arrays.fill() operations may help significantly, but not dramatically.