Here is my code on gist
This camera app is follow Android Official Guide
My device is Nexus 5 with kikat 4.4.2
#Override
public void onFaceDetection(Camera.Face[] faces, Camera camera) {
if (faces.length > 0){
Camera.Face f = faces[0];
Log.v(TAG, ("Detected" + faces.length + "faces,the ID of first face is:" + f.id ));
Log.v(TAG, "leftEye : " + f.leftEye);
Log.v(TAG, "mouth : " + f.mouth);
Log.v(TAG, "rect : " + f.rect);
Log.v(TAG, "rightEye: " + f.rightEye);
mCamera.stopFaceDetection();
}
}
The output above code when detect a human face is:
Detected 1 faces,the ID of first face is:-1
FaceActivity﹕ leftEye : null
FaceActivity﹕ mouth : null
FaceActivity﹕ rect : Rect(-393, 356 - -213, 676)
FaceActivity﹕ rightEye: null
So, I want to know whether my Nexus 5 support FaceDetect?If not, how could it implement Screen Lock with Face Unlock?
I found out the reason for this problem. It's all about RGB_564. Android has an API to recognize the human face, but only RGB_564 bitmaps are supported. Face detection is a very cost intensive action. So by default, the camera's FaceDetect feature only recognizes basic face information, and that was the reason why face.leftEye is null.
Related
After i flashed my phone with LineageOS which is a custom rom, my equalizer got alot of UnsupportedOperationExceptions.
getStrengthSupported also returns false on custom roms but true on stock android.
For now i just disable my equalizer if i catch this exception in a try-catch.
But i was wondering if there is another way so i can also support custom roms.
if (mBassBoost.getStrengthSupported()) {
mBassBoost.setEnabled((short) progress > 0);
mBassBoost.setStrength((short) progress);
Log.i(TAG, "mBassBoost StrengthSupported: "+ mBassBoost.getStrengthSupported());
}else{
Log.e(TAG, "mBassBoost StrengthSupported: "+ mBassBoost.getStrengthSupported());
}
mBassBoostProgress = (int)progress;
Log.i(TAG, "BassBoost Rounded Strength: " + mBassBoost.getRoundedStrength());
I am trying to fetch the fired alerts using the splunk java sdk. But i am not able to get any reference. Here is the code snippet i have and it is not fetching me any results.
FiredAlertGroupCollection firedAlertGroups = service.getFiredAlertGroups();
System.out.println("Fired Alert : " + firedAlertGroups.size());
for (FiredAlertGroup entity : firedAlertGroups.values()) {
EntityCollection<FiredAlert> alerts = entity.getAlerts();
for (FiredAlert alert : alerts.values()) {
System.out.println("alerts >>>> " +alert.getName() +": " + alert.getSavedSearchName()+": " + alert.getTitle());
}
}
Is there a way, i can filter the alerts fired in the last 24 hours etc.
Please help me on the same.
I can't find information about face detection on preview in android.hardware.Camera2, would anybody help me with a complete example?
I saw some questions with camera2 examples in github but I can't understand them.
I used Camera2 sample from Google: https://github.com/googlesamples/android-Camera2Basic.
I set face recognition mode to FULL.
mPreviewRequestBuilder.set(CaptureRequest.STATISTICS_FACE_DETECT_MODE, CameraMetadata.STATISTICS_FACE_DETECT_MODE_FULL);
Also I checked STATISTICS_INFO_MAX_FACE_COUNT and STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES:
int max_count = characteristics.get(
CameraCharacteristics.STATISTICS_INFO_MAX_FACE_COUNT);
int modes [] = characteristics.get(
CameraCharacteristics.STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES);
Output: maxCount : 5 , modes : [0, 2]
My CaptureCallback:
private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() {
private void process(CaptureResult result) {
Integer mode = result.get(CaptureResult.STATISTICS_FACE_DETECT_MODE);
Face [] faces = result.get(CaptureResult.STATISTICS_FACES);
if(faces != null && mode != null)
Log.e("tag", "faces : " + faces.length + " , mode : " + mode );
}
#Override
public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request,
CaptureResult partialResult) {
process(partialResult);
}
#Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
TotalCaptureResult result) {
process(result);
} `
Output: faces : 0 , mode : 2
public static final int STATISTICS_FACE_DETECT_MODE_FULL = 2;
Faces length is constantly 0. Looks like it doesn't recognise a face properly or I missed something.
I know approach with FaceDetector. I just wanted to check how it works with new camera2 Face.
I need to detect face on preview of camera2!
I think that you can't use CameraMetadata.STATISTICS_FACE_DETECT_MODE_FULL, because some devices do not support this type of face detection. Please, can you verify if your device support STATISTICS_FACE_DETECT_MODE_FULL?
If the answer is "NO", please try to use STATISTICS_FACE_DETECT_MODE_SIMPLE
Look at this Samsung Example
https://developer.samsung.com/galaxy/camera#techdocs
There is a sample explaining how to use face detection with camera2 API
I am struggling for a couple of hours now on how to link a discid to a musicbrainz mbid.
So, using dietmar-steiner / JMBDiscId
JMBDiscId discId = new JMBDiscId();
if (discId.init(PropertyFinder.getProperty("libdiscid.path")))
{
String musicBrainzDiscID = discId.getDiscId(PropertyFinder.getProperty("cdrom.path"));
}
or musicbrainzws2-java
Disc controller = new Disc();
String drive = PropertyFinder.getProperty("cdrom.path");
try {
DiscWs2 disc =controller.lookUp(drive);
log.info("DISC: " + disc.getDiscId() + " match: " + disc.getReleases().size() + " releases");
....
I can extract a discid for freedb or musicbrainz easily (more or less), but I have not found a way on calculating the id I that I need to download cover art via the CoverArtArchiveClient from last.fm.
CoverArtArchiveClient client = new DefaultCoverArtArchiveClient();
try
{
UUID mbid = UUID.fromString("mbid to locate release");
fm.last.musicbrainz.coverart.CoverArt coverArt = client.getByMbid(mbid);
Theoretically, I assume, I could you the data collected by musicbrainzws2-java to trigger a search, and then use the mbid from the result ... but that cannot be the best option to do.
I am happy about any push into the right direction...
Cheers,
Ed.
You don't calculate the MBID. The MBID is attached on every entity you retrieve from MusicBrainz.
When getting releases by DiscID you get a list. Each entry is a release and has an MBID, accessible with getId():
for (ReleaseWs2 rel : disc.getReleases()){
log.info("MBID: " + rel.getId() + ", String: " + rel.toString());
}
You then probably want to try the CoverArtArchive (CAA) for every release and take the first cover art you get.
Unfortunately I don't know of any API documentation for musicbrainzws2 on the web. I recommend running javadoc on all source files.
I am writing an Android application to read input from a HID USB foot pedal (press the pedal, get a message, do something).
The UsbManager is not recognizing the device. The foot pedal may be throwing an error in Android kernel when it plugs in, because I see this error message in the logcat:
"EventHub could not get driver version for /dev/input/mouse0, not a typewriter"
However, I know the foot pedal works, because when I plug it in and press it, it changes the focus to the next button on the activity... So I know it is communicating with my Nexus tablet and apparently its default action is to move the focus to the next button/object. I don't think there are any problems with my code, since it will recognize other USB devices, just not this foot pedal. I can actually tell when it's pressed by checking for when the focus changes, but that won't work for what I want since this app will run in the background as a service. I've tried setting an intent filter for this specific USB device (I know its product id and vendor id). However, it still shows no connected devices and the pop-up message that is supposed to ask the user to confirm launching the application never shows up. I've tried just listing all the connected USB devices as well, but I always get an empty list.
Is there any way to intercept input from this device so I can tell when the foot pedal gets pressed, even though Android's USB Manager will not recognize it?
For completeness, here is my code. I am testing on a Galaxy Nexus 10 tablet:
public int list_usb_devices()
{
int device_count = 0;
UsbManager mUsbManager;
mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
String LOG_TAG = "USB";
for (UsbDevice device : mUsbManager.getDeviceList().values()) {
//This code is never reached...
Log.d(LOG_TAG, "Detected device: " + device.toString());
Log.d(LOG_TAG, "Model: " + device.getDeviceName());
Log.d(LOG_TAG, "Id: " + device.getDeviceId());
Log.d(LOG_TAG, "Class: " + device.getDeviceClass());
Log.d(LOG_TAG, "Protocol: " + device.getDeviceProtocol());
Log.d(LOG_TAG, "VendorId: " + device.getVendorId());
Log.d(LOG_TAG, "ProductId: " + device.getProductId());
CharSequence text = device.toString();
show_toast(text);
device_count++;
}
return device_count;
}
I did some research in the Android source and it seems that all HID boot devices (mouse, keyboard etc.) are blacklisted and can therefore not be accessed using the USBManager API.
Here is the relevant part from the UsbHostManager.java , see here: http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/4.4.2_r1/com/android/server/usb/UsbHostManager.java/?v=source
/* returns true if the USB device should not be accessible by applications */
private boolean isBlackListed(int clazz, int subClass, int protocol) {
// blacklist hubs
if (clazz == UsbConstants.USB_CLASS_HUB) return true;
// blacklist HID boot devices (mouse and keyboard)
if (clazz == UsbConstants.USB_CLASS_HID &&
subClass == UsbConstants.USB_INTERFACE_SUBCLASS_BOOT) {
return true;
}
return false;
}