android - Mobile Vision API - concatenate new detector object to continue frame processing -
i want use new face detection feature vision api provides along additional frame processing in application. this, need have access camera frame processed face detector, , concatenate processor using face detected data.
as see in sample, camerasource abstracts detection , camera access, , can't have access frame being processed. there examples of how camera frame in api, or, maybe, create , concatenate detector receives it? possible @ least?
thanks, lucio
yes, possible. you'd need create own subclass of detector wraps facedetector , executes frame processing code in detect method. this:
class myfacedetector extends detector<face> { private detector<face> mdelegate; myfacedetector(detector<face> delegate) { mdelegate = delegate; } public sparsearray<face> detect(frame frame) { // *** add custom frame processing code here return mdelegate.detect(frame); } public boolean isoperational() { return mdelegate.isoperational(); } public boolean setfocus(int id) { return mdelegate.setfocus(id); } }
you'd wrap face detector class, , pass class camera source. this:
facedetector facedetector = new facedetector.builder(context) .build(); myfacedetector myfacedetector = new myfacedetector(facedetector); myfacedetector.setprocessor(/* include processor here */); mcamerasource = new camerasource.builder(context, myfacedetector) .build();
your detector called first raw frame data.
note image may not upright, if device rotated. can orientation through frame's metadata.getrotation method.
one word of caution: once detect method returns, should not access frame pixel data. since camera source recycles image buffers, contents of frame object overridden once method returns.
edit: (additional notes) avoid boilerplate code of myfacedetector
using multidetector this:
multidetector multidetector = new multidetector.builder() .add(new facedetector.builder(context) .build()) .add(new yourreallyowndetector()) .build();
also note use of facetrackerfactory
in conjuction multiprocessor
described there.
Comments
Post a Comment