问题
Summary: Our app depends on a high detection speed of facial landmarks (= like eyes open or closed). Thus I developed an algorythm that takes the position of the face from the last frame and crops the image from the next frame. This works perfectly and the Face Detector only has to process a quarter of the image.
But it does not increase the detection speed. Does anybody know why?
Edit: All that my algorythm is doing is croping the image based on the information from the last image. But it does not perform the ImageRecognition itself. We are using Mobile Vision from Google.
important Code snippets:
This snippped is executed before passing the bitmap to the Face Detector. It takes the face position from the previous frame and only passes this part of the image:
Bitmap bitmapReturn = Bitmap.createBitmap(bitmap, topLeftX, topLeftY, width, height);
This snippet is executed after the frame is processed by the Face Detector. It porviedes the location of the image for the next frame:
float spotY = getSpotY(face);
float spotX = getRatioX(face);
int moveX = (int) (((float)bitMapScanWidth / 2) - spotX) ;
int moveY = (int) (((float)bitMapScanHeight / 2) - spotY);
moveValues(moveX, moveY);
There are some further code snippets that make sure the image values topLeftX
and topLeftY
don't reach values beyond the bitmap size and others that make sure the face has the same size on the image.
But as said before. The algorythm works fine, but doesn't lead to anymore speed. I can't figure out why, because it should massively reduce the required computation time. Can anybody explain me why this is not the case? Do I have to adjust something? Or is there another way, to increase speed in my algorythm?
Note that when I compared the speed between the two versions (With the algorythm that crops the image and without it) both versions actually calculated through the required functions to crop the image. The only difference was that one of them actually used the values to crop the image and the other one just calculated them in the background. This means, that the computation required for my algorythm was not the reason for the missing speed improvement.
回答1:
If you are building your own algorithm for facial recognition, you can try to change the actual algorithm and use an architecture that is suitable for mobile devices. like MobilNetSSD or such, also you can try and change how you compile your algorithm and deploy it on mobile because both those techniques can boost the performance beyond what a simple cropping function can do. further, if you don't have any problem sharing the actual algorithm you are using I will do my best to see why cropping doesn't work for your specific case.
来源:https://stackoverflow.com/questions/59343628/face-detector-mobile-vision-speed-not-increased-with-smaller-bitmap