Okay, no response, obviously it does not work. Solution: I rewrote it to use camera2 library!Hi, I am trying to adapt CPJordi's example facedetection8, but in portrait mode. So far, i have not been able to change the code to show the face upright. The picture is always shown sideways. Thanks for help!
This is not a logical reasoning at all, and in my opinion, a bit of bad education.Okay, no response, obviously it does not work.
... I therefore had to search for a workaround and found one...
OK:
I could not make the camera library get a preview or take pictures in portrait mode. It works perfectly in landscape, but on my four different phones and pads it would not give an upright preview in portrait mode but tilting the picture by either 90 degrees right or left. Maybe I did something wrong or left out a parameter, that's why I posted my starting question three weeks ago. Scanning through forums like stackexchange and others I found out that other developers had this issue too. The problem is not in JordiCPs excellent wrapper, but in the underlying intrinsic Android classes. I refer to posts like this one:
Android: Camera preview orientation in portrait mode
I'm using the camera to show preview only (not to take pictures or record videos). The app is always in portrait mode (landscape mode is disabled). The camera preview is always rotated 90 degrees ...stackoverflow.com
So I converted my code to use the camera2 library where the camera orientation is no issue. There is an example for this library here:
Camera2 - New camera library
Camera2 library is based on the newer Camera API introduced in Android 5 (API 21). It is therefore supported by Android 5+ devices. It requires B4A v7.3+. The library is built to work together with CamEx2 class. Camera2 native API is more complex than the old API. However together CamEx2 and...www.b4x.com
I am open to any correction, particularly if someone found out how to get a portrait preview with the original camera lib.
Hi ,gezuebThe code is well dispersed in the app, so I send you the whole app as an example. It simulates Hogwarts Fat Lady, detects motion, asks the person to look into the camera, detects a face and frames it and then tries to recognize the person using tensorflow lite. Obviously the last part will not give you reasonable results, as it is trained to recognize me, my wife and my dog. As the zipped file is to large to upload here, I will add a link to the dropbox :
Have fun!Dropbox - File Deleted - Simplify your life
www.dropbox.com
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ok - model file is present in assets-foilder
java.lang.RuntimeException: Error initializing TensorFlow!
at com.tillekesoft.tensorflowlite.TensorflowWrapper$1.run(TensorflowWrapper.java:53)
at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:784)
Caused by: java.io.FileNotFoundException: faces.tflite
at android.content.res.AssetManager.nativeOpenAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:865)
at com.tillekesoft.tensorflowlite.TensorFlowImageClassifier.copyToCacheFile(TensorFlowImageClassifier.java:181)
at com.tillekesoft.tensorflowlite.TensorFlowImageClassifier.openAssetFile(TensorFlowImageClassifier.java:169)
at com.tillekesoft.tensorflowlite.TensorFlowImageClassifier.loadModelFile(TensorFlowImageClassifier.java:82)
at com.tillekesoft.tensorflowlite.TensorFlowImageClassifier.create(TensorFlowImageClassifier.java:58)
at com.tillekesoft.tensorflowlite.TensorflowWrapper$1.run(TensorflowWrapper.java:47)
... 4 more