CN112633230A - Face encryption method and device, electronic equipment and storage medium - Google Patents

Face encryption method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112633230A
CN112633230A CN202011627347.0A CN202011627347A CN112633230A CN 112633230 A CN112633230 A CN 112633230A CN 202011627347 A CN202011627347 A CN 202011627347A CN 112633230 A CN112633230 A CN 112633230A
Authority
CN
China
Prior art keywords
face
data
encrypted
image data
encryption
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011627347.0A
Other languages
Chinese (zh)
Inventor
武绍旭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Intellifusion Technologies Co Ltd
Original Assignee
Shenzhen Intellifusion Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Intellifusion Technologies Co Ltd filed Critical Shenzhen Intellifusion Technologies Co Ltd
Priority to CN202011627347.0A priority Critical patent/CN112633230A/en
Publication of CN112633230A publication Critical patent/CN112633230A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/16Human faces, e.g. facial parts, sketches or expressions
    • G06V40/161Detection; Localisation; Normalisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • G06F21/6245Protecting personal data, e.g. for financial or medical purposes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/0021Image watermarking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/25Determination of region of interest [ROI] or a volume of interest [VOI]

Abstract

The embodiment of the invention provides a face encryption method, a face encryption device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring face image data to be encrypted and face encryption frame data; determining a face key area to be encrypted as first face key part data in the face image data to be encrypted according to the face encryption frame data, copying the face key area as second face key part data, and respectively performing first encryption and second encryption on the first face key part data and the second face key part data to obtain first encrypted image data and second encrypted image data; and packaging the first encrypted image data, the second encrypted image data and the face encryption frame data into encrypted face image data. The embodiment of the invention has the advantages of simple realization, good encryption effect and high human face image decryption and restoration precision.

Description

Face encryption method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of data encryption technologies, and in particular, to a face encryption method and apparatus, an electronic device, and a storage medium.
Background
With the large-scale falling-to-ground business of face recognition technology in public places such as intelligent security, urban traffic, smart business and intelligent community, the privacy protection problem of face information also increasingly attracts public attention and worry, and in order to practically protect the privacy of the public and respond to the worry of the whole society about the safety of face information, a safety mechanism for face information encryption needs to be introduced into a new generation of face recognition system. For an unauthorized user, only encrypted face pictures or information can be acquired, and for an authorized user, unencrypted face picture information can be conveniently acquired. Therefore, the face picture encryption technology is required to be safe, reversible and lossless.
The prior art mainly adopts an in-place transformation scheme, namely data in-place transformation and in-place storage. The scheme mainly carries out position conversion or disorder processing on key parts (such as eyes) of the face in a decoding state so as to achieve the effect of mosaic of key parts. This solution has the following drawbacks: firstly, accurate control of the mosaic effect is difficult. For example, the coding effect obtained through operations such as disorder or transformation is not stable, and some original images can be seen sometimes, so that the encryption effect is not ideal; secondly, the disorder of the pixel level requires an operation of accurate reversible support, and the encoding and decoding operations of the picture are not an accurate reversible process, and there is a deviation on the pixel level, so there may be a certain difference with the original image after the restoration. Therefore, the existing face encryption method has low decoding accuracy, which results in low picture restoration degree.
Disclosure of Invention
The embodiment of the invention provides a face encryption method which can improve the face encryption effect and the reduction precision.
In a first aspect, an embodiment of the present invention provides a face encryption method, including the following steps:
acquiring face image data to be encrypted and face encryption frame data;
determining a face key area to be encrypted as first face key part data in the face image data to be encrypted according to the face encryption frame data, copying the face key area as second face key part data, and respectively performing first encryption and second encryption on the first face key part data and the second face key part data to obtain first encrypted image data and second encrypted image data;
and packaging the first encrypted image data, the second encrypted image data and the face encryption frame data into encrypted face image data.
Optionally, the determining, by the face encryption frame data, a face key area to be encrypted as first face key location data in the face image data to be encrypted according to the face encryption frame data, and copying the face key area as second face key location data includes:
determining the face key area in the face image data to be encrypted according to the coordinate data, and taking pixel points of the face key area as first face key position data;
copying the pixel points of the face key area as second face key part data, and preprocessing the second face key part data to obtain preprocessed second face key part data.
Optionally, the performing first encryption on the first key location data to obtain first encrypted image data includes:
acquiring each pixel point of a first face key part from the face image data to be encrypted according to the coordinate data;
and carrying out mosaic coding on each pixel point of a first face key part in the face image data to be encrypted according to a preset coding rule to obtain the first encrypted image data.
Optionally, the second encrypting the second face key part data to obtain second encrypted image data includes:
carrying out pixel point coding on the second face key part data;
and adding the face encryption frame data into the coded second face key part data to obtain second encrypted image data.
Optionally, the step of performing pixel point coding on the second face key part data includes:
performing pixel point negation on the key part data of the human face;
and coding the inverted second human face key part data according to a preset coding rule.
Optionally, the encrypted face image data further includes an encryption identifier and a length of the second encrypted image data.
Optionally, the method further includes a face decryption step, including:
judging whether to decrypt the human face according to the encrypted identifier;
if the human face is to be decrypted, separating the first encrypted image data and the second encrypted image data from the encrypted human face image data based on the length of the second encrypted image data; and correspondingly decrypting the second encrypted image data, and restoring the second face key part data to the first encrypted image data according to the face encryption frame data decrypted by the second encrypted image data to obtain the original face image data to be encrypted.
In a second aspect, an embodiment of the present invention provides a face encryption apparatus, including:
the acquisition module is used for acquiring the face image data to be encrypted and the face encryption frame data;
the encryption module is used for determining a face key area to be encrypted in the face image data to be encrypted as first face key part data according to the face encryption frame data, copying the face key area as second face key part data, and respectively performing first encryption and second encryption on the first face key part data and the second face key part data to obtain first encrypted image data and second encrypted image data;
and the packaging module is used for packaging the first encrypted image data, the second encrypted image data and the face encryption frame data into encrypted face image data.
In a third aspect, an embodiment of the present invention provides an electronic device, including: the face encryption method comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor executes the computer program to realize the steps in the face encryption method provided by the embodiment of the invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the steps in the face encryption method provided in the embodiment of the present invention.
In the embodiment of the invention, face image data to be encrypted and face encryption frame data are obtained; determining a face key area to be encrypted as first face key part data in the face image data to be encrypted according to the face encryption frame data, copying the face key area as second face key part data, and respectively performing first encryption and second encryption on the first face key part data and the second face key part data to obtain first encrypted image data and second encrypted image data; and packaging the first encrypted image data, the second encrypted image data and the face encryption frame data into encrypted face image data. Reading the pixel data of the key region of the face to be encrypted as the second key part data of the face through a face encryption frame, carrying out second encryption, adding the second key part data of the face to be encrypted to the back of the original face image data to be encrypted, storing the second key part data of the face to be encrypted together, assigning the pixel value of the key part of the first face in the original face image to be encrypted to a preset value to realize first encryption, reading the stored second key part pixel data of the face from the encrypted face image data during decryption, and filling the second key part pixel data of the face into the key region of the face according to the face encryption frame, thereby realizing decryption and restoration of the face encrypted image. The embodiment of the invention has the advantages of simple realization, good encryption effect and high human face image decryption and restoration degree.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a face encryption method according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for obtaining face key part data according to an embodiment of the present invention;
fig. 3 is a flowchart of a first encryption method according to an embodiment of the present invention;
fig. 4 is a flowchart of a second encryption method according to an embodiment of the present invention;
fig. 5 is a flowchart of a method for encoding pixel points at key portions of a human face according to an embodiment of the present invention;
fig. 6 is a schematic flow chart of a face decryption method according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a face encryption apparatus according to an embodiment of the present invention;
FIG. 8 is a schematic structural diagram of a preprocessing module according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a first encryption module according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a second encryption module according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of an encoding submodule provided in an embodiment of the present invention;
fig. 12 is a schematic structural diagram of another face encryption apparatus according to an embodiment of the present invention;
fig. 13 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart of a face encryption method according to an embodiment of the present invention, as shown in fig. 1, including the following steps:
101. and acquiring the face image data to be encrypted and the face encryption frame data.
In the embodiment of the present invention, the face image data to be encrypted may be acquired by a device with a camera function, such as a traffic probe, a computer camera, a mobile phone camera, and the like, automatically in real time, or may be manually input by other visual interfaces, such as GUI or WEB pages. The face image data to be encrypted at least comprises feature information of a face to be encrypted, the face feature information comprises key part feature information of the face, such as two-dimensional or three-dimensional feature information of the nose, eyes and the like of the face, and corresponding key part feature information can be identified and extracted through a neural network model.
The face encryption frame data is corresponding coordinate position information of the key part of the face in the face image to be encrypted, the face encryption frame is a rectangle by default, and can be represented by four-tuple reset (left, top, right, bottom, namely, a midpoint coordinate top of an upper frame, a midpoint coordinate bottom of a lower frame, a midpoint coordinate left of a left frame, and a midpoint coordinate right of a right frame) coordinates, and the reset face encryption frame is completely contained in the face image. The face encryption box can also be represented in the form of a quadruplet Rect (upper left corner point coordinate, upper right corner point coordinate, lower left corner point coordinate, lower right corner point coordinate).
Further, the key part features may be extracted by a neural network model (e.g., a convolutional neural network CNN, etc.), and corresponding coordinate information may be acquired at the same time to be used as the face encryption frame data.
Specifically, the face encryption frame data may be obtained by performing face key part detection on face image data to be encrypted through a target detection network, and the target detection network may return a detection frame, where the detection frame includes the face image key part and may be used as the face encryption frame data.
In a possible embodiment, the detection frame is in an expression form of (x, y, w, h), where x, y are coordinates of a center point of the detection frame, w is a width of the detection frame, and h is a height of the detection frame, and the detection frame can be converted into an expression form of a quadruplet Rect to be used as the face encryption frame data.
Specifically, the detection frame (x, y, w, h) may be converted into an expression form of Rect (upper left corner, upper right corner, lower left corner, and lower right corner), so that the upper left corner is used as a starting point and the lower right corner is used as an end point to sequence the pixels in the face encryption frame, and optimize the data structure in the encryption and decryption processes.
102. According to the face encryption frame data, determining a face key area to be encrypted in the face image data to be encrypted as first face key part data, copying the face key area as second face key part data, and respectively performing first encryption and second encryption on the first face key part data and the second face key part data to obtain first encrypted image data and second encrypted image data.
In this embodiment of the present invention, a face key region to be encrypted may be determined from the face image data to be encrypted through the Rect coordinate information of the face encryption frame data obtained in step 101, and a pixel point in the face key region is used as a first face key part data, and a pixel point in the face key region is copied as a second face key part data, and then the second encryption is performed, for example, if the face key region to be encrypted is determined to be an eye through the face encryption frame coordinate information, then the eye data is copied as the second face key part data, and the eye data of the second face key part may be encoded according to a preset encoding rule, so as to obtain the second encrypted data.
For example, in the face image data to be encrypted, obtaining is started according to a pixel point corresponding to the upper left corner of the Rect face encryption frame until a pixel point corresponding to the lower right corner of the Rect face encryption frame is ended, and the second face key part data can be obtained; and then, performing second encryption on the second face key part data, wherein the second encryption can adopt a reversible encryption mode, for example, the value of each pixel point is subjected to negation operation, and the second face key part data can be restored by negation in decryption.
It should be noted that, the first encryption of the first face key position data in the face image data to be encrypted is performed in an irreversible encryption manner, for example, a mosaic encryption manner, and through the irreversible first encryption, the face key position located according to the face encryption frame can be subjected to mosaic encryption in the face image to be encrypted, and the values of the first face key position data pixel points can also be uniformly set to a certain value, and if the values are uniformly set to 0, the original first face key position pixel point value cannot be recovered, so that the encryption effect of the first encryption is better and cannot be completely restored.
The data of the face key region can be data corresponding to a face key part rectangular frame, the face key part rectangular frame can be obtained by detecting the face key part of face image data to be encrypted through a target key part detection network, the target key part detection network can return a detection frame, the detection frame comprises a face key part, and the detection frame and the face key part image in the detection frame can be used as the face key part data. The face key part data can also be expressed according to a quadruple Rect. The face key part rectangular frame can also be coordinate information manually selected or input by a user through a visual interface.
Optionally, the face encryption frame data includes coordinate data of the face key region, please refer to fig. 2, and fig. 2 is a flowchart of a method for obtaining face key region data according to an embodiment of the present invention, and as shown in fig. 2, the steps of determining, in the face image data to be encrypted, a face key region to be encrypted as first face key region data and copying the face key region as second face key region data according to the face encryption frame data specifically include:
201. and determining a face key area in the face image data to be encrypted according to the coordinate data, and taking pixel points of the face key area as first face key position data.
In this embodiment of the present invention, the face key region may be determined by using the quadruple Rect coordinate information of the face encryption frame data obtained in step 101, for example, according to a rectangular frame formed by the upper left corner point coordinate, the upper right corner point coordinate, the lower left corner point coordinate, and the lower right corner point coordinate of the quadruple Rect face encryption frame, and a pixel point in the face key region is used as the first face key position data.
202. And copying the pixel points of the face key area as second face key part data, and preprocessing the second face key part data to obtain preprocessed second face key part data.
In the embodiment of the present invention, the pixel points in the face key area determined in step 201 may be copied as the second face key location data, that is, in the face image data to be encrypted, pixel point reading is performed sequentially from left to right and from top to bottom starting from the pixel point corresponding to the upper-left corner point coordinate of the rectangular frame of the face key area until the pixel point corresponding to the lower-right corner point coordinate of the rectangular frame of the face key area ends, so that the second face key location data may be obtained from the face image data to be encrypted. Then, preprocessing each pixel point in the second face key part data, including data format conversion, channel mode conversion and the like; the data format conversion can convert an original acquired face image format into a required format, such as a Mat format, which is a data format form specified by OpenCV (image processing system), and is data in a matrix (marcrix) format, the image data in the Mat format can be regarded as a certain two-dimensional array, and the channel mode conversion can convert an image in different channel modes, such as RGB to YUV or gray scale conversion, so as to acquire an RGB value or a YUV value or a gray scale value of each pixel point according to requirements; through the preprocessing, the gray value or RGB value of each pixel point can be conveniently obtained from the human face image data in Mat format, and the values are modified and reset.
Optionally, referring to fig. 3, fig. 3 is a flowchart of a first encryption method according to an embodiment of the present invention, as shown in fig. 3, including the following steps:
301. and acquiring each pixel point of the key part of the first face from the face image data to be encrypted according to the coordinate data.
In this embodiment of the present invention, the quadruple Rect coordinate information of the face encryption frame data obtained in step 101 may be obtained, that is, the corresponding first face key location data is sequentially read from left to right and from top to bottom in the face image data to be encrypted according to the top left corner point coordinate, the top right corner point coordinate, the bottom left corner point coordinate, and the bottom right corner point coordinate of the rectangular face encryption frame, and the location information and the pixel value information of each pixel point are obtained from the first face key location data in the face image data to be encrypted.
302. And performing mosaic coding on each pixel point of a first face key part in the face image data to be encrypted according to a preset coding rule to obtain the first encrypted image data.
In the embodiment of the invention, firstly, the corresponding position of a face key region is positioned in the face image data to be encrypted according to the four-tuple Rect coordinate information of the face encryption frame data, the value of each pixel point of a first face key part is sequentially obtained from left to right and from top to bottom, then, the value of each pixel point is uniformly set according to a preset coding rule, if the value of the RGB pixel points is uniformly set to be 0, the mosaic coding operation of each pixel point of the key part in the original human face image data to be encrypted is realized according to the preset coding rule, thereby obtaining the first encrypted image data, whereby the first encryption is irreversible encryption, the value of the first face key part pixel point is uniformly set to be a certain value, and then the original pixel point value cannot be recovered, so that the encryption effect is good, and the first face key part pixel point cannot be restored by the outside.
Optionally, referring to fig. 4, fig. 4 is a flowchart of a second encryption method according to an embodiment of the present invention, as shown in fig. 4, including the following steps:
401. and carrying out pixel point coding on the key part data of the second face.
In the embodiment of the present invention, the pixel point value of the second face key portion obtained from the face image to be encrypted may be inverted, and then each pixel point is correspondingly encoded according to a preset encoding rule, so as to obtain encoded second face key portion data. The process of inverting and encoding the pixel points is reversible, so that the encoded pixel points can be restored.
Specifically, referring to fig. 5 for the step 401, fig. 5 is a flowchart of a method for encoding a pixel point of a key part of a human face according to an embodiment of the present invention, and as shown in fig. 5, the method includes the following steps:
501. and performing pixel negation on the second face key part data.
In the embodiment of the invention, after the face image data to be encrypted is positioned at the corresponding position of the key part of the face according to the quadruple Rect coordinate information of the face encryption frame data, the value of each pixel point is sequentially copied from left to right and from top to bottom as the key part of the second face, then the value of each pixel point is inverted, for RGB pixel points, the value of each channel of the pixel points is inverted, for example, 0 of the R channel is inverted to 255, 1 of the R channel is inverted to 254, and the like, and each pixel point after inversion is sequentially and temporarily stored in a memory variable strRgb according to a character string format.
502. And coding the inverted second human face key part data according to a preset coding rule.
In an embodiment of the present invention, the preset encoding rule may be a base64 encoding rule, and the base64 encoding rule is a method for representing binary data based on 64 printable characters. Reading the second face key part data temporarily stored in the memory variable strgb, and then correspondingly encoding the second face key part data in the inverted character string format according to the preset base64 encoding rule to obtain the encoded second face key part data.
As can be seen from the above, the second encryption is reversible encryption, that is, the second face key part data temporarily stored in the memory variable strgb can be inversely encoded according to the base64 encoding rule, and then the value of each pixel point of the face key part can be obtained by inverting, so that the face key part can be restored and obtained, and the face key part can be restored by one hundred percent, that is, the restoration precision after encryption is high.
402. And adding the face encryption frame data into the coded second face key part data to obtain the second encrypted image data.
In this embodiment of the present invention, the face encryption frame data may be added to the end of the second face key part data encoded in step 502 to obtain the second encrypted image data, so that the second encrypted image data simultaneously carries the second face key part data and the coordinate information of the face encryption frame, such as the eye data and the coordinate information of the eyes in the original image. The face encryption frame data comprises coordinate information of a face encryption frame, and specifically comprises four coordinate values of a left upper corner point coordinate, a right upper corner point coordinate, a left lower corner point coordinate and a right lower corner point coordinate of the face encryption frame, and each coordinate value can be stored by a LONG type occupying 8 bytes.
103. And packaging the first encrypted image data, the second encrypted image data and the face encryption frame data into encrypted face image data.
In the embodiment of the present invention, the first encrypted image data may be encoded, for example, jpeg encoded, and then the second encrypted image data and the face encryption frame data may be sequentially added after the encoded first encrypted image data, and the length and the encryption identifier of the second encrypted image data may also be continuously added, and all the data are encapsulated together to form the encrypted face image data. The length of the second encrypted image data can be obtained by measuring the second face key part data in the coded character string format, the encryption identifier is located at the last part of the encrypted face image data and is a preset value, such as the value 1 or the character ENCODE, and the like, and is used for identifying whether the image data is encrypted through the encryption process during decryption so as to determine whether to decrypt the image data according to the reverse process of the encryption process.
Specifically, referring to fig. 6, fig. 6 is a flowchart of a face decryption method according to an embodiment of the present invention, and as shown in fig. 6, the method includes the following steps:
601. and judging whether to decrypt the human face according to the encrypted identifier.
In the embodiment of the invention, the encryption identifier is preset at the tail part of the image data to be decrypted through the encryption step, whether the face decryption is carried out is determined by reading and judging whether the encryption identifier is the same as the preset one, if so, the image is encrypted and needs to be correspondingly decrypted, and if not, the image is not decrypted.
602. And if the human face is to be decrypted, separating the first encrypted image data and the second encrypted image data from the encrypted human face image data based on the length of the second encrypted image data.
In the embodiment of the invention, if the encrypted identifier is the same as the preset identifier, the image is encrypted and needs to be correspondingly decrypted; firstly, the value of the length of the second encrypted image data is obtained from the penultimate field of the tail part of the encrypted face image data, and separates the first encrypted image data and the second encrypted image data from the encrypted face image data based on the value, for example, the encrypted face image data has 1000 bytes, wherein the encryption identifier occupies 8 bytes, the second encrypted image data length occupies 8 bytes, which stores a value of 256, the second encrypted image data has a length of 256 bytes, the first encrypted image data length is 1000-8-8-256 bytes to 728 bytes, that is, the encrypted face image data is read from the head, the first 728 bytes are the first encrypted image data, and the data between the 729 th byte and the 984 th byte is the second encrypted image data.
603. And correspondingly decrypting the second encrypted image data, and restoring the second face key part data to the first encrypted image data according to the face encryption frame data decrypted by the second encrypted image data to obtain the original face image data to be encrypted.
In an embodiment of the present invention, according to the encryption process, the second encrypted image data includes second face key part data and coordinate information of a face encryption frame, where the coordinate information of the face encryption frame includes upper, lower, left, and right coordinate values of the face encryption frame, which account for 4 × 8 to 32 bytes, and the rest of the byte data is the second face key part data. Performing base64 decoding and pixel point value negation on the second face key part data to obtain decoded original second face key part data; and performing jpeg decoding on the first encrypted image data to obtain image data after mosaic coding is performed on the key part, sequentially traversing corresponding pixel points in the image data after the mosaic coding from left to right and from top to bottom according to the coordinate information of the face encryption frame, and reading each pixel value from the decoded original second face key part data to sequentially reset each traversed pixel point, thereby obtaining the original face image data to be encrypted.
In summary, in the embodiment of the present invention, a face encryption frame is used to read pixel data of a key region of a face to be encrypted as second key region data of the face, perform second encryption, and then attach the second key region data to the back of original face image data to be encrypted and store the second key region data and the original face image data separately, while a first key region pixel value in the original face image to be encrypted is assigned with a preset value to implement first encryption, and when decrypting, only the stored second key region pixel data of the face needs to be read from the encrypted face image data, and then the second key region pixel data is filled into the key region of the face according to the face encryption frame, thereby implementing decryption and restoration of the face encrypted image. The embodiment of the invention has the advantages of simple realization, good encryption effect and high human face image decryption and restoration degree.
It should be noted that the face encryption method provided by the embodiment of the present invention may be applied to devices such as a mobile phone, a monitor, a computer, and a server that can perform data search.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a face encryption apparatus according to an embodiment of the present invention, and as shown in fig. 7, the apparatus 700 includes:
an obtaining module 701, configured to obtain face image data to be encrypted and face encryption frame data;
an encryption module 702, configured to determine, according to the face encryption frame data, a face key area to be encrypted in the face image data to be encrypted as a first face key part data, copy the face key area as a second face key part data, and perform first encryption and second encryption on the first face key part data and the second face key part data, respectively, to obtain first encrypted image data and second encrypted image data;
a packaging module 703, configured to package the first encrypted image data, the second encrypted image data, and the face encryption frame data into encrypted face image data.
Optionally, the face encryption frame data includes coordinate data of the face key region, as shown in fig. 8, fig. 8 is a schematic structural diagram of a preprocessing module provided in an embodiment of the present invention, where the preprocessing module includes:
a determining submodule 7021, configured to determine the face key region in the face image data to be encrypted according to the coordinate data, and use a pixel point of the face key region as a first face key position data;
and the preprocessing submodule 7022 is configured to copy the pixel points of the face key region as second face key part data, and preprocess the second face key part data to obtain preprocessed second face key part data.
Optionally, as shown in fig. 9, fig. 9 is a schematic structural diagram of a first encryption module according to an embodiment of the present invention, where the first encryption module 800 includes:
the obtaining submodule 801 is configured to obtain each pixel point of a key part of a first face from the face image data to be encrypted according to the coordinate data;
the encoding submodule 802 is configured to perform mosaic encoding on each pixel point of a first face key portion in the face image data to be encrypted according to a preset encoding rule, so as to obtain the first encrypted image data.
Optionally, as shown in fig. 10, fig. 10 is a schematic structural diagram of a second encryption module according to an embodiment of the present invention, where the second encryption module 900 includes:
the encoding submodule 901 is configured to perform pixel encoding on the second face key part data;
and the adding submodule 902 is configured to add the face encryption frame data to the encoded second face key part data to obtain the second encrypted image data.
Optionally, as shown in fig. 11, the encoding sub-module 901 includes:
a negation unit 9011, configured to perform pixel negation on the second face key part data;
and the coding unit 9012 is configured to code the negated second face key part data according to a preset coding rule.
Optionally, as shown in fig. 12, the face encryption apparatus 700 further includes:
a judging module 704, configured to judge whether to perform face decryption according to the encrypted identifier;
a separation module 705, configured to separate the first encrypted image data and the second encrypted image data from the encrypted face image data based on the length of the second encrypted image data if face decryption is to be performed;
and a decryption and restoration module 706, configured to correspondingly decrypt the second encrypted image data, and restore the second face key part data to the first encrypted image data according to the face encryption frame data decrypted by the second encrypted image data, so as to obtain original face image data to be encrypted.
It should be noted that the face encryption apparatus provided in the embodiment of the present invention may be applied to a mobile phone, a monitor, a computer, a server, and other devices that can perform data search.
The face encryption device provided by the embodiment of the invention can realize each process realized by the face encryption method in the method embodiment, and can achieve the same beneficial effect. To avoid repetition, further description is omitted here.
Referring to fig. 13, fig. 13 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, as shown in fig. 13, including: a memory 1302, a processor 1301, and a computer program stored on the memory 1302 and executable on the processor 1301, wherein:
the processor 1301 is used to call the computer program stored in the memory 1302, and performs the following steps:
acquiring face image data to be encrypted and face encryption frame data;
determining a face key area to be encrypted as first face key part data in the face image data to be encrypted according to the face encryption frame data, copying the face key area as second face key part data, and respectively performing first encryption and second encryption on the first face key part data and the second face key part data to obtain first encrypted image data and second encrypted image data;
and packaging the first encrypted image data, the second encrypted image data and the face encryption frame data into encrypted face image data.
Optionally, the determining, by the processor 1301, the face key area to be encrypted in the face image data to be encrypted as first face key location data according to the face encryption frame data, and copying the face key area as second face key location data according to the face encryption frame data includes:
determining the face key area in the face image data to be encrypted according to the coordinate data, and taking pixel points of the face key area as first face key position data;
copying the pixel points of the face key area as second face key part data, and preprocessing the second face key part data to obtain preprocessed second face key part data.
Optionally, the performing, by the processor 1301, the first encryption on the first person key position data to obtain first encrypted image data includes:
acquiring each pixel point of a first face key part from the face image data to be encrypted according to the coordinate data;
and carrying out mosaic coding on each pixel point of a first face key part in the face image data to be encrypted according to a preset coding rule to obtain the first encrypted image data.
Optionally, the second encrypting, performed by the processor 1301, the second face key part data to obtain second encrypted image data includes:
carrying out pixel point coding on the second face key part data;
and adding the face encryption frame data into the coded second face key part data to obtain second encrypted image data.
Optionally, the step, executed by the processor 1301, of performing pixel point encoding on the second face key part data includes:
performing pixel negation on the second face key part data;
and coding the inverted second human face key part data according to a preset coding rule.
Optionally, the processor 1301 further performs a face decryption step, including:
judging whether to decrypt the human face according to the encrypted identifier;
if the human face is to be decrypted, separating the first encrypted image data and the second encrypted image data from the encrypted human face image data based on the length of the second encrypted image data;
and correspondingly decrypting the second encrypted image data, and restoring the second face key part data to the first encrypted image data according to the face encryption frame data decrypted by the second encrypted image data to obtain the original face image data to be encrypted.
It should be noted that the electronic device may be a device that can be applied to a mobile phone, a monitor, a computer, a server, and the like that can perform face encryption.
The electronic device provided by the embodiment of the invention can realize each process realized by the face encryption method in the method embodiment, can achieve the same beneficial effect, and is not repeated here for avoiding repetition.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the face encryption method provided in the embodiment of the present invention, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention, and it is therefore to be understood that the invention is not limited by the scope of the appended claims.

Claims (10)

1. A face encryption method is characterized by comprising the following steps:
acquiring face image data to be encrypted and face encryption frame data;
determining a face key area to be encrypted as first face key part data in the face image data to be encrypted according to the face encryption frame data, copying the face key area as second face key part data, and respectively performing first encryption and second encryption on the first face key part data and the second face key part data to obtain first encrypted image data and second encrypted image data;
and packaging the first encrypted image data, the second encrypted image data and the face encryption frame data into encrypted face image data.
2. The method of claim 1, wherein the face encryption box data includes coordinate data of the face key region, and the determining a face key region to be encrypted as first face key region data in the face image data to be encrypted and copying the face key region as second face key region data based on the face encryption box data comprises:
determining the face key area in the face image data to be encrypted according to the coordinate data, and taking pixel points of the face key area as first face key position data;
copying the pixel points of the face key area as second face key part data, and preprocessing the second face key part data to obtain preprocessed second face key part data.
3. The method of claim 2, wherein said first encrypting the first key location data to obtain first encrypted image data comprises:
acquiring each pixel point of a first face key part from the face image data to be encrypted according to the coordinate data;
and carrying out mosaic coding on each pixel point of a first face key part in the face image data to be encrypted according to a preset coding rule to obtain the first encrypted image data.
4. The method of claim 3, wherein the second encrypting the second face key location data to obtain second encrypted image data comprises:
carrying out pixel point coding on the second face key part data;
and adding the face encryption frame data into the coded second face key part data to obtain second encrypted image data.
5. The method of claim 4, wherein said step of pixel encoding said second face key location data comprises:
performing pixel negation on the second face key part data;
and coding the inverted second human face key part data according to a preset coding rule.
6. The method of claim 5, wherein the encrypted face image data further comprises an encryption identification and the second encrypted image data length.
7. The method of claim 6, wherein the method further comprises a face decryption step comprising:
judging whether to decrypt the human face according to the encrypted identifier;
if the human face is to be decrypted, separating the first encrypted image data and the second encrypted image data from the encrypted human face image data based on the length of the second encrypted image data;
and correspondingly decrypting the second encrypted image data, and restoring the second face key part data to the first encrypted image data according to the face encryption frame data decrypted by the second encrypted image data to obtain the original face image data to be encrypted.
8. A face encryption apparatus, comprising:
the acquisition module is used for acquiring the face image data to be encrypted and the face encryption frame data;
the encryption module is used for determining a face key area to be encrypted in the face image data to be encrypted as first face key part data according to the face encryption frame data, copying the face key area as second face key part data, and respectively performing first encryption and second encryption on the first face key part data and the second face key part data to obtain first encrypted image data and second encrypted image data;
and the packaging module is used for packaging the first encrypted image data, the second encrypted image data and the face encryption frame data into encrypted face image data.
9. An electronic device, comprising: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps in the face encryption method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that a computer program is stored thereon, which, when being executed by a processor, implements the steps in the face encryption method according to any one of claims 1 to 7.
CN202011627347.0A 2020-12-30 2020-12-30 Face encryption method and device, electronic equipment and storage medium Pending CN112633230A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011627347.0A CN112633230A (en) 2020-12-30 2020-12-30 Face encryption method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011627347.0A CN112633230A (en) 2020-12-30 2020-12-30 Face encryption method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112633230A true CN112633230A (en) 2021-04-09

Family

ID=75290265

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011627347.0A Pending CN112633230A (en) 2020-12-30 2020-12-30 Face encryption method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112633230A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115439795A (en) * 2022-11-08 2022-12-06 浙江慧享信息科技有限公司 Video coding method, medium and equipment related to portrait
WO2023051377A1 (en) * 2021-09-30 2023-04-06 北京地平线信息技术有限公司 Desensitization method and apparatus for image data

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023051377A1 (en) * 2021-09-30 2023-04-06 北京地平线信息技术有限公司 Desensitization method and apparatus for image data
CN115439795A (en) * 2022-11-08 2022-12-06 浙江慧享信息科技有限公司 Video coding method, medium and equipment related to portrait
CN115439795B (en) * 2022-11-08 2023-10-13 浙江慧享信息科技有限公司 Video coding method, medium and equipment related to portrait

Similar Documents

Publication Publication Date Title
CN112633230A (en) Face encryption method and device, electronic equipment and storage medium
CN113806806B (en) Desensitization and restoration method and system for webpage screenshot
US20120076297A1 (en) Terminal for use in associating an annotation with an image
KR101460552B1 (en) Masking and Recovering Method of Privacy Region
CN111738898B (en) Text digital watermark embedding/extracting method and device
CN111931145A (en) Face encryption method, face recognition method, face encryption device, face recognition device, electronic equipment and storage medium
CN111222611B (en) Color-based stacked three-dimensional code encoding method, encoding device, decoding method, decoding device and storage medium
CN110634096B (en) Self-adaptive multi-mode information hiding method and device
CN114461988A (en) Image encryption method and device, image decryption method and device
CN110069907A (en) Big data source tracing method and system based on digital watermarking
CN112134687B (en) Information encryption and decryption method based on two-dimensional code
CN114616834B (en) Face-based frame encapsulation for video telephony
CN108256360A (en) The display methods and terminal of a kind of sensitive information
CN110225027B (en) Method and system for unidirectional data ferry between isolation networks based on three-dimensional code technology
RU2713762C1 (en) Method of embedding biometric information into a color image of a face and a device for realizing the method
CN117597702A (en) Scaling-independent watermark extraction
CN116391200A (en) Scaling agnostic watermark extraction
CN115526282A (en) Watermark encryption method, watermark extraction method, device and storage medium
KR20220051510A (en) Device, method and computer program for protecting image including personal information
Pinto et al. Protection of JPEG compressed e-comics by selective encryption
CN104732137A (en) Android-based method of recognizing multi-mode AES-encrypted (advanced encryption standard encrypted) QR (quick response) codes
CN112418371A (en) Secure three-dimensional code for blockchains and methods of generating and decoding
CN116205781A (en) Image processing method and device
JP2663922B2 (en) Video encoding device
CN111627089B (en) User head portrait picture processing method, device and system and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination