Thinking and realization of anti-facial recognition

Source: Internet
Author: User

Thinking and realization of anti-facial recognition

I. Basic knowledge and background

       ? Face recognition is a very classic machine recognition application that has been used in many places. The related algorithm principle and the realization development are all very developed, the OPENCV has the good realization. This is the status quo.

However, because of this, people-related privacy has become a cause for concern. One of the concepts above applied SIGVC is called "anti-facial recognition"http://www.sigvc.org/bbs/forum.php?mod=viewthread&tid=3348&highlight=%B7% B4%C8%CB%C1%B3is a technology implementation that focuses on user privacy. From the technical realization, it is divided into "face recognition" and "face Blur" two parts. Two parts of the implementation is not very difficult, the key is "processing the input image, protect the user's privacy" the idea is crucial. Here is my related research.

Ii. Steps of implementation

       ? one) face recognition

This type of face recognition image is generally a global image, such as

Instead of this image with a single face as the main content

So in the choice of the algorithm, I prefer the Haar method, but not the skin color model. I think the skin color is more suitable for close-up, when it needs to be handled in fine detail.

Then the identification:

for this positive picture, the effect is good. There may be an area of error recognition, but it does not affect the body.

voidMain ()

{
//Read in picture
Mat SRC=Imread ("C:/m.jpg",0);
//Human face recognition
String Fn_haar="C:/haarcascade_frontalface_default.xml";
Cascadeclassifier Haar_cascade;
Haar_cascade.load (Fn_haar);
Vector<Rect_<int>>Faces
Haar_cascade.detectmultiscale (SRC, faces);//Detection of multiple faces
//Draw the area
for(intI=0; I<Faces.size (); I++)
{
Rect face_i=Faces[i];
Rectangle (Src,face_i,scalar (255));
}
Imshow ("src", SRC);
Cv::Waitkey ();
GetChar ();
}

II) blurred face

There are many ways to blur your face. As the saying goes, it is easy to draw a ghost, it is difficult to make a face here, but if you want to make a person face into a human face, it will be a lot simpler. The more common is to play mosaic, but there is no code at hand (if there is a welcome to add), so the direct use of fuzzy algorithm for processing

This treatment after the face, the basic can not see the original person is which. It is important to note that the Gussianblur parameters need to be made larger, so that the effect of blurring is better.

Encapsulation into a function, it should be noted that the image is directly modified here

//Face Blur
void blurface (Mat src) {    Gaussianblur (Src,src,size (19,19), n);}

III) main processes

the main flow of the anti-face recognition facial blur method is to recognize the face, then guass the blur, and then merge with the original. You need to make a batch process and generate a log.

It is important to note that the final result of the picture still needs color, but in the process of processing may be used in grayscale photos.

The effect is as follows, it should be recognized.

OK, here to achieve the effect of single-sheet, in the actual project must be batch processing, and processing input and output, together with the following written

//Bulk processing read picture function
Vector<Pair<Char*, Mat>>Read_img (ConstString&Dir
{
Cstatdir Statdir;
Pair<Char*, Mat>Pfi
Vector<Pair<Char*, Mat>>Vp;
if(!Statdir. Setinitdir (Dir.c_str ()))
{
returnVp;
}
intcls_id=Dir[dir.length ()-1]-' 0 ';
Vector<Char*>File_vec=Statdir. Beginbrowsefilenames ("*.jpg");
intI,s=File_vec.size ();
for(I=0; I<S;i++)
{
Pfi.first=File_vec[i];
Pfi.second=Imread (File_vec[i],0);
Vp.push_back (PFI);
}
File_vec=Statdir. Beginbrowsefilenames ("*.bmp");
S=File_vec.size ();
for(I=0; I<S;i++)
{
Pfi.first=File_vec[i];
Pfi.second=Imread (File_vec[i],0);
Vp.push_back (PFI);
}
File_vec=Statdir. Beginbrowsefilenames ("*.png");
S=File_vec.size ();
for(I=0; I<S;i++)
{
Pfi.first=File_vec[i];
Pfi.second=Imread (File_vec[i],0);
Vp.push_back (PFI);
}
returnVp;
}

Processing all files under the IMGs folder in the current directory, the result is as follows

Third, reflection

     &NBSP; ? The current code can continue to be improved at the time of deployment, and now requires the haarcascade_frontalface_default.xml Copy to the c:/directory, you need to create the C:/imgs folder and copy the image that needs to be transformed into it, and create the D:/imgs folder. This is inconvenient, but as a prototype, I did not continue to optimize.

I think the key point is that according to the object you need to highlight, select the recognition algorithm for face recognition. The goal is to erase the face and display the area that needs to be displayed.

Thanks for reading! Hope to be able to help you.

From for notes (Wiz)



Thinking and realization of anti-facial recognition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.