Detecting and cropping a face from an picture? - java

I am working on a Face Recognition system for my internship. I am developing the project in Java right now. I am using OpenCV library, but it does not seem to work correctly in detecting faces.
I am at a point, where I capture image from the desktop and store it on the hard drive.
All I want now is to detect a face in that image (NOT IDENTIFY). I just need to detect that face and crop it.
Please help me with it. If anyone has specific code in Java to detect faces in a images, please send me that too.72236

This library already has face detection built in. You'd probably be better off using it.

Related

Android App use HED with OpenCV and Deep Learning(Java)

I am developing an android app to scan documents with my phone. I am using openCV and Canny edge detection and it works ok but if I try to scan an document on a background without enough contrast between the document and the background it fails. I have tried other apps in the Play Store and they are still able to scan the document with less contrast. So I was looking for ways to improve my edge detection and found this:
https://www.pyimagesearch.com/2019/03/04/holistically-nested-edge-detection-with-opencv-and-deep-learning/
But I can't figure out how to use HED in my Android Studio Java project. More precisely I can't find out how to create the custom layer cropping class for the neural network in Java. I was able to get the rest of the tutorial to work but I dont know how to create the custom layer cropping class.
At the moment im am registering an empty or wrong class as cropping layer and I'm getting blank images.
If any of you guys know something or can point me in the right direction I'd be very thankfull.
(edit) I did some research and apparently you have to create a class in c++ and use it in java but i can't find instructions on how to achieve this.

How can I do face recognition of two images using opencv java in android

I'm trying to create a face recognition application in android studio in java language. I spent considerable amount of time, searching for step by step guides for achieving this function. I found many tutorials for python language and i couldn't find any proper tutorial or atleast a video tutorial for java.
Can someone please provide me with a proper link with the steps to do face recognition with OpenCv in android using java language.
I'm new to OpenCv, so i have no big idea on its functions.
Your help is highly appreciated
Update 1 ::
I'm trying to capture the image of the user and then cross check the taken image with an image that is already available in the gallery.
I want to know if both are the same so that i can allow the user to use the application.
I actually made a Java program that utilised OpenCV for facial recognition earlier this year.
For me it was an utter nightmare. Guides to doing this on Java are basically nonexistent and the documentation for Java OpenCV is very poor.
What I ended up doing to get to grips with OpenCV was I used PyImageSearch to learn how OpenCV works and then just trawled through the OpenCV javadocs until I found the most similar classes to what was being used in PyImageSearch.
There are a few guides for OpenCV recognition using Java (I'll have a look through my notes when I get a chance and see if I saved any links for my own reference) but none of them were for what I needed.
If you edit your post with some more information on the recognition you're trying to do (video or jpeg or png?; frontal faces or side faces?; specific faces or faces in general?) I may be able to help a little more.
The Youtube link that #Varma posted might help you get to grips with OpenCV as a whole, but that series doesn't seem to cover facial recognition.
EDIT #1
Okay, recognising who someone is via an image is definitely doable with OpenCV, but it's not something I've done. Here's a PyImageSearch page on how to do it in Python. The methodology for doing it in Java with OpenCV will most likely be more or less the same even thought the syntax will - of course - make it look very different (should mostly be a matter of finding the equivalent Java classes and methods).
If it proves difficult, there are alternatives to OpenCV you could use, like these or Google's API. Keep in mind though that facial recognition is not very secure and does come with some controversy.

Android Camera preview with funhouse mirror effect

I created a android small app that uses the front facing camera to shoot a selfie. But what i want to accomplish is a funhouse mirror effect.
I searched the internet trying to find a solution or a way to do this but i am guessing i am searching for the wrong terms here:
Sample Image
Can someone push me in the right direction or how this is made? I searched for morphing, distortion etc.
What i have right now:
A basic camera app wich is saving a taken photo using the Camera2 API in Android SDK 23
Just only Camera2 API are not enough to develop an app which is like mentioned you. You should use computer vision libraries such as OpenCV or OpenGL.
First of all, please check it out for creating theoretical background.
Here is an example application which is using OpenCV and it is about funny effects.
This can be another reference application which is about fun house effects and it was developed by using GLSL.
Also this post can be helpful for you.
Moreover, you can check it and it out. And, you can use "image warping" term to search to find solutions for your problem on internet.

Detecting barcode using android camera

I am currently developing this Android phone application for the visually impaired people to detect and scan barcode. I am going to use ZXing(scanning via intent) for decoding barcode.
The problem now is, I need to use the camera to detect the presence of barcode around scanning region and alert the user via vibration or speech synthesizer. I am kind of stuck in this area now, I have tried borrowing books from the library and google searching for edge detection example, but to no avail:(
Can any kind soul please give me some advice in this area?
Thanks in advance!
There are other scanners on the market that use the full picture to detect barcodes. I know that NeoReader does not have this kind of scanning region.
It may be easier to find an API for different scanner then to detect barcodes (don't forget to focus...). Even if you find a way to detect codes, you still have to guide the visually impaired people to move the mobile so that the code will be inside the scanning area.

Gstreamer-java color distortion

I am playing video with gstreamer using gstreamer-java.
When I move my program to ubuntu and play video with it, the red and blue colors are switched, like..the people's faces are blue.
If I run the same program on windows, I don't have any color problem..
I did some search on google and here is what i found
https://answers.launchpad.net/ubuntu/+source/totem/+question/7373
I followed a lot of these people's suggestions here, but it still doesn't work on the ubuntu..
The Movie Player in ubunutu - totem (using gstreamer) can display the colors correctly for the same video file.
is there any way I can control gstreamer using gstreamer-java to change the color settings so it looks right?
Thanks!
I think you are using the XVideo (XV) or OpenGL output. There is probably a problem in the graphics driver. One solution is to use unaccelerated X11 output which is going to be painfully slow but won't have the artifacts you mention.
Could you provide gst-launch pipeline string which you should also be using in gstreamer-java api? From your description it looks like the image appears as RGB instead of BGR. This is due to video buffers being received as Big Endian in Java API. You may want to refer this patch on http://groups.google.com/group/gstreamer-java/msg/f93e7900d3028c51

Categories