HK40053647B - Method and apparatus for recognizing human faces, computer readable medium and electronic device - Google Patents
Method and apparatus for recognizing human faces, computer readable medium and electronic device Download PDFInfo
- Publication number
- HK40053647B HK40053647B HK42021044186.1A HK42021044186A HK40053647B HK 40053647 B HK40053647 B HK 40053647B HK 42021044186 A HK42021044186 A HK 42021044186A HK 40053647 B HK40053647 B HK 40053647B
- Authority
- HK
- Hong Kong
- Prior art keywords
- node
- face
- target
- block
- related data
- Prior art date
Links
Description
技术领域Technical Field
本申请涉区块链技术领域,具体而言,涉及一种人脸识别方法、装置、计算机可读介质及电子设备。This application relates to the field of blockchain technology, and more specifically, to a face recognition method, device, computer-readable medium, and electronic device.
背景技术Background Technology
当前,在进行人脸识别时,主要通过将人脸特征库离线存储在终端的本地来实现离线人脸识别,而人脸特征库的文件往往很大,因此,将人脸特征库存储在终端的本地不仅消耗了大量的网络流量,还占用了很多本地的存储资源,造成存储资源的浪费。Currently, facial recognition is mainly performed offline by storing the facial feature database locally on the terminal. However, facial feature database files are often very large. Therefore, storing the facial feature database locally on the terminal not only consumes a lot of network traffic, but also occupies a lot of local storage resources, resulting in a waste of storage resources.
发明内容Summary of the Invention
本申请的实施例提供了一种人脸识别方法、装置、计算机可读介质及电子设备,进而至少在一定程度上可以减少将人脸特征库存储在终端本地所消耗的网络流量和存储资源。Embodiments of this application provide a face recognition method, apparatus, computer-readable medium, and electronic device, which can at least to some extent reduce the network traffic and storage resources consumed by storing the face feature database locally on the terminal.
本申请的其他特性和优点将通过下面的详细描述变得显然,或部分地通过本申请的实践而习得。Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
根据本申请实施例的一个方面,提供了一种人脸识别方法,所述方法包括:以接入本地局域网的用于进行人脸识别的终端设备作为区块链节点,组建在所述本地局域网内进行数据通信的区块链网络,所述区块链网络包括生成并存储目标区块的目标节点以及用于查找所述目标区块的查询节点;在所述目标节点接入互联网的情况下,通过所述目标节点从服务端下载用于离线存储的人脸相关数据,并在所述目标节点上生成包含所述人脸相关数据的目标区块;将所述目标区块保存在所述目标节点上,并通过所述目标节点在所述区块链网络上广播所述目标区块的上链信息,所述上链信息用于表示所述目标区块与区块链上的其他区块的链接关系;当所述查询节点接收到所述区块链网络中广播的所述上链信息时,在所述查询节点上保存根据所述上链信息生成的区块记录,所述区块记录包括用于查找所述目标区块的查询路径;响应于人脸识别请求,根据所述查询节点上保存的区块记录,遍历所述区块链中的各个区块以得到人脸识别结果。According to one aspect of the embodiments of this application, a face recognition method is provided. The method includes: using a terminal device connected to a local area network (LAN) for face recognition as a blockchain node, establishing a blockchain network for data communication within the LAN, the blockchain network including a target node for generating and storing target blocks and a query node for searching the target blocks; when the target node is connected to the Internet, downloading face-related data for offline storage from a server through the target node, and generating a target block containing the face-related data on the target node; storing the target block on the target node, and broadcasting on-chain information of the target block on the blockchain network through the target node, the on-chain information indicating the link relationship between the target block and other blocks on the blockchain; when the query node receives the on-chain information broadcast in the blockchain network, storing a block record generated based on the on-chain information on the query node, the block record including a query path for searching the target block; and in response to a face recognition request, traversing each block in the blockchain according to the block record stored on the query node to obtain a face recognition result.
根据本申请实施例的一个方面,提供了一种人脸识别装置,所述装置包括:组建单元,用于以接入本地局域网的用于进行人脸识别的终端设备作为区块链节点,组建在所述本地局域网内进行数据通信的区块链网络,所述区块链网络包括生成并存储目标区块的目标节点以及用于查找所述目标区块的查询节点;下载和生成单元,用于在所述目标节点接入互联网的情况下,通过所述目标节点从服务端下载用于离线存储的人脸相关数据,并在所述目标节点上生成包含所述人脸相关数据的目标区块;保存和广播单元,用于将所述目标区块保存在所述目标节点上,并通过所述目标节点在所述区块链网络上广播所述目标区块的上链信息,所述上链信息用于表示所述目标区块与区块链上的其他区块的链接关系;接收和保存单元,用于当所述查询节点接收到所述区块链网络中广播的所述上链信息时,在所述查询节点上保存根据所述上链信息生成的区块记录,所述区块记录包括用于查找所述目标区块的查询路径;遍历单元,用于响应于人脸识别请求,根据所述查询节点上保存的区块记录,遍历所述区块链中的各个区块以得到人脸识别结果。According to one aspect of the embodiments of this application, a face recognition device is provided. The device includes: a building unit, configured to build a blockchain network for data communication within the local area network, using a terminal device for face recognition connected to a local area network as a blockchain node; the blockchain network includes target nodes for generating and storing target blocks and query nodes for searching the target blocks; a downloading and generating unit, configured to download face-related data for offline storage from a server through the target node when the target node is connected to the Internet, and generate a target block containing the face-related data on the target node; and a saving and broadcasting unit, configured to... The target block is stored on the target node, and the target node broadcasts the on-chain information of the target block on the blockchain network. The on-chain information is used to indicate the link relationship between the target block and other blocks on the blockchain. A receiving and storing unit is used to store a block record generated based on the on-chain information on the query node when the query node receives the on-chain information broadcast on the blockchain network. The block record includes a query path for finding the target block. A traversal unit is used to traverse each block in the blockchain to obtain the face recognition result in response to a face recognition request, based on the block record stored on the query node.
在本申请的一些实施例中,基于前述方案,所述下载和生成单元配置为:获取所述目标节点的标识信息和最新加入区块链的区块中的第一哈希值;根据所述目标节点的标识信息、所述第一哈希值和所述人脸相关数据确定第二哈希值;基于所述目标节点的标识信息、所述人脸相关数据、所述第一哈希值和所述第二哈希值生成区块。In some embodiments of this application, based on the foregoing scheme, the download and generation unit is configured to: obtain the identification information of the target node and the first hash value in the latest block added to the blockchain; determine the second hash value based on the identification information of the target node, the first hash value and the face-related data; and generate a block based on the identification information of the target node, the face-related data, the first hash value and the second hash value.
在本申请的一些实施例中,基于前述方案,所述下载和生成单元配置为:对所述人脸相关数据进行加密,得到加密后的人脸相关数据;将所述目标节点的标识信息、所述加密后的人脸相关数据、所述第一哈希值和所述第二哈希值打包成区块。In some embodiments of this application, based on the foregoing scheme, the download and generation unit is configured to: encrypt the face-related data to obtain encrypted face-related data; and package the target node's identification information, the encrypted face-related data, the first hash value, and the second hash value into a block.
在本申请的一些实施例中,基于前述方案,所述上链信息包括哈希值和所述目标节点的标识信息,所述接收和保存单元配置为:当所述查询节点接收到所述区块链网络中广播的所述上链信息时,将所述上链信息中包含的所述哈希值和所述目标节点的标识信息作为区块记录保存至所述查询节点上。In some embodiments of this application, based on the foregoing scheme, the on-chain information includes a hash value and the identification information of the target node, and the receiving and saving unit is configured to: when the query node receives the on-chain information broadcast in the blockchain network, save the hash value and the identification information of the target node contained in the on-chain information as a block record to the query node.
在本申请的一些实施例中,基于前述方案,所述遍历单元配置为:获取所述人脸识别请求中的人脸数据;根据所述区块记录中的哈希值和节点的标识信息,确定所述区块链中各区块的查询路径;根据所述查询路径,依次向所述区块链网络中各节点发送所述人脸数据,由各节点在存储的区块中进行检索,得到各节点返回的人脸识别结果。In some embodiments of this application, based on the aforementioned scheme, the traversal unit is configured to: obtain the face data in the face recognition request; determine the query path of each block in the blockchain according to the hash value and node identification information in the block record; and send the face data to each node in the blockchain network in sequence according to the query path, so that each node can retrieve the face data in the stored blocks and obtain the face recognition result returned by each node.
在本申请的一些实施例中,基于前述方案,所述下载和生成单元还用于:通过所述查询节点监听所述目标节点的工作状态;当所述查询节点监听到所述区块链网络中的所述目标节点处于离线状态时,从所述服务端下载已由所述目标节点生成的所述目标区块中的人脸相关数据,并在所述查询节点上生成包含所述目标区块中的人脸相关数据的目标备份区块;将所述目标备份区块保存在所述查询节点上,并通过所述查询节点在所述区块链网络上广播所述目标备份区块的关联节点信息,以使所述区块链网络中的其他节点将所述关联节点信息中的内容保存至区块记录中,其中,所述关联节点信息包括所述查询节点的标识信息和所述目标节点的标识信息。In some embodiments of this application, based on the foregoing scheme, the download and generation unit is further configured to: monitor the working status of the target node through the query node; when the query node detects that the target node in the blockchain network is offline, download the face-related data in the target block generated by the target node from the server, and generate a target backup block containing the face-related data in the target block on the query node; save the target backup block on the query node, and broadcast the associated node information of the target backup block on the blockchain network through the query node, so that other nodes in the blockchain network save the content in the associated node information to the block record, wherein the associated node information includes the identification information of the query node and the identification information of the target node.
在本申请的一些实施例中,基于前述方案,所述下载和生成单元配置为:接收所述区块链网络中所述目标节点定期发来的工作状态信息;根据未定期接收到所述目标节点发来的工作状态信息,确定所述目标节点处于离线状态。In some embodiments of this application, based on the foregoing scheme, the download and generation unit is configured to: receive work status information periodically sent by the target node in the blockchain network; and determine that the target node is offline if it has not periodically received work status information from the target node.
在本申请的一些实施例中,基于前述方案,在通过所述查询节点在所述区块链网络上广播所述目标备份区块的关联节点信息之后,所述下载和生成单元还用于:根据接收到所述目标节点定期发来的工作状态信息,确定所述目标节点恢复至在线状态,并将存储的所述目标备份区块清除。In some embodiments of this application, based on the foregoing scheme, after the associated node information of the target backup block is broadcast on the blockchain network through the query node, the download and generation unit is further configured to: determine that the target node has recovered to the online state based on the working status information received periodically from the target node, and clear the stored target backup block.
在本申请的一些实施例中,基于前述方案,所述区块链网络中的各节点均能够采集人脸数据。In some embodiments of this application, based on the aforementioned scheme, each node in the blockchain network is able to collect facial data.
在本申请的一些实施例中,基于前述方案,所述区块链网络中的各节点用于刷脸支付,所述区块链网络中的各节点与同一商户标识对应。In some embodiments of this application, based on the aforementioned scheme, each node in the blockchain network is used for facial recognition payment, and each node in the blockchain network corresponds to the same merchant identifier.
在本申请的一些实施例中,基于前述方案,在响应于人脸识别请求,根据所述查询节点上保存的区块记录,遍历所述区块链中的各个区块以得到人脸识别结果之后,所述遍历单元还用于:如果检索到与所述人脸识别请求中的人脸数据匹配的所述人脸相关数据,则通过所述查询节点向所述服务端发送支付指令,由所述服务端对所述人脸相关数据对应的支付账户进行支付操作;如果未检索到与所述人脸识别请求中的人脸数据匹配的所述人脸相关数据,则通过所述查询节点将所述人脸数据上传至所述服务端,由所述服务端在确定出与所述人脸数据匹配的支付账户之后,对所述支付账户进行支付操作。In some embodiments of this application, based on the aforementioned scheme, after responding to a face recognition request and traversing each block in the blockchain according to the block records stored on the query node to obtain the face recognition result, the traversal unit is further configured to: if face-related data matching the face data in the face recognition request is found, then a payment instruction is sent to the server through the query node, and the server performs a payment operation on the payment account corresponding to the face-related data; if no face-related data matching the face data in the face recognition request is found, then the face data is uploaded to the server through the query node, and the server performs a payment operation on the payment account after determining the payment account matching the face data.
在本申请的一些实施例中,基于前述方案,所述遍历单元配置为:如果检索到与所述人脸识别请求中的人脸数据匹配的所述人脸相关数据,则在所述查询节点连通了网络时向所述服务端发送支付指令,由所述服务端对所述人脸相关数据对应的支付账户进行支付操作。In some embodiments of this application, based on the foregoing scheme, the traversal unit is configured to: if face-related data matching the face data in the face recognition request is retrieved, then when the query node is connected to the network, send a payment instruction to the server, and the server performs a payment operation on the payment account corresponding to the face-related data.
根据本申请实施例的一个方面,提供了一种计算机可读介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上述实施例中所述的人脸识别方法。According to one aspect of the embodiments of this application, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the face recognition method as described in the above embodiments.
根据本申请实施例的一个方面,提供了一种电子设备,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现如上述实施例中所述的人脸识别方法。According to one aspect of the embodiments of this application, an electronic device is provided, including: one or more processors; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the face recognition method as described in the above embodiments.
在本申请的一些实施例所提供的技术方案中,利用了终端设备作为区块链节点构建起一个区块链网络,区块链网络中的各终端设备在获取到人脸相关数据后就根据人脸相关数据生成区块并将区块上链,同时,各区块存储各生成区块的终端设备上,最终通过在区块链中进行检索来实现离线人脸识别。因此,人脸相关数据是从服务端下载至本地的,无需将人脸数据上传再进行人脸匹配,因此能够提升人脸识别的效率;人脸相关数据是分散存储于区块链网络中,每个节点只存储一部分人脸相关数据,在实现人脸识别特别是离线人脸识别的同时,不仅可以减少将人脸相关数据存储在终端本地所消耗的网络流量,还大大减少了存储人脸相关数据所消耗的存储资源,并且,由于人脸相关数据存储于区块链中,因此还能够保证数据存储的安全性,提高了用户隐私数据的安全性。In some embodiments of this application, a blockchain network is constructed using terminal devices as blockchain nodes. Each terminal device in the blockchain network generates a block based on the face-related data after acquiring it and uploads the block to the blockchain. Simultaneously, each block is stored on the terminal device that generated it, and offline face recognition is achieved by searching within the blockchain. Therefore, the face-related data is downloaded locally from the server, eliminating the need to upload the face data for face matching, thus improving the efficiency of face recognition. Furthermore, the face-related data is distributed across the blockchain network, with each node storing only a portion of the data. This not only reduces network traffic consumed by storing face-related data locally on the terminal but also significantly reduces storage resources. Moreover, since the face-related data is stored on the blockchain, data security is guaranteed, improving the security of user privacy data.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application.
附图说明Attached Figure Description
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。在附图中:The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:
图1示出了可以应用本申请实施例的技术方案的示例性系统架构的示意图;Figure 1 illustrates a schematic diagram of an exemplary system architecture to which the technical solutions of the embodiments of this application can be applied;
图2示出了根据本申请的一个实施例的人脸识别方法的流程图;Figure 2 shows a flowchart of a face recognition method according to an embodiment of this application;
图3示出了根据本申请的一个实施例的人脸识别方法的应用架构示意图;Figure 3 illustrates a schematic diagram of the application architecture of a face recognition method according to an embodiment of this application;
图4示出了根据本申请的一个实施例的区块链网络中节点从服务端下载人脸特征库时的状态监控界面示意图;Figure 4 shows a schematic diagram of the status monitoring interface of a node in a blockchain network downloading a face feature database from a server according to an embodiment of this application;
图5示出了根据本申请的一个实施例的区块的生成过程的流程图;Figure 5 shows a flowchart of the block generation process according to an embodiment of this application;
图6示出了根据本申请的一个实施例的图5中步骤530的细节的流程图;Figure 6 shows a flowchart detailing step 530 in Figure 5 according to an embodiment of this application;
图7示出了根据本申请的一个实施例的对区块链进行检索的流程图;Figure 7 illustrates a flowchart of blockchain retrieval according to an embodiment of this application;
图8示出了根据本申请的一个实施例的当区块链网络中的目标节点处于离线状态时的处理过程的流程图;Figure 8 shows a flowchart of the processing procedure when the target node in the blockchain network is offline, according to an embodiment of this application.
图9示出了根据本申请的一个实施例的图2中步骤250之后步骤的流程图;Figure 9 shows a flowchart of the steps following step 250 in Figure 2 according to an embodiment of this application;
图10示出了根据本申请的一个实施例的人脸识别装置的框图;Figure 10 shows a block diagram of a face recognition device according to an embodiment of this application;
图11示出了适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。Figure 11 shows a schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application.
具体实施方式Detailed Implementation
现在将参考附图更全面地描述示例实施方式。然而,示例实施方式能够以多种形式实施,且不应被理解为限于在此阐述的范例;相反,提供这些实施方式使得本申请将更加全面和完整,并将示例实施方式的构思全面地传达给本领域的技术人员。Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
此外,所描述的特征、结构或特性可以以任何合适的方式结合在一个或更多实施例中。在下面的描述中,提供许多具体细节从而给出对本申请的实施例的充分理解。然而,本领域技术人员将意识到,可以实践本申请的技术方案而没有特定细节中的一个或更多,或者可以采用其它的方法、组元、装置、步骤等。在其它情况下,不详细示出或描述公知方法、装置、实现或者操作以避免模糊本申请的各方面。Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
附图中所示的方框图仅仅是功能实体,不一定必须与物理上独立的实体相对应。即,可以采用软件形式来实现这些功能实体,或在一个或多个硬件模块或集成电路中实现这些功能实体,或在不同网络和/或处理器装置和/或微控制器装置中实现这些功能实体。The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and/or processor devices and/or microcontroller devices.
附图中所示的流程图仅是示例性说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解,而有的操作/步骤可以合并或部分合并,因此实际执行的顺序有可能根据实际情况改变。The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations/steps, nor do they necessarily have to be performed in the described order. For example, some operations/steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
目前,很多场景需要使用离线人脸识别。如前所述,在相关技术中,实现离线人脸识别的方案主要是将离线人脸特征库存储在终端的本地。而一个离线人脸特征库的文件大小往往高达几百兆,这样,既消耗了大量的网络流量,也占用了很多本地的存储资源,造成存储资源的浪费。Currently, many scenarios require offline facial recognition. As mentioned earlier, in related technologies, the main solution for implementing offline facial recognition is to store the offline facial feature database locally on the terminal. However, the file size of an offline facial feature database is often several hundred megabytes, which consumes a lot of network bandwidth and occupies a lot of local storage resources, resulting in a waste of storage resources.
为此,本申请首先提供了一种人脸识别方法。人脸识别是基于人的脸部特征信息进行身份识别的一种生物识别技术,该技术是用摄像机或摄像头采集含有人脸的图像或视频流,并自动在图像中检测和跟踪人脸,进而对检测到的人脸进行脸部识别的一系列相关技术,通常也叫做人像识别、面部识别。本申请的人脸识别方法通过将人脸相关数据是分散存储于区块链网络的各个节点中,并基于此进行人脸识别,可以减少存储人脸相关数据所消耗的网络流量和存储资源。Therefore, this application first provides a face recognition method. Face recognition is a biometric technology that identifies individuals based on their facial features. This technology involves using a camera or webcam to capture images or video streams containing faces, automatically detecting and tracking faces within the images, and then performing face recognition on the detected faces. It is also commonly referred to as portrait recognition or facial recognition. The face recognition method in this application reduces the network traffic and storage resources consumed in storing face-related data by distributing face-related data across various nodes in a blockchain network and performing face recognition based on this data.
图1示出了可以应用本申请实施例的技术方案的示例性系统架构的示意图。如图1所示,该系统架构可以包括区块链网络100、网络110以及云端服务器120,区块链网络100中至少包括第一节点101、第二节点102、第三节点103、第四节点104以及第五节点105,区块链网络100中各个节点均为刷脸物联网(Internet of Things,IoT)设备,刷脸物联网设备可以设置于商家的门店内,刷脸物联网设备具有摄像头,能够采集人脸数据,刷脸物联网设备用于在消费者付款时进行刷脸支付,并可以进行离线支付。区块链网络100中任意两个节点之间均可以进行通信,区块链网络100中的各个节点也均可以通过网络110与云端服务器120进行通信。利用图1所示系统架构实现人脸识别的过程如下:首先,区块链网络100中各个节点通过网络110从云端服务器120中下载数据,以获得人脸相关数据;接着,各个节点根据获得的人脸相关数据生成区块并将区块添加至区块链中,从而建立区块链,此时区块链存储在区块链网络中的多个节点上;最后,当区块链网络100中某一节点接收到人脸检索请求时,即当某一刷脸物联网设备需要进行刷脸支付时,通过在各个节点中对区块链进行人脸相关数据的检索,从而完成人脸识别。Figure 1 illustrates a schematic diagram of an exemplary system architecture to which the technical solutions of the embodiments of this application can be applied. As shown in Figure 1, the system architecture may include a blockchain network 100, a network 110, and a cloud server 120. The blockchain network 100 includes at least a first node 101, a second node 102, a third node 103, a fourth node 104, and a fifth node 105. Each node in the blockchain network 100 is a facial recognition Internet of Things (IoT) device. The facial recognition IoT device can be installed in a merchant's store. The facial recognition IoT device has a camera that can collect facial data. The facial recognition IoT device is used to make facial recognition payments when consumers pay, and it can also make offline payments. Any two nodes in the blockchain network 100 can communicate with each other, and each node in the blockchain network 100 can also communicate with the cloud server 120 through the network 110. The process of implementing face recognition using the system architecture shown in Figure 1 is as follows: First, each node in the blockchain network 100 downloads data from the cloud server 120 through network 110 to obtain face-related data; then, each node generates a block based on the obtained face-related data and adds the block to the blockchain, thereby establishing the blockchain, which is then stored on multiple nodes in the blockchain network; finally, when a node in the blockchain network 100 receives a face retrieval request, that is, when a face-scanning IoT device needs to make face-scanning payments, it completes face recognition by retrieving face-related data from the blockchain in each node.
需要说明的是,图1示出的仅为本申请的一个实施例。虽然图1实施例中人脸识别用于刷脸支付场景中,但本申请提供的人脸识别方法还可以应用于门禁等其他各种需要进行刷脸识别的场景;虽然图1实施例中,人脸相关数据是各节点从一个云端服务器下载得到的,但在本申请的其它实施例中,人脸相关数据可以由节点从包括多个服务器的服务器集群或数据库集群中下载得到;虽然图1实施例中区块链网络仅包括五个节点,但在其他实施例或者具体应用中,区块链网络中可以包括更多或更少的节点。本申请实施例对此不作任何限定,本申请的保护范围也不应因此而受到任何限制。It should be noted that Figure 1 shows only one embodiment of this application. Although the face recognition in the embodiment of Figure 1 is used in a face-scanning payment scenario, the face recognition method provided by this application can also be applied to access control and other scenarios requiring face recognition. Although in the embodiment of Figure 1, the face-related data is downloaded by each node from a cloud server, in other embodiments of this application, the face-related data can be downloaded by the nodes from a server cluster or database cluster including multiple servers. Although the blockchain network in the embodiment of Figure 1 includes only five nodes, in other embodiments or specific applications, the blockchain network may include more or fewer nodes. This application does not limit the scope of protection of this application in any way.
并且,易于理解,本申请实施例所提供的人脸识别方法由刷脸设备执行,相应地,人脸识别装置一般为刷脸设备。但是,在本申请的其它实施例中,服务器也可以与刷脸设备具有相似的功能,从而执行本申请实施例所提供的人脸识别的方案。Furthermore, it is easy to understand that the face recognition method provided in this application embodiment is executed by a face-scanning device, and correspondingly, the face recognition device is generally a face-scanning device. However, in other embodiments of this application, the server may also have similar functions to the face-scanning device, thereby executing the face recognition scheme provided in this application embodiment.
本申请实施例提供的人脸识别方法是基于区块链实现的。The face recognition method provided in this application is based on blockchain.
区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层。Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying platform, a platform product service layer, and an application service layer.
区块链底层平台可以包括用户管理、基础服务、智能合约以及运营监控等处理模块。其中,用户管理模块负责所有区块链参与者的身份信息管理,包括维护公私钥生成(账户管理)、密钥管理以及用户真实身份和区块链地址对应关系维护(权限管理)等,并且在授权的情况下,监管和审计某些真实身份的交易情况,提供风险控制的规则配置(风控审计);基础服务模块部署在所有区块链节点设备上,用来验证业务请求的有效性,并对有效请求完成共识后记录到存储上,对于一个新的业务请求,基础服务先对接口适配解析和鉴权处理(接口适配),然后通过共识算法将业务信息加密(共识管理),在加密之后完整一致的传输至共享账本上(网络通信),并进行记录存储;智能合约模块负责合约的注册发行以及合约触发和合约执行,开发人员可以通过某种编程语言定义合约逻辑,发布到区块链上(合约注册),根据合约条款的逻辑,调用密钥或者其它的事件触发执行,完成合约逻辑,同时还提供对合约升级注销的功能;运营监控模块主要负责产品发布过程中的部署、配置的修改、合约设置、云适配以及产品运行中的实时状态的可视化输出,例如:告警、监控网络情况、监控节点设备健康状态等。The underlying blockchain platform can include processing modules such as user management, basic services, smart contracts, and operational monitoring. The user management module is responsible for managing the identity information of all blockchain participants, including maintaining public and private key generation (account management), key management, and maintaining the correspondence between user real identities and blockchain addresses (access management). Furthermore, under authorization, it monitors and audits transactions of certain real identities and provides risk control rule configuration (risk control audit). The basic services module is deployed on all blockchain node devices to verify the validity of business requests. After consensus is reached on valid requests, they are recorded in storage. For a new business request, the basic services first perform interface adaptation parsing and authentication (interface adaptation), and then encrypt the business information through a consensus algorithm (consensus management). After encryption, the data is transmitted completely and consistently to the shared ledger (network communication) and recorded and stored. The smart contract module is responsible for contract registration, issuance, triggering, and execution. Developers can define contract logic using a programming language and publish it to the blockchain (contract registration). According to the contract terms, the key or other events are invoked to trigger execution and complete the contract logic. It also provides functions for contract upgrades and cancellations. The operation monitoring module is mainly responsible for deployment, configuration modification, contract settings, cloud adaptation, and real-time status visualization output during product release, such as alarms, monitoring network conditions, and monitoring the health status of node devices.
平台产品服务层提供典型应用的基本能力和实现框架,开发人员可以基于这些基本能力,叠加业务的特性,完成业务逻辑的区块链实现。应用服务层提供基于区块链方案的应用服务给业务参与方进行使用。The platform's product service layer provides the basic capabilities and implementation frameworks for typical applications. Developers can leverage these basic capabilities, along with the specific characteristics of their business needs, to implement blockchain-based business logic. The application service layer provides blockchain-based application services to business stakeholders.
以下对本申请实施例的技术方案的实现细节进行详细阐述:The implementation details of the technical solutions in the embodiments of this application are described in detail below:
图2示出了根据本申请的一个实施例的人脸识别方法的流程图,该人脸识别方法可以由具有计算和通信功能的终端设备来执行,这些终端设备还可以通过设置的摄像头采集人脸数据,比如可以是图1中刷脸IoT设备,具体可以为微信支付所使用的青蛙一代、青蛙二代等智能支付硬件设备。具体到图2实施例中,执行主体可以为以终端设备的形式存在的区块链网络中的节点,区块链网络中任一节点均可以执行本申请实施例的人脸识别方法。参照图2所示,该人脸识别方法至少包括以下步骤:Figure 2 shows a flowchart of a face recognition method according to an embodiment of this application. This face recognition method can be executed by a terminal device with computing and communication functions. These terminal devices can also collect facial data through a camera, such as the face-scanning IoT device shown in Figure 1, specifically the smart payment hardware devices used by WeChat Pay, such as the Frog Generation 1 and Frog Generation 2. Specifically, in the embodiment of Figure 2, the executing entity can be a node in a blockchain network existing in the form of a terminal device. Any node in the blockchain network can execute the face recognition method of this application embodiment. Referring to Figure 2, the face recognition method includes at least the following steps:
在步骤210中,以接入本地局域网的用于进行人脸识别的终端设备作为区块链节点,组建在本地局域网内进行数据通信的区块链网络。In step 210, a blockchain network for data communication within the local area network is established by using a terminal device connected to the local area network for face recognition as a blockchain node.
区块链网络包括生成并存储目标区块的目标节点以及用于查找目标区块的查询节点。A blockchain network includes target nodes that generate and store target blocks, and query nodes that are used to find target blocks.
此处的查询节点是区块链网络中目标节点之外的节点,区块链网络中可以包括多个查询节点。虽然本步骤中将区块链网络中的节点区分为目标节点和查询节点,但此处仅仅是为了使本申请的方案更易于理解。实际上,区块链网络中任意一个节点均可以生成并存储区块,区块链网络中任意一个节点也可以查找区块。The query node here refers to a node in the blockchain network other than the target node; a blockchain network can include multiple query nodes. Although this step distinguishes between target nodes and query nodes in the blockchain network, this is merely to make the scheme of this application easier to understand. In reality, any node in the blockchain network can generate and store blocks, and any node in the blockchain network can also search for blocks.
区块链网络中任意两个节点之间均可以进行通信,各节点上可以安装有客户端,节点之间可以利用客户端进行通信。本地局域网覆盖在一个较小的范围内,比如可以是一个学校、一个商场甚至是一个店铺。In a blockchain network, any two nodes can communicate with each other. Each node can have a client installed, and nodes can communicate with each other using the client. A local area network covers a relatively small area, such as a school, a shopping mall, or even a shop.
在步骤220中,在目标节点接入互联网的情况下,通过目标节点从服务端下载用于离线存储的人脸相关数据,并在目标节点上生成包含人脸相关数据的目标区块。In step 220, if the target node is connected to the Internet, the target node downloads face-related data for offline storage from the server and generates a target block containing the face-related data on the target node.
人脸相关数据是任何能够用于识别出人脸对应的身份信息的数据。比如人脸相关数据可以是人脸照片、人脸视频流中的某一图像帧、甚至还可以是人脸视频流中的一组图像帧等能够完整记录人脸信息的数据;此外,人脸相关数据还可以是从前面所说的人脸照片、一个图像帧或者一组图像帧等能够完整记录人脸信息的数据中提取到的人脸特征数据。此处的人脸特征数据是指能够描述人脸器官的形状以及它们之间的距离特性,并且有助于人脸分类的特征数据。Face-related data refers to any data that can be used to identify the identity information corresponding to a face. For example, face-related data can be a facial photograph, a single image frame from a facial video stream, or even a set of image frames from a facial video stream—data that can completely record facial information. Furthermore, face-related data can also be facial feature data extracted from the aforementioned facial photographs, single image frames, or sets of image frames that can completely record facial information. Here, facial feature data refers to feature data that can describe the shape of facial features and the distance characteristics between them, and is helpful for face classification.
在目标节点接入了互联网时,会从服务端下载人脸相关数据。区块是一种数据结构,其包括人脸相关数据,还可以包括其他信息。区块链网络中任一节点均可以从服务端下载用于离线存储的人脸相关数据。When the target node connects to the internet, it downloads face-related data from the server. A block is a data structure that includes face-related data and may also include other information. Any node in the blockchain network can download face-related data from the server for offline storage.
服务端可以为各种能够用于存储数据的终端或设备,比如可以是服务器或者服务器的集群,在云技术场景下,服务端还可以是位于云端的云服务器。The server can be any terminal or device that can be used to store data, such as a server or a cluster of servers. In cloud technology scenarios, the server can also be a cloud server located in the cloud.
目标节点可以在各种时刻根据多种方式、规则从服务端下载人脸相关数据。The target node can download face-related data from the server at various times according to various methods and rules.
比如,可以在目标节点进行系统初始化时从服务端下载人脸相关数据。For example, face-related data can be downloaded from the server when the target node performs system initialization.
图3示出了根据本申请的一个实施例的人脸识别方法的应用架构示意图。当本申请实施例的方案应用于图3时,实际上是应用于使用刷脸IoT设备进行刷脸支付的场景。请参见图3,从上至下排列的三个方框分别代表了该应用架构的三个部分,其中,位于中间的方框和位于下方的方框分别是私链终端网络中的两个部分,私链终端网络代表本实施例中区块链网络是利用终端设备建立起的私链形式的区块链网络。位于中间的方框中的内容描述了人脸相关数据在区块链网络中的区块链如何存储,位于下方的方框的内容则描述了基于私链终端网络进行刷脸支付的具体流程。根据图3中位于下方的方框中的内容可知,在开始刷脸之后,在区块链网络中的各节点进行特征检索,从而进行人脸识别。Figure 3 illustrates a schematic diagram of the application architecture of a face recognition method according to an embodiment of this application. When the solution of this embodiment is applied to Figure 3, it is actually applied to a scenario of using a face-scanning IoT device for face-scanning payment. Referring to Figure 3, the three boxes arranged from top to bottom represent the three parts of the application architecture. The middle box and the bottom box represent two parts of the private blockchain terminal network, which in this embodiment represents a private blockchain network established using terminal devices. The content in the middle box describes how face-related data is stored on the blockchain within the blockchain network, while the content in the bottom box describes the specific process of face-scanning payment based on the private blockchain terminal network. As shown in the content of the bottom box in Figure 3, after face scanning begins, feature retrieval is performed at each node in the blockchain network to achieve face recognition.
请参照图3,位于上方的方框中的后台即为服务端,其以人脸特征库的方式存储人脸相关数据,并且该人脸相关数据是人脸特征数据。人脸特征库是存储批量的人脸特征数据的文件,各人脸特征库的文件大小均为5M,各人脸特征库存储不同的人脸特征数据,这样可以批量并且有条理地实现对人脸特征数据的存储。区块链网络中的节点以人脸特征库为单位进行人脸相关数据的下载。具体而言,根据图3的位于中间的方框中的内容可知,其中,区块链网络中包括3个节点,分别为节点1、节点2以及节点3,其中,每个节点存储了若干区块,每个区块均包含3个特征库,每个特征库是由存储了包含该特征库的区块的节点从后台(服务端)下载的。Referring to Figure 3, the backend in the upper box is the server. It stores face-related data in the form of a face feature database, which is face feature data. The face feature database is a file storing batches of face feature data. Each face feature database is 5MB in size, and each database stores different face feature data, allowing for batch and organized storage of face feature data. Nodes in the blockchain network download face-related data in units of face feature databases. Specifically, as shown in the middle box of Figure 3, the blockchain network includes three nodes: Node 1, Node 2, and Node 3. Each node stores several blocks, and each block contains three feature databases. Each feature database is downloaded from the backend (server) by the node that stores the block containing that feature database.
在本申请实施例中,人脸相关数据是人脸特征数据,并且存储人脸特征数据的人脸特征库的文件大小为5M,该人脸特征库可以存储数十万人脸特征数据,由此可见,对于两个同样大小的文件,该文件所能存储的人脸特征数据的数量远远高于人脸照片的数量,因此,本申请实施例采用人脸特征库存储人脸特征数据可以大大减少进行人脸识别所消耗的存储资源。In this embodiment of the application, the face-related data is face feature data, and the file size of the face feature library storing the face feature data is 5M. This face feature library can store hundreds of thousands of face feature data. It can be seen that for two files of the same size, the number of face feature data that the file can store is far greater than the number of face photos. Therefore, the use of a face feature library to store face feature data in this embodiment of the application can greatly reduce the storage resources consumed by face recognition.
图4示出了根据本申请的一个实施例的区块链网络中节点从服务端下载人脸特征库时的状态监控界面示意图。请参见图4,该状态监控界面可以是在区块链网络中节点进行显示的,也可以是在服务端进行显示的。在图4中,顶部的大圆柱体代表服务端中所有人脸特征库被下载的状态,在该大圆柱体中深色部分与该大圆柱体的相对大小代表了所有人脸特征库中已下载的人脸特征库的数目与所有人脸特征库的总数的比例关系,同时,该界面还显示了具体的数目,其中,人脸特征库的总数为200,人脸特征库已下载数目为120;位于大圆柱体下方的小圆柱体代表区块链网络中各个节点存储容量的状态,在该小圆柱体中深色部分与该小圆柱体的相对大小代表了节点中已占用容量与总容量的比例关系,同时,该界面还显示了节点中的具体容量数值,比如,各节点的总容量均为1GB,节点1的可用容量为590MB,节点2的可用容量为390MB,节点3的可用容量为230MB。此外,节点1与服务端的连接线为虚线,而节点2、节点3与服务端的连接线为实线。这表示,在当前,节点1未从服务端下载数据,而节点2和节点3均正在从服务端下载数据。因此,通过图4所示的状态监控界面可以让人直观地了解区块链网络中节点从服务端下载人脸特征库时的整个系统的状态。Figure 4 illustrates a schematic diagram of the status monitoring interface of a node in a blockchain network downloading a facial feature database from a server, according to an embodiment of this application. Referring to Figure 4, this status monitoring interface can be displayed on the node in the blockchain network or on the server. In Figure 4, the large cylinder at the top represents the download status of all facial feature databases on the server. The relative size of the dark portion within this large cylinder represents the ratio of the number of downloaded facial feature databases to the total number of facial feature databases. The interface also displays specific numbers: the total number of facial feature databases is 200, and 120 have been downloaded. The smaller cylinder below the large cylinder represents the storage capacity status of each node in the blockchain network. The relative size of the dark portion within this smaller cylinder represents the ratio of the occupied capacity of a node to the total capacity. The interface also displays specific capacity values for each node; for example, the total capacity of each node is 1GB, with node 1 having 590MB of available capacity, node 2 having 390MB, and node 3 having 230MB. Furthermore, the connection line between node 1 and the server is a dashed line, while the connections between nodes 2 and 3 and the server are solid lines. This indicates that, currently, node 1 is not downloading data from the server, while nodes 2 and 3 are both downloading data from the server. Therefore, the status monitoring interface shown in Figure 4 provides a clear understanding of the overall system status in the blockchain network as nodes download the facial feature database from the server.
在服务端存储的人脸相关数据中,可以对区块链网络中各节点能够下载的人脸相关数据进行限制,使节点不能随意进行人脸相关数据的下载。The face-related data stored on the server can be restricted from being downloaded by each node in the blockchain network, preventing nodes from downloading face-related data arbitrarily.
在本申请的一个实施例中,通过目标节点从服务端下载用于离线存储的人脸相关数据,包括:通过目标节点从服务端下载与目标节点的地域标识信息对应的人脸相关数据。In one embodiment of this application, downloading face-related data for offline storage from the server via the target node includes: downloading face-related data corresponding to the geographic identification information of the target node from the server via the target node.
具体地,举例而言,目标节点的管理员可以通过对目标节点这一终端设备进行操作而向服务端发送下载请求,该下载请求中携带有目标节点的地域标识信息;而服务端存储着地域标识信息以及与地域标识信息对应的人脸相关数据;服务端在接收到由目标节点发来的下载请求之后,会得到该下载请求中目标节点的地域标识信息;服务端根据目标节点的地域标识信息向目标节点返回下载页面,该目标节点中包含与目标节点的地域标识信息对应的人脸相关数据的下载入口,目标节点的管理员可以通过该下载入口下载与目标节点的地域标识信息对应的人脸相关数据。Specifically, for example, the administrator of the target node can send a download request to the server by operating the target node as a terminal device. This download request carries the geographic identification information of the target node. The server stores the geographic identification information and the corresponding facial data. After receiving the download request from the target node, the server obtains the geographic identification information of the target node from the download request. Based on the geographic identification information of the target node, the server returns a download page to the target node. This target node contains a download entry for the facial data corresponding to the geographic identification information of the target node. The administrator of the target node can download the facial data corresponding to the geographic identification information of the target node through this download entry.
比如,支付场景中,可以为一个地区内的每个区域设置对应的地域标识信息,当商户购买刷脸IoT设备时,可以根据商户提供的地址提供相应的刷脸IoT设备,这些刷脸IoT设备中配置了商户的地址所属区域对应的地域标识信息,因此,这些刷脸IoT设备向服务端发送的下载请求可以携带各节点的地域标识信息。For example, in a payment scenario, corresponding regional identification information can be set for each area within a region. When a merchant purchases a facial recognition IoT device, the corresponding facial recognition IoT device can be provided based on the address provided by the merchant. These facial recognition IoT devices are configured with the regional identification information corresponding to the area where the merchant's address belongs. Therefore, the download requests sent by these facial recognition IoT devices to the server can carry the regional identification information of each node.
再比如,还是以支付场景为例,本申请实施例提供的人脸识别方法可以应用于支付系统中。支付系统包括服务端。每个用户在向支付系统的服务端注册支付账户时会提交住址、户籍地址、电话、人脸原始数据等信息,用户在使用支付系统时还可以向支付系统提供位置信息,如此,服务端便可以利用人脸原始数据生成人脸相关数据,同时,服务端还会根据用户提供的住址、户籍地址、电话、位置信息等信息确定这些信息对应的地域标识信息,进而,服务端可以将人脸相关数据与地域标识信息相关联。For example, taking the payment scenario as an example again, the facial recognition method provided in this application embodiment can be applied to a payment system. The payment system includes a server. When registering a payment account with the payment system's server, each user submits information such as address, registered address, telephone number, and raw facial data. When using the payment system, users can also provide location information. In this way, the server can use the raw facial data to generate facial-related data. At the same time, the server will also determine the corresponding geographic identification information based on the address, registered address, telephone number, and location information provided by the user. Then, the server can associate the facial-related data with the geographic identification information.
由此可见,在上述实施例中,刷脸IoT设备只需要下载与地域标识信息对应的人脸相关数据,因此,所需下载的人脸相关数据更少,从而能够节约网络资源和存储资源;同时,一个支付账户的住址、户籍地址、电话、位置信息等信息可能对应不同的地域标识信息,因而,本申请实施例中还可以允许将一个人脸相关数据与多个地域标识信息相关联,这样,提高了人脸相关数据的存储冗余性,使得同一个用户在不同地域的刷脸IoT设备中都能够进行离线刷脸支付,提高了用户体验。Therefore, in the above embodiments, the facial recognition IoT device only needs to download the face-related data corresponding to the regional identification information. Thus, less face-related data needs to be downloaded, thereby saving network and storage resources. At the same time, the address, registered address, telephone number, location information, and other information of a payment account may correspond to different regional identification information. Therefore, in this embodiment, it is also possible to associate one face-related data with multiple regional identification information. This improves the storage redundancy of face-related data, enabling the same user to make offline facial recognition payments on facial recognition IoT devices in different regions, thereby improving the user experience.
在本申请的一个实施例中,通过目标节点从服务端下载与目标节点的地域标识信息对应的人脸相关数据,包括:通过目标节点接收到服务端向区块链网络中的节点发来的广播信息,确定服务端中新增了与目标节点的地域标识信息对应的人脸相关数据,并从服务端下载与目标节点的地域标识信息对应的人脸相关数据,其中,广播信息中包含了目标节点的地域标识信息。In one embodiment of this application, downloading face-related data corresponding to the geographic identification information of the target node from the server by the target node includes: receiving broadcast information sent by the server to nodes in the blockchain network by the target node, determining that the server has added face-related data corresponding to the geographic identification information of the target node, and downloading face-related data corresponding to the geographic identification information of the target node from the server, wherein the broadcast information includes the geographic identification information of the target node.
本申请实施例中,一旦服务端中更新了人脸相关数据,相应的终端设备就能收到该服务端发来的广播信息,进而这些终端设备可以及时从服务端下载最近更新的人脸相关数据,保证了人脸识别的可靠性。In this embodiment, once the server updates the face-related data, the corresponding terminal device can receive the broadcast information sent by the server, and then these terminal devices can download the latest updated face-related data from the server in a timely manner, ensuring the reliability of face recognition.
在本申请的一个实施例中,从服务端下载用于离线存储的人脸相关数据是定期执行的。In one embodiment of this application, downloading face-related data from the server for offline storage is performed periodically.
在本申请的一个实施例中,在通过目标节点从服务端下载用于离线存储的人脸相关数据之前,所述方法还包括:确定目标节点在当天之前的预定天数内每天每小时接收到的人脸识别请求的频次;针对预定天数内的每一天,确定该天内接收到的人脸识别请求的频次最低的小时,作为该天的低频时段;根据各天的低频时段,确定当天的目标低频时段;通过目标节点从服务端下载用于离线存储的人脸相关数据,包括:在当天的目标低频时段通过目标节点从服务端下载用于离线存储的人脸相关数据。In one embodiment of this application, before downloading face-related data for offline storage from the server via the target node, the method further includes: determining the frequency of face recognition requests received by the target node every hour of every day within a predetermined number of days prior to the current day; for each day within the predetermined number of days, determining the hour with the lowest frequency of face recognition requests received that day as the low-frequency period for that day; determining the target low-frequency period for the current day based on the low-frequency periods for each day; and downloading face-related data for offline storage from the server via the target node, including: downloading face-related data for offline storage from the server via the target node during the target low-frequency period of the current day.
在本申请的一个实施例中,根据各天的低频时段,确定当天的目标低频时段,包括:确定各低频时段对应的天数;将对应的天数最大的低频时段作为当天的目标低频时段。In one embodiment of this application, determining the target low-frequency period of a day based on the low-frequency periods of each day includes: determining the number of days corresponding to each low-frequency period; and taking the low-frequency period with the largest number of days as the target low-frequency period of the day.
比如,预定天数为7天,那么,若低频时段为21:00-22:00的天数为1,低频时段为22:00-23:00的天数为2,低频时段为23:00-24:00的天数为4,那么,确定出的目标低频时段为23:00-24:00,也就是说,将在当天的23:00-24:00内从服务端下载人脸相关数据。For example, if the reservation period is 7 days, then if the number of days with low frequency period from 21:00 to 22:00 is 1, the number of days with low frequency period from 22:00 to 23:00 is 2, and the number of days with low frequency period from 23:00 to 24:00 is 4, then the determined target low frequency period is 23:00 to 24:00. In other words, the face-related data will be downloaded from the server within 23:00 to 24:00 on the same day.
当终端设备在一个小时内接收到的人脸识别请求的频次比较大时,说明该终端设备的负荷较高,此时若从服务端下载人脸相关数据,则会进一步加大终端设备的负荷,并可能影响终端设备的性能。本申请实施例中,通过预测当天的低频时段并在低频时段下载人脸相关数据,从而在终端设备负荷较低时再从服务端下载数据,避免影响终端设备的性能;同时,当天的低频时段是根据当天之前的预定天数内各小时接收到的人脸识别请求的频次来确定的,能够提高所预测的低频时段的准确性。When a terminal device receives a high frequency of face recognition requests within an hour, it indicates a high load on the device. Downloading face-related data from the server at this time would further increase the load and potentially impact the device's performance. In this embodiment, by predicting the low-frequency periods of the day and downloading face-related data during these periods, data is downloaded from the server when the terminal device's load is low, thus avoiding impacting its performance. Furthermore, the low-frequency periods are determined based on the frequency of face recognition requests received in each hour within a predetermined number of days prior to the current day, improving the accuracy of the predicted low-frequency periods.
在本申请的一个实施例中,区块链网络中各节点在向服务端发送下载请求之后,将各下载请求按照请求的时间先后顺序发送至请求消息队列中,各节点按照所发送的下载请求在请求消息队列中排序的顺序依次从服务端下载人脸相关数据。In one embodiment of this application, after each node in the blockchain network sends a download request to the server, it sends the download requests to the request message queue in the order of the request time. Each node downloads face-related data from the server in the order in which the downloaded requests are sorted in the request message queue.
在本申请实施例中,各节点的下载请求会被按照发送顺序被存储至请求消息队列中,并由服务端对各下载请求依次进行处理,利用消息队列实现了对下载请求的削峰处理,避免了服务端因短时间内收到大量下载请求而导致系统崩溃,提高了系统的可用性。In this embodiment, download requests from each node are stored in a request message queue in the order they are sent, and the server processes each download request sequentially. The message queue is used to smooth out the peaks of download requests, preventing the server from crashing due to a large number of download requests received in a short period of time, thus improving the availability of the system.
在本申请的一个实施例中,目标节点是区块链网络中连续处于空闲状态的时间最长的终端设备,其中,空闲状态是终端设备未下载人脸相关数据且未生成区块的状态。In one embodiment of this application, the target node is the terminal device in the blockchain network that has been in an idle state for the longest period of time. The idle state is the state in which the terminal device has not downloaded face-related data and has not generated a block.
也就是说,目标节点是各终端设备中空闲时间最长的终端设备,空闲时间是最近一次生成区块的时刻距离当前时刻的时间。可以对各终端设备对应的空闲时间长度从大到小进行排序,各终端设备按照该排序依次下载人脸相关数据,并根据人脸相关数据生成和打包区块。In other words, the target node is the terminal device with the longest idle time among all terminal devices. Idle time is the time between the last time a block was generated and the current time. The idle time lengths of each terminal device can be sorted from largest to smallest, and each terminal device downloads face-related data sequentially according to this sorting, and generates and packages blocks based on the face-related data.
本申请实施例中,各终端设备按照空闲时间的长短依次进行人脸相关数据的下载和区块的生成,不仅大大减轻了服务端的压力,更能够充分区块链网络中的闲置终端设备,提高了资源的利用率。In this embodiment, each terminal device downloads face-related data and generates blocks sequentially according to the length of its idle time. This not only greatly reduces the pressure on the server but also makes full use of idle terminal devices in the blockchain network, thereby improving resource utilization.
在本申请的一个实施例中,区块生成过程的具体步骤如图5所示。图5示出了根据本申请的一个实施例的区块的生成过程的流程图。请参见图5,具体包括以下步骤:In one embodiment of this application, the specific steps of the block generation process are shown in Figure 5. Figure 5 illustrates a flowchart of the block generation process according to an embodiment of this application. Referring to Figure 5, the process specifically includes the following steps:
在步骤510中,获取目标节点的标识信息和最新加入区块链的区块中的第一哈希值。In step 510, the identification information of the target node and the first hash value in the latest block added to the blockchain are obtained.
目标节点的标识信息是能够唯一标识一个目标节点的信息,目标节点的标识信息的数据类型可以为字符串,其可以包括字母、数字、下划线等。The identification information of a target node is information that can uniquely identify a target node. The data type of the identification information of a target node can be a string, which can include letters, numbers, underscores, etc.
加入区块链的各区块依次连接组成区块链。因此,各区块在加入至区块链中时,具有一定的顺序。最新加入区块链的区块即当前时间之前最后一个加入区块链的区块,每个区块中都有一个哈希值。The blocks added to the blockchain are linked together sequentially to form the blockchain. Therefore, the blocks are added to the blockchain in a specific order. The most recently added block is the last block added before the current time, and each block contains a hash value.
在步骤520中,根据目标节点的标识信息、第一哈希值和人脸相关数据确定第二哈希值。In step 520, the second hash value is determined based on the target node's identification information, the first hash value, and face-related data.
具体来说,对第一哈希值、人脸相关数据和目标节点的标识信息的组合进行哈希运算,得到第二哈希值。Specifically, a hash operation is performed on the combination of the first hash value, face-related data, and the identification information of the target node to obtain the second hash value.
在步骤530中,基于目标节点的标识信息、人脸相关数据、第一哈希值和第二哈希值生成区块。In step 530, a block is generated based on the target node's identification information, face-related data, first hash value, and second hash value.
第二哈希值在生成的区块中的作用和位置与第一哈希值在前述的最新加入区块链的区块中的作用和位置是类似的。The role and position of the second hash value in the generated block are similar to the role and position of the first hash value in the most recently added block of the blockchain.
在本申请的一个实施例中,步骤530的具体步骤可以如图6所示。图6示出了根据本申请的一个实施例的图5中步骤530的细节的流程图。如图6所示,步骤530具体包括以下步骤:In one embodiment of this application, the specific steps of step 530 can be as shown in FIG6. FIG6 shows a flowchart detailing step 530 in FIG5 according to an embodiment of this application. As shown in FIG6, step 530 specifically includes the following steps:
在步骤531中,对人脸相关数据进行加密,得到加密后的人脸相关数据。In step 531, the face-related data is encrypted to obtain encrypted face-related data.
在本申请的一个实施例中,对人脸相关数据进行加密,得到加密后的人脸相关数据,包括:利用在目标节点的本地存储的密钥对人脸相关数据进行加密,得到加密后的人脸相关数据,其中,密钥无法被目标节点的使用人员获取。In one embodiment of this application, encrypting face-related data to obtain encrypted face-related data includes: encrypting face-related data using a key stored locally on the target node to obtain encrypted face-related data, wherein the key cannot be obtained by the user of the target node.
比如,在支付场景中,可以使用对称密钥对人脸相关数据进行加密,对称密钥被烧录在刷脸IoT设备的ROM(Read-Only Memory,只读存储器)上。通过将对称密钥烧录在刷脸IoT设备的ROM中,使得对称密钥无法通过技术手段被强制获取,提高了数据存储的安全性。For example, in payment scenarios, symmetric keys can be used to encrypt facial recognition data. These symmetric keys are programmed into the ROM (Read-Only Memory) of the facial recognition IoT device. By programming the symmetric key into the ROM, it becomes impossible to forcibly obtain it through technical means, thus improving data storage security.
在本申请的一个实施例中,在对人脸相关数据进行加密,得到加密后的人脸相关数据之前,还包括:获取服务端定期发来的加密后的对称密钥,加密后的对称密钥由服务端利用目标节点的公钥对对称密钥加密而成;基于目标节点的私钥对加密后的对称密钥进行解密,得到对称密钥;对人脸相关数据进行加密,得到加密后的人脸相关数据,包括:利用对称密钥对人脸相关数据进行加密,得到加密后的人脸相关数据。In one embodiment of this application, before encrypting the face-related data to obtain the encrypted face-related data, the method further includes: obtaining an encrypted symmetric key periodically sent by the server, wherein the encrypted symmetric key is generated by the server using the public key of the target node to encrypt the symmetric key; decrypting the encrypted symmetric key based on the private key of the target node to obtain the symmetric key; and encrypting the face-related data to obtain the encrypted face-related data, which includes: encrypting the face-related data using the symmetric key to obtain the encrypted face-related data.
目标节点的私钥和对称密钥一样都烧录在目标节点的ROM中,以提高安全性。The target node's private key, like its symmetric key, is burned into the target node's ROM to enhance security.
在本申请实施例中,实现了对终端设备中对称密钥的自动更新,有效保证了人脸相关数据的加密安全性,并且由于对称密钥是服务端利用终端设备的公钥加密生成的,而终端设备的私钥只存储于终端设备上,因此只有终端设备能够获得对称密钥的明文,从而提高了对称密钥的传输安全性。In this embodiment, the automatic updating of the symmetric key in the terminal device is realized, which effectively ensures the encryption security of face-related data. Since the symmetric key is generated by the server using the public key of the terminal device, and the private key of the terminal device is only stored on the terminal device, only the terminal device can obtain the plaintext of the symmetric key, thereby improving the transmission security of the symmetric key.
在步骤532中,将目标节点的标识信息、加密后的人脸相关数据、第一哈希值和第二哈希值打包成区块。In step 532, the target node's identification information, encrypted face-related data, first hash value, and second hash value are packaged into a block.
具体而言,将目标节点的标识信息、加密后的人脸相关数据、第一哈希值和第二哈希值这些信息按照区块的数据结构进行数据封装,从而得到区块,这些信息在区块中的排列顺序可以是任意的。Specifically, the target node's identification information, encrypted face-related data, first hash value, and second hash value are encapsulated according to the block's data structure to obtain a block. The order of these information in the block can be arbitrary.
由于区块链中人脸相关数据经过了加密,所以当需要进行人脸检索时,需要对加密后的人脸相关数据进行解密处理。Because face-related data in the blockchain is encrypted, it is necessary to decrypt the encrypted face-related data when face retrieval is required.
根据图6所示的实施例,通过先对人脸相关数据进行加密,然后再进行区块的打包,进一步提高了人脸相关数据的安全性,避免用户隐私出现泄露。According to the embodiment shown in Figure 6, by first encrypting the face-related data and then packaging it into blocks, the security of the face-related data is further improved, and the leakage of user privacy is avoided.
在本申请的一个实施例中,人脸相关数据存储在位于服务端的人脸特征库中,该方法还包括:若根据正在下载的目标人脸特征库的大小,判断在下载了目标人脸特征库之后,根据已下载但未打包的人脸特征库打包成的区块文件大小将会超过预定文件大小,则将在当前已下载但未打包的人脸特征库打包成区块。In one embodiment of this application, face-related data is stored in a face feature database located on the server. The method further includes: if, based on the size of the target face feature database being downloaded, it is determined that the size of the block file packaged from the downloaded but unpackaged face feature database will exceed a predetermined file size after the target face feature database is downloaded, then the currently downloaded but unpackaged face feature database will be packaged into a block.
目标人脸特征库在当前正在下载,因此,当前已下载但未打包的人脸特征库不包括目标人脸特征库。The target facial feature library is currently being downloaded; therefore, the facial feature library that has been downloaded but not yet packaged does not include the target facial feature library.
请继续参见图3,根据位于中间的方框中的内容可知,每个区块包括前一个区块的哈希值和当前区块的哈希值,各区块依据哈希值依次相连,组成区块链。每个区块均包括3个人脸特征库,比如创世区块包括特征库1、特征库2以及特征库3,区块1则包括特征库4、特征库5以及特征库6,以此类推,其中才,创世区块是区块链中首个生成的区块,其在进行区块打包时所依据哈希值为空值。在本申请实施例中,当每台刷脸IoT设备下载的人脸特征库即将超过20M时,该刷脸IoT设备负责将这些人脸特征库打包集成为一个区块文件。由于每个人脸特征库的文件大小为5M,因此,当下载了三个人脸特征库之后,刷脸IoT设备就需要将这些人脸特征库打包成区块,这是因为区块中还包括哈希值、节点的标识信息等其他信息,若下载4个人脸特征库之后再进行打包,将会导致区块过大。Please refer to Figure 3. As shown in the middle box, each block includes the hash value of the previous block and the hash value of the current block. Blocks are sequentially linked based on their hash values to form a blockchain. Each block includes three facial feature databases. For example, the genesis block includes feature databases 1, 2, and 3; block 1 includes feature databases 4, 5, and 6, and so on. The genesis block is the first block generated in the blockchain, and its hash value is empty when it is packaged. In this embodiment, when the facial feature database downloaded by each facial recognition IoT device is about to exceed 20MB, the device is responsible for packaging these databases into a single block file. Since each facial feature database file is 5MB, after downloading three databases, the device needs to package them into a block. This is because the block also includes hash values, node identification information, and other information. Downloading four databases before packaging would result in an excessively large block.
请继续参见图2,在步骤230中,将目标区块保存在目标节点上,并通过目标节点在区块链网络上广播目标区块的上链信息。Please refer to Figure 2. In step 230, the target block is stored on the target node, and the on-chain information of the target block is broadcast on the blockchain network through the target node.
上链信息用于表示目标区块与区块链上的其他区块的链接关系。On-chain information is used to represent the link relationship between the target block and other blocks on the blockchain.
区块链网络中终端设备从服务端下载的人脸相关数据最终以区块的形式进行存储。区块链网络上目标节点之外的其他节点均可以接收到上链信息。In a blockchain network, facial recognition data downloaded by terminal devices from the server is ultimately stored in the form of blocks. All nodes on the blockchain network, except the target node, can receive the information uploaded to the chain.
具体地,上链信息中可以包括目标区块中的标识信息、第一哈希值及第二哈希值,由于第一哈希值属于最新加入区块链的区块,因此,基于最新加入区块链的区块中的第一哈希值和目标区块中的第二哈希值可以确定目标区块与其他区块的链接关系;当然,上链信息中可以仅包括目标区块中的标识信息、第二哈希值及时间戳,时间戳反映了上链信息的发送时间,因此,基于时间戳的先后顺序可以确定目标区块与其他区块的链接关系。Specifically, the on-chain information may include the identifier information, first hash value, and second hash value of the target block. Since the first hash value belongs to the most recently added block, the link relationship between the target block and other blocks can be determined based on the first hash value of the most recently added block and the second hash value of the target block. Of course, the on-chain information may only include the identifier information, second hash value, and timestamp of the target block. The timestamp reflects the time when the on-chain information was sent. Therefore, the link relationship between the target block and other blocks can be determined based on the order of the timestamps.
在步骤240中,当查询节点接收到区块链网络中广播的上链信息时,在查询节点上保存根据上链信息生成的区块记录。In step 240, when the query node receives the on-chain information broadcast in the blockchain network, it saves the block record generated based on the on-chain information on the query node.
区块记录包括用于查找目标区块的查询路径。Block records include query paths used to locate the target block.
区块记录中的数据形式可以是各种各样的。区块记录中包括区块链中各个区块的链接关系,这些链接关系是各个区块的查询路径的一部分。The data in a block record can take many forms. A block record includes links between blocks in the blockchain, and these links form part of the query path for each block.
具体地,在本申请的一个实施例中,上链信息包括哈希值和目标节点的标识信息,当查询节点接收到区块链网络中广播的上链信息时,在查询节点上保存根据上链信息生成的区块记录,包括:当查询节点接收到区块链网络中广播的上链信息时,将上链信息中包含的哈希值和目标节点的标识信息作为区块记录保存至查询节点上。Specifically, in one embodiment of this application, the on-chain information includes a hash value and the identification information of the target node. When the query node receives the on-chain information broadcast in the blockchain network, it saves the block record generated based on the on-chain information on the query node, including: when the query node receives the on-chain information broadcast in the blockchain network, it saves the hash value and the identification information of the target node contained in the on-chain information as a block record on the query node.
实际上,上链信息可以是区块记录的一部分,上链信息对应着区块记录中目标区块的这一部分。In fact, the information uploaded to the blockchain can be a part of the block record, and the information uploaded to the blockchain corresponds to this part of the target block in the block record.
被作为区块记录保存至查询节点上的上链信息中的哈希值,既可以是第二哈希值,也可以同时包括第一哈希值和第二哈希值。当该哈希值为第二哈希值时,上链信息中还可以包括时间戳,还可以将时间戳作为区块记录保存至查询节点上。这些时间戳的先后顺序代表着各个区块的链接关系。The hash value in the on-chain information saved as a block record on the query node can be either a second hash value or a combination of both. When the hash value is the second hash value, the on-chain information can also include a timestamp, which can also be saved as a block record on the query node. The order of these timestamps represents the linking relationship between the blocks.
本申请实施例通过向区块链网络中的其他节点广播上链信息实现了区块链的建立,使得每个被添加到区块链中的区块都能够得到新加入区块链中的区块的信息。This application embodiment establishes a blockchain by broadcasting on-chain information to other nodes in the blockchain network, so that each block added to the blockchain can receive information about the newly added blocks.
在步骤250中,响应于人脸识别请求,根据查询节点上保存的区块记录,遍历区块链中的各个区块以得到人脸识别结果。In step 250, in response to the face recognition request, the blockchain is traversed according to the block records stored on the query node to obtain the face recognition result.
人脸识别请求的内容中包含了人脸数据。人脸识别请求通常是根据依赖于人脸识别的功能模块的调用而触发的。比如,在支付场景中,功能模块为支付模块,当用户在刷脸IoT设备上进行刷脸支付操作时,就会触发生成人脸识别请求。需要指出的是,此处的人脸识别请求可以不是网络请求,比如可以为接口调用请求或者方法之间的参数传递。The content of a face recognition request includes facial data. Face recognition requests are typically triggered by calls to functional modules that rely on face recognition. For example, in a payment scenario, the functional module is the payment module; when a user performs a face-scanning payment operation on a face-scanning IoT device, a face recognition request is generated. It should be noted that this face recognition request does not necessarily have to be a network request; it can be an API call request or a parameter passing between methods.
人脸数据是任何能够用于识别出人脸对应的身份信息的数据。比如人脸数据可以是人脸照片、人脸视频流中的某一图像帧、甚至还可以是人脸视频流中的一组图像帧等能够完整记录人脸信息的数据;此外,人脸数据还可以是从前面所说的人脸照片、一个图像帧或者一组图像帧等能够完整记录人脸信息的数据中提取到的人脸特征数据。Facial data is any data that can be used to identify the identity information corresponding to a face. For example, facial data can be a facial photograph, a single image frame from a facial video stream, or even a set of image frames from a facial video stream—data that can completely record facial information. In addition, facial data can also be facial feature data extracted from the aforementioned facial photographs, single image frames, or sets of image frames—data that can completely record facial information.
接收到人脸识别请求的节点可以是区块链网络中的任意一个查询节点。由于区块记录中包括各区块的查询路径,因此,可以根据区块记录实现对区块链中的各个区块的遍历。The node receiving the face recognition request can be any query node in the blockchain network. Since the block record includes the query path for each block, it is possible to traverse each block in the blockchain based on the block record.
对区块链中区块进行遍历实际上就是对区块链进行检索的过程,人脸识别结果是由区块链网络中的节点提供的,当对区块链网络中的各节点进行检索时,各节点可以返回人脸识别结果。在本申请实施例中,区块链中的区块是根据人脸相关数据生成。因此,通过对区块链进行检索,可以确定出与人脸数据对应的人脸相关数据,而人脸相关数据绑定的身份信息是已知的,因而能够识别出人脸数据对应的身份信息。Traversing blocks in a blockchain is essentially a process of searching the blockchain. Facial recognition results are provided by nodes in the blockchain network; when searching each node, each node can return the facial recognition result. In this embodiment, the blocks in the blockchain are generated based on facial-related data. Therefore, by searching the blockchain, facial-related data corresponding to facial data can be identified. Since the identity information bound to the facial-related data is known, the identity information corresponding to the facial data can be recognized.
如果在目标节点上进行检索发现目标区块中的人脸相关数据与人脸识别请求中包含的人脸数据相匹配,那么目标节点将会向接收到人脸识别请求的节点返回人脸识别结果,区块链网络中的节点返回的人脸识别结果的形式可以是多种多样的。If a search on the target node reveals that the face-related data in the target block matches the face data included in the face recognition request, then the target node will return the face recognition result to the node that received the face recognition request. The form of the face recognition result returned by the node in the blockchain network can be varied.
比如,节点上可以存储与人脸相关数据对应的身份信息,当在一个节点上检索到与人脸数据匹配的人脸相关数据时,该节点可以将该人脸相关数据对应的身份信息作为人脸识别结果返回,当在该节点上未检索到与人脸数据匹配的人脸相关数据时,该节点返回的人脸识别结果可以为“未检索到相关数据”等类似能够表示查询失败的信息。此处的身份信息可以为任何能够唯一标识人脸对应的身份的信息,例如,身份信息可以是用户的身份证号、银行卡号、手机号等用户固有的信息,还可以是与身份证号、银行卡号、手机号等用户固有的信息一一对应的标识信息。For example, nodes can store identity information corresponding to face-related data. When a node retrieves face-related data that matches the face data, it can return the corresponding identity information as the face recognition result. If no face-related data matching the face data is found on the node, the node can return a face recognition result such as "No relevant data found," indicating a failed query. This identity information can be any information that uniquely identifies the identity corresponding to the face. For example, identity information can be a user's ID card number, bank card number, mobile phone number, or other user-specific information, or it can be identification information that corresponds one-to-one with user-specific information such as ID card number, bank card number, and mobile phone number.
再比如,当在一个节点上检索到与人脸数据匹配的人脸相关数据时,该节点可以将“查询成功”或者类似的能够表示查询成功的信息作为人脸识别结果返回,当在该节点上未检索到与人脸数据匹配的人脸相关数据时,该节点返回的人脸识别结果可以为“查询失败”或者相关的能够表示查询失败的信息。For example, when a node retrieves face-related data that matches the face data, the node can return "query successful" or similar information indicating a successful query as the face recognition result. When no face-related data matching the face data is retrieved at the node, the face recognition result returned by the node can be "query failed" or similar information indicating a failed query.
图7示出了根据本申请的一个实施例的对区块链进行检索的流程图。Figure 7 shows a flowchart of a blockchain retrieval process according to an embodiment of this application.
请参阅图7,包括以下步骤:Please refer to Figure 7, which includes the following steps:
在步骤710中,获取人脸识别请求中的人脸数据。In step 710, the face data in the face recognition request is obtained.
人脸识别请求中携带有人脸数据。The facial recognition request carries facial data.
此处的人脸相关数据既可以是人脸照片等能够完整记录人脸信息的数据,还可以是前述的能够描述人脸器官的形状以及它们之间的距离特性、并且有助于人脸分类的人脸特征数据。The face-related data here can be either face photos or other data that can completely record face information, or the aforementioned face feature data that can describe the shape of face organs and the distance characteristics between them, and help with face classification.
在步骤720中,根据区块记录中的哈希值和节点的标识信息,确定区块链中各区块的查询路径。In step 720, the query path for each block in the blockchain is determined based on the hash value in the block record and the node's identification information.
每个区块在打包上链时,其他终端设备会接收到打包该区块的终端设备广播的上链信息,上链信息中的哈希值和终端设备的标识信息会被存储至区块记录中。When each block is packaged and uploaded to the blockchain, other terminal devices will receive the on-chain information broadcast by the terminal device that packaged the block. The hash value and the terminal device's identification information in the on-chain information will be stored in the block record.
根据区块记录中的哈希值(比如第一哈希值和第二哈希值),可以确定各个区块的链接关系,因此,区块链网络中各个终端设备均知晓区块链中各区块的连接顺序;再根据区块记录中各哈希值对应的节点的标识信息,就可以确定用于表示依次向区块链网络中哪个节点上的哪个区块进行查询的查询路径。Based on the hash values (such as the first hash value and the second hash value) in the block record, the linking relationship of each block can be determined. Therefore, each terminal device in the blockchain network knows the connection order of each block in the blockchain. Then, based on the node identification information corresponding to each hash value in the block record, the query path used to indicate which block on which node in the blockchain network to query in sequence can be determined.
在步骤730中,根据查询路径,依次向区块链网络中各节点发送人脸数据,由各节点在存储的区块中进行检索,得到各节点返回的人脸识别结果。In step 730, according to the query path, face data is sent to each node in the blockchain network in sequence, and each node retrieves the face recognition results returned by each node in the stored blocks.
当在各终端设备上存储的人脸相关数据经过加密后,需要先进行解密,然后再判断存储的人脸相关数据是否与人脸数据匹配,各终端设备具体可以通过深度学习模型等各种算法确定人脸相关数据与人脸数据是否相匹配。After the face-related data stored on various terminal devices is encrypted, it needs to be decrypted first, and then it needs to be determined whether the stored face-related data matches the face data. Each terminal device can use various algorithms such as deep learning models to determine whether the face-related data matches the face data.
通过图3还可以看到,不同区块分散存储在多个节点上。节点上除了包括存储的区块之外,还包括区块链中各区块在节点上的存储顺序,这个存储顺序即为区块的查询路径,其与区块链中区块的连接关系相对应。举例而言,创世区块位于节点1上,而区块1位于节点3上,因此,创世区块和区块1对应的存储顺序为节点1->节点3,即需要先向节点1发送人脸数据,再向节点3发送人脸数据。Figure 3 also shows that different blocks are distributed and stored across multiple nodes. In addition to the stored blocks, each node also displays the storage order of the blocks in the blockchain. This storage order is the block query path, which corresponds to the connection relationship between blocks in the blockchain. For example, the genesis block is located on node 1, while block 1 is located on node 3. Therefore, the storage order of the genesis block and block 1 is node 1 -> node 3, meaning that facial data needs to be sent to node 1 first, and then to node 3.
根据图7所示的实施例,可以依据区块在各终端设备上的存储顺序对人脸数据进行检索,从而避免了重复检索,保证了检索效率。According to the embodiment shown in Figure 7, face data can be retrieved based on the storage order of blocks on each terminal device, thereby avoiding repeated retrieval and ensuring retrieval efficiency.
在本申请的一个实施例中,若在区块链网络中的一个节点上未检索到与人脸数据匹配的人脸相关数据,该节点会根据查询路径直接向下一个节点发送人脸数据。In one embodiment of this application, if no face-related data matching the face data is found on a node in the blockchain network, the node will directly send the face data to the next node according to the query path.
在本申请实施例中,当在一个终端设备上未检索到匹配的人脸相关数据时,当前终端设备无需在接收到该终端设备返回的人脸识别结果之后再向其他终端设备发送人脸数据,提高了人脸识别效率。本申请实施例还实现了备份机制。In this embodiment, when no matching face-related data is found on a terminal device, the current terminal device does not need to send face data to other terminal devices after receiving the face recognition result returned by that terminal device, thus improving face recognition efficiency. This embodiment also implements a backup mechanism.
图8示出了根据本申请的一个实施例的当区块链网络中的目标节点处于离线状态时的处理过程的流程图。请参见图8,备份机制可通过如下过程实现:Figure 8 illustrates a flowchart of the processing procedure when a target node in a blockchain network is offline, according to an embodiment of this application. Referring to Figure 8, the backup mechanism can be implemented through the following process:
在步骤810中,通过查询节点监听目标节点的工作状态。In step 810, the working status of the target node is monitored by querying the node.
在本申请的一个实施例中,通过查询节点监听目标节点的工作状态,包括:接收区块链网络中目标节点定期发来的工作状态信息;根据未定期接收到目标节点发来的工作状态信息,确定目标节点处于离线状态。In one embodiment of this application, the monitoring of the target node's working status by querying the node includes: receiving working status information periodically sent by the target node in the blockchain network; and determining that the target node is offline if working status information is not periodically received from the target node.
举例来说,整个区块链网络中所有终端设备会每隔5分钟会向其他终端设备发放一次广播消息,告知当前自身的状态信息,因此,对于每个终端设备而言,它们近似于实时的知道链上每个终端设备的存活状态;在当前终端设备最近一次收到来自目标终端设备的广播信息的时刻距离当前时刻的时长超过预定时长时,可以确定目标终端设备处于离线状态。For example, every 5 minutes, all terminal devices in the entire blockchain network will broadcast a message to other terminal devices to inform them of their current status. Therefore, each terminal device knows the liveness status of each other on the chain in near real time. If the time elapsed between the current terminal device receiving the broadcast message from the target terminal device and the current time exceeds a predetermined time, it can be determined that the target terminal device is offline.
在本申请实施例中,通过根据未定期接收到区块链网络中其他终端设备发来的工作状态信息而确定其他终端设备处于离线状态,使得区块链网络中某一终端设备在出现宕机、故障等事故时,区块链网络中其他终端设备也能够获知该终端设备的状态信息,提高了区块链网络的运行可靠性。In this embodiment, by determining that other terminal devices are offline based on the fact that they have not periodically received working status information from other terminal devices in the blockchain network, other terminal devices in the blockchain network can also know the status information of a terminal device when it crashes or malfunctions, thereby improving the operational reliability of the blockchain network.
在步骤820中,当查询节点监听到区块链网络中的目标节点处于离线状态时,从服务端下载已由目标节点生成的目标区块中的人脸相关数据,并在查询节点上生成包含目标区块中的人脸相关数据的目标备份区块。In step 820, when the query node detects that the target node in the blockchain network is offline, it downloads the face-related data from the target block generated by the target node from the server and generates a target backup block containing the face-related data from the target block on the query node.
人脸相关数据是节点从服务端下载的,因此,服务端可以知晓哪些人脸相关数据是由目标节点下载和打包的,进而知晓哪些人脸相关数据是由目标节点生成的目标区块中所包含的,这样,服务端就可以向查询节点提供目标区块中的人脸相关数据。The face-related data is downloaded by the node from the server. Therefore, the server can know which face-related data was downloaded and packaged by the target node, and thus know which face-related data is contained in the target block generated by the target node. In this way, the server can provide the face-related data in the target block to the query node.
在步骤830中,将目标备份区块保存在查询节点上,并通过查询节点在区块链网络上广播目标备份区块的关联节点信息,以使区块链网络中的其他节点将关联节点信息中的内容保存至区块记录中。In step 830, the target backup block is stored on the query node, and the associated node information of the target backup block is broadcast on the blockchain network through the query node, so that other nodes in the blockchain network can save the content of the associated node information into the block record.
其中,关联节点信息包括查询节点的标识信息和目标节点的标识信息。The associated node information includes the identifier information of the query node and the identifier information of the target node.
由于目标节点已经离线,因此为了能够利用目标区块中的人脸相关数据进行人脸识别,需要在区块链网络中由查询节点代替目标节点来存储目标区块中的人脸相关数据。Since the target node is offline, in order to use the face-related data in the target block for face recognition, a query node needs to replace the target node in the blockchain network to store the face-related data in the target block.
当区块链网络中其他节点接收到关联节点信息后,会对关联节点信息中的内容进行保存,以用于进行人脸识别的检索过程。When other nodes in the blockchain network receive the associated node information, they will save the content of the associated node information for use in the facial recognition retrieval process.
关联节点信息是与目标备份区块相对应的,既反映了目标备份区块是由哪个节点生成的,也反映了目标备份区块是用于替代哪个节点上的区块。The associated node information corresponds to the target backup block, reflecting both which node generated the target backup block and which node the target backup block is used to replace.
其他节点至少可以将关联节点信息中查询节点的标识信息保存至区块记录中。具体来说,其他节点可以根据关联节点信息中目标节点的标识信息将在本地的区块记录中存储的目标节点的标识信息替换为查询节点的标识信息;其他节点还可以根据关联节点信息中目标节点的标识信息将查询节点的标识信息和目标节点的标识信息对应存储。目标区块中的人脸相关数据已经存储在查询节点中的目标备份区块上,之后,其他节点再将区块记录中目标节点的标识信息替换为查询节点的标识信息,这样,当区块链网络中的节点需要对目标区块中的人脸相关数据进行检索时,可以知晓需要向保存有目标备份区块的查询节点发送人脸数据。Other nodes can at least save the identifier information of the query node from the associated node information to the block record. Specifically, other nodes can replace the identifier information of the target node stored in their local block record with the identifier information of the query node based on the identifier information of the target node in the associated node information; other nodes can also store the identifier information of the query node and the identifier information of the target node correspondingly based on the identifier information of the target node in the associated node information. The face-related data in the target block has already been stored on the target backup block in the query node. Afterwards, other nodes replace the identifier information of the target node in the block record with the identifier information of the query node. In this way, when a node in the blockchain network needs to retrieve the face-related data in the target block, it knows that it needs to send the face data to the query node that stores the target backup block.
基于图8所示实施例,实现了目标区块中的人脸相关数据在区块链网络中的备份,即使区块链网络中的节点发生宕机等离线状况,其他节点也能够顺利进行人脸识别。Based on the embodiment shown in Figure 8, the face-related data in the target block is backed up in the blockchain network. Even if a node in the blockchain network goes offline or crashes, other nodes can still perform face recognition smoothly.
需要指出的是,将某一查询节点选择作为目标区块的备份存储节点可以是根据各种规则和机制来确定的。比如,当区块链中各个终端设备在监听到某一终端设备宕机之后,可以通过竞争方式向服务端请求获取由该终端设备存储的人脸相关数据,服务端会向首个发出请求的节点提供相应的人脸相关数据,由于当前的查询节点是最先发出请求的节点,因此当前的查询节点能从服务端获取到由宕机的终端设备存储的人脸相关数据;再比如,能够下载目标区块中的人脸相关数据的查询节点可以是区块链中被指定的用于获取由宕机的终端设备存储的人脸相关数据的节点。It should be noted that the selection of a query node as the backup storage node for the target block can be determined based on various rules and mechanisms. For example, when various terminal devices in the blockchain detect that a terminal device has crashed, they can compete to request the server to retrieve the face-related data stored by that terminal device. The server will provide the corresponding face-related data to the first node to make the request. Since the current query node is the first node to make the request, it can obtain the face-related data stored by the crashed terminal device from the server. Alternatively, the query node capable of downloading the face-related data in the target block can be a node in the blockchain designated to retrieve the face-related data stored by the crashed terminal device.
在本申请的一个实施例中,在通过查询节点在区块链网络上广播目标备份区块的关联节点信息之后,该方法还包括:根据接收到目标节点定期发来的工作状态信息,确定目标节点恢复至在线状态,并将存储的目标备份区块清除。In one embodiment of this application, after broadcasting the associated node information of the target backup block on the blockchain network through the query node, the method further includes: determining that the target node has recovered to the online state based on the working status information received periodically from the target node, and clearing the stored target backup block.
在本申请的一个实施例中,其他节点根据关联节点信息中目标节点的标识信息将在本地的区块记录中存储的目标节点的标识信息替换为查询节点的标识信息,在接收到目标节点定期发来的工作状态信息之后,其他节点根据接收到目标节点定期发来的工作状态信息而将区块记录中由目标节点的标识信息替换成的查询节点的标识信息重置为目标节点的标识信息。In one embodiment of this application, other nodes replace the target node's identifier information stored in their local block records with the query node's identifier information based on the target node's identifier information in the associated node information. After receiving the working status information periodically sent by the target node, other nodes reset the query node's identifier information in the block records, which was replaced by the target node's identifier information, back to the target node's identifier information based on the working status information periodically sent by the target node.
由于能够再次接收到目标节点定期发来的工作状态信息,因此,可以确定目标节点已经恢复至在线状态,此时,目标节点上存储的人脸相关数据已经可以用于人脸识别,通过将存储的目标备份区块清除,能够减少存储空间的占用;并且,其他节点通过将查询节点的标识信息重置为目标节点的标识信息,使得在需要使用目标区块中的人脸相关数据进行匹配时,可以目标节点。Since the target node can receive the working status information periodically sent by the target node again, it can be determined that the target node has been restored to the online state. At this time, the face-related data stored on the target node can be used for face recognition. By clearing the stored target backup block, the storage space occupied can be reduced. Furthermore, other nodes can reset the identification information of the query node to the identification information of the target node, so that when they need to use the face-related data in the target block for matching, they can use the target node.
在本申请的一个实施例中,区块链网络中的各节点均能够采集人脸数据。In one embodiment of this application, each node in the blockchain network is able to collect facial data.
具体来说,当本申请实施例用于刷脸支付场景时,区块链网络中的各节点可以为刷脸IoT设备,此时,节点既可以存储人脸相关数据,也能够直接采集人脸数据。Specifically, when the embodiments of this application are used in a facial recognition payment scenario, each node in the blockchain network can be a facial recognition IoT device. In this case, the node can both store face-related data and directly collect face data.
在本申请的一个实施例中,区块链网络中的各节点用于刷脸支付,区块链网络中的各节点与同一商户标识对应。In one embodiment of this application, each node in the blockchain network is used for facial recognition payment, and each node in the blockchain network corresponds to the same merchant identifier.
商户标识用于唯一标识一个商户,因此,与同一商户标识对应的节点的规模是很小的,比如,与同一商户标识对应的区块链网络中的各终节点可以是一个门店内的刷脸IoT设备,这些刷脸IoT设备可以部署在一个本地局域网中,而利用本地局域网可以在各节点之间高速传输数据,从而大大降低了在区块链网络中进行检索的延时,使得人脸识别的效率与全部在本地上存储人脸相关数据时人脸识别的效率相当。A merchant identifier is used to uniquely identify a merchant. Therefore, the scale of nodes corresponding to the same merchant identifier is very small. For example, each end node in the blockchain network corresponding to the same merchant identifier can be a facial recognition IoT device in a store. These facial recognition IoT devices can be deployed in a local area network. The local area network can be used to transmit data between nodes at high speed, thereby greatly reducing the latency of retrieval in the blockchain network. This makes the efficiency of facial recognition comparable to that of facial recognition when all facial-related data is stored locally.
图9示出了根据本申请的一个实施例的图2中步骤250之后步骤的流程图。如图9所示,在步骤250之后,还可以包括以下步骤:Figure 9 shows a flowchart of the steps following step 250 in Figure 2 according to an embodiment of this application. As shown in Figure 9, after step 250, the following steps may also be included:
在步骤910中,如果检索到与人脸识别请求中的人脸数据匹配的人脸相关数据,则通过查询节点向服务端发送支付指令,由服务端对人脸相关数据对应的支付账户进行支付操作。In step 910, if face-related data matching the face data in the face recognition request is retrieved, a payment instruction is sent to the server through the query node, and the server performs payment operation on the payment account corresponding to the face-related data.
比如,一个节点上可以存储与人脸相关数据对应的支付账号,当该节点上一个人脸相关数据与人脸数据匹配时,该节点可以向当前节点返回与该人脸相关数据对应的支付账号,当前节点可以向服务端发送支付指令,而支付指令中包含该支付账号对应的支付票据,从而进行支付操作。For example, a node can store payment accounts corresponding to face-related data. When a face-related data on that node matches a face, the node can return the payment account corresponding to that face-related data to the current node. The current node can then send a payment instruction to the server, which includes the payment receipt corresponding to that payment account, thereby performing the payment operation.
对支付账户进行支付操作是将消费金额从支付账户转移至商家账户。Making a payment to a payment account involves transferring the amount of money spent from the payment account to the merchant's account.
在本申请的一个实施例中,如果检索到与人脸识别请求中的人脸数据匹配的人脸相关数据,则通过查询节点向服务端发送支付指令,由服务端对人脸相关数据对应的支付账户进行支付操作,包括:如果检索到与人脸识别请求中的人脸数据匹配的人脸相关数据,则在查询节点连通了网络时向服务端发送支付指令,由服务端对人脸相关数据对应的支付账户进行支付操作。In one embodiment of this application, if face-related data matching the face data in the face recognition request is retrieved, a payment instruction is sent to the server through the query node, and the server performs a payment operation on the payment account corresponding to the face-related data. This includes: if face-related data matching the face data in the face recognition request is retrieved, a payment instruction is sent to the server when the query node is connected to the network, and the server performs a payment operation on the payment account corresponding to the face-related data.
具体而言,当在区块链网络中检索完毕时,可以得到与人脸数据匹配的人脸相关数据所对应的支付账号。此时,由于当前的查询节点尚未连通网络,可以将包含支付账号的支付票据暂时存储在本地,而在当前的查询节点连通了网络时,再向服务端发送包含支付票据的支付指令。Specifically, once the search in the blockchain network is complete, the payment account corresponding to the face-related data that matches the face data can be obtained. At this point, since the current query node is not yet connected to the network, the payment receipt containing the payment account can be temporarily stored locally. Once the current query node is connected to the network, a payment instruction containing the payment receipt will be sent to the server.
在本实施例中,实现了延迟支付,通过本申请实施例的方案,即使终端设备暂时未连通网络,只要终端设备能够恢复与网络的连通,就能够顺利完成支付操作。In this embodiment, delayed payment is implemented. Through the solution of this application embodiment, even if the terminal device is temporarily not connected to the network, as long as the terminal device can restore the connection with the network, the payment operation can be completed smoothly.
在步骤920中,如果未检索到与人脸识别请求中的人脸数据匹配的人脸相关数据,则通过查询节点将人脸数据上传至服务端,由服务端在确定出与人脸数据匹配的支付账户之后,对支付账户进行支付操作。In step 920, if no face-related data matching the face data in the face recognition request is found, the face data is uploaded to the server through the query node. After the server determines the payment account that matches the face data, it performs the payment operation on the payment account.
在本实施例中,只有在本地局域网无法完成人脸识别时,再由服务端进行人脸识别,并完成相应的支付操作;而在大多数情况下,人脸识别都是在本地局域网进行的,从而有效降低了网络拥塞的风险。In this embodiment, face recognition is only performed by the server when the local area network cannot complete the face recognition and the corresponding payment operation is completed; in most cases, face recognition is performed on the local area network, thereby effectively reducing the risk of network congestion.
值得一提的是,虽然本申请实施例中,向服务端发送支付指令以及人脸数据是由接收到人脸识别请求的查询节点执行的,但在本申请的其他实施例中,向服务端发送支付指令以及人脸数据可以由当前的查询节点之外的其他节点执行。具体地,向服务端发送支付指令可以由存储了与人脸数据匹配的人脸相关数据的节点执行,人脸数据可以由区块链网络中存储了最后一个区块的节点执行。It is worth noting that, although in this embodiment, sending payment instructions and facial data to the server is executed by the query node that receives the facial recognition request, in other embodiments of this application, sending payment instructions and facial data to the server can be executed by nodes other than the current query node. Specifically, sending payment instructions to the server can be executed by a node that stores facial-related data matching the facial data, and sending facial data can be executed by a node that stores the last block in the blockchain network.
请继续参见图3,根据图3位于下方的方框中的内容可以确定,在进行特征检索之后,如果在区块链网络中检索失败,即区块链中不存在与人脸数据匹配的人脸相关数据,此时,在云端进行人脸识别,并在识别完成之后直接扣款;而如果在区块链网络中检索成功,但如果当前节点尚未连通网络,可以将包含支付账号的支付票据暂时存储在本地,而在当前节点连通了网络时,再向服务端发送包含支付票据的支付指令,从而实现了延迟支付。Please refer to Figure 3. According to the content in the box at the bottom of Figure 3, after feature retrieval, if the retrieval fails in the blockchain network, that is, there is no face-related data matching the face data in the blockchain, then face recognition is performed in the cloud, and the payment is deducted directly after the recognition is completed. If the retrieval is successful in the blockchain network, but the current node is not yet connected to the network, the payment receipt containing the payment account can be temporarily stored locally. When the current node is connected to the network, the payment instruction containing the payment receipt is sent to the server, thus realizing delayed payment.
需要指出的是,虽然本申请实施例中,进行支付操作的服务端和节点下载的人脸相关数据所来源的服务端为同一服务端,但在本申请的其他实施例中,进行支付操作和人脸相关数据所来源的服务端还可以是不同的终端设备。It should be noted that, although in the embodiments of this application, the server performing the payment operation and the server from which the face-related data downloaded by the node originate are the same server, in other embodiments of this application, the server performing the payment operation and the server from which the face-related data originate may be different terminal devices.
综上所述,根据本申请实施例提供的人脸识别方法,人脸相关数据是从服务端下载至本地的,无需将人脸数据上传再进行人脸匹配,因此能够提升人脸识别的效率;在实现人脸识别特别是离线人脸识别的同时,既可以减少将人脸相关数据存储在终端本地所消耗的网络流量,也能够减少存储人脸相关数据所消耗的存储资源,并且,通过将人脸相关数据存储于区块链中,还能够保证数据存储的安全性,能够有效保护用户隐私数据。In summary, the face recognition method provided in this application downloads face-related data from the server to the local machine, eliminating the need to upload face data for face matching, thus improving the efficiency of face recognition. While achieving face recognition, especially offline face recognition, it reduces network traffic consumed by storing face-related data locally on the terminal, as well as storage resources. Furthermore, storing face-related data in a blockchain ensures data security and effectively protects user privacy data.
以下介绍本申请的装置实施例,可以用于执行本申请上述实施例中的人脸识别方法。对于本申请装置实施例中未披露的细节,请参照本申请上述的人脸识别方法的实施例。The following describes an embodiment of the apparatus described in this application, which can be used to execute the face recognition method described above. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the face recognition method described above.
图10示出了根据本申请的一个实施例的人脸识别装置的框图。参照图10所示,根据本申请的一个实施例的人脸识别装置1000,包括:组建单元1010、下载和生成单元1020、保存和广播单元1030、接收和保存单元1040和遍历单元1050。Figure 10 shows a block diagram of a face recognition device according to an embodiment of the present application. Referring to Figure 10, a face recognition device 1000 according to an embodiment of the present application includes: a component assembly unit 1010, a download and generation unit 1020, a storage and broadcast unit 1030, a receiving and storage unit 1040, and a traversal unit 1050.
其中,组建单元1010用于以接入本地局域网的用于进行人脸识别的终端设备作为区块链节点,组建在所述本地局域网内进行数据通信的区块链网络,所述区块链网络包括生成并存储目标区块的目标节点以及用于查找所述目标区块的查询节点;下载和生成单元1020用于在所述目标节点接入互联网的情况下,通过所述目标节点从服务端下载用于离线存储的人脸相关数据,并在所述目标节点上生成包含所述人脸相关数据的目标区块;保存和广播单元1030用于将所述目标区块保存在所述目标节点上,并通过所述目标节点在所述区块链网络上广播所述目标区块的上链信息,所述上链信息用于表示所述目标区块与区块链上的其他区块的链接关系;接收和保存单元1040用于当所述查询节点接收到所述区块链网络中广播的所述上链信息时,在所述查询节点上保存根据所述上链信息生成的区块记录,所述区块记录包括用于查找所述目标区块的查询路径;遍历单元1050用于响应于人脸识别请求,根据所述查询节点上保存的区块记录,遍历所述区块链中的各个区块以得到人脸识别结果。The blockchain network is configured to establish a blockchain network for data communication within the local area network, using a terminal device connected to the local area network (LAN) for face recognition as a blockchain node. The blockchain network includes target nodes for generating and storing target blocks and query nodes for searching the target blocks. The download and generation unit 1020, when the target node is connected to the internet, downloads face-related data for offline storage from the server through the target node and generates a target block containing the face-related data on the target node. The storage and broadcast unit 1030 stores the target block on the target node. On the node, the target node broadcasts the on-chain information of the target block on the blockchain network. The on-chain information is used to indicate the link relationship between the target block and other blocks on the blockchain. The receiving and saving unit 1040 is used to save the block record generated according to the on-chain information on the query node when the query node receives the on-chain information broadcast in the blockchain network. The block record includes a query path for finding the target block. The traversal unit 1050 is used to traverse each block in the blockchain to obtain the face recognition result in response to the face recognition request, according to the block record saved on the query node.
在本申请的一些实施例中,基于前述方案,下载和生成单元1020配置为:获取所述目标节点的标识信息和最新加入区块链的区块中的第一哈希值;根据所述目标节点的标识信息、所述第一哈希值和所述人脸相关数据确定第二哈希值;基于所述目标节点的标识信息、所述人脸相关数据、所述第一哈希值和所述第二哈希值生成区块。In some embodiments of this application, based on the foregoing scheme, the download and generation unit 1020 is configured to: obtain the identification information of the target node and the first hash value in the latest block added to the blockchain; determine the second hash value based on the identification information of the target node, the first hash value and the face-related data; and generate a block based on the identification information of the target node, the face-related data, the first hash value and the second hash value.
在本申请的一些实施例中,基于前述方案,下载和生成单元1020配置为:对所述人脸相关数据进行加密,得到加密后的人脸相关数据;将所述目标节点的标识信息、所述加密后的人脸相关数据、所述第一哈希值和所述第二哈希值打包成区块。In some embodiments of this application, based on the foregoing scheme, the download and generation unit 1020 is configured to: encrypt the face-related data to obtain encrypted face-related data; and package the identification information of the target node, the encrypted face-related data, the first hash value, and the second hash value into a block.
在本申请的一些实施例中,基于前述方案,所述上链信息包括哈希值和所述目标节点的标识信息,接收和保存单元1040配置为:当所述查询节点接收到所述区块链网络中广播的所述上链信息时,将所述上链信息中包含的所述哈希值和所述目标节点的标识信息作为区块记录保存至所述查询节点上。In some embodiments of this application, based on the foregoing scheme, the on-chain information includes a hash value and the identification information of the target node. The receiving and saving unit 1040 is configured to: when the query node receives the on-chain information broadcast in the blockchain network, save the hash value and the identification information of the target node contained in the on-chain information as a block record to the query node.
在本申请的一些实施例中,基于前述方案,遍历单元1050配置为:获取所述人脸识别请求中的人脸数据;根据所述区块记录中的哈希值和节点的标识信息,确定所述区块链中各区块的查询路径;根据所述查询路径,依次向所述区块链网络中各节点发送所述人脸数据,由各节点在存储的区块中进行检索,得到各节点返回的人脸识别结果。In some embodiments of this application, based on the aforementioned scheme, the traversal unit 1050 is configured to: obtain the face data in the face recognition request; determine the query path of each block in the blockchain according to the hash value and node identification information in the block record; and send the face data to each node in the blockchain network in sequence according to the query path, so that each node can retrieve the face data in the stored blocks and obtain the face recognition result returned by each node.
在本申请的一些实施例中,基于前述方案,下载和生成单元1020还用于:通过所述查询节点监听所述目标节点的工作状态;当所述查询节点监听到所述区块链网络中的所述目标节点处于离线状态时,从所述服务端下载已由所述目标节点生成的所述目标区块中的人脸相关数据,并在所述查询节点上生成包含所述目标区块中的人脸相关数据的目标备份区块;将所述目标备份区块保存在所述查询节点上,并通过所述查询节点在所述区块链网络上广播所述目标备份区块的关联节点信息,以使所述区块链网络中的其他节点将所述关联节点信息中的内容保存至区块记录中,其中,所述关联节点信息包括所述查询节点的标识信息和所述目标节点的标识信息。In some embodiments of this application, based on the foregoing scheme, the download and generation unit 1020 is further configured to: monitor the working status of the target node through the query node; when the query node detects that the target node in the blockchain network is offline, download the face-related data in the target block generated by the target node from the server, and generate a target backup block containing the face-related data in the target block on the query node; save the target backup block on the query node, and broadcast the associated node information of the target backup block on the blockchain network through the query node, so that other nodes in the blockchain network save the content in the associated node information to the block record, wherein the associated node information includes the identification information of the query node and the identification information of the target node.
在本申请的一些实施例中,基于前述方案,下载和生成单元1020配置为:接收所述区块链网络中所述目标节点定期发来的工作状态信息;根据未定期接收到所述目标节点发来的工作状态信息,确定所述目标节点处于离线状态。In some embodiments of this application, based on the foregoing scheme, the download and generation unit 1020 is configured to: receive work status information periodically sent by the target node in the blockchain network; and determine that the target node is offline if it has not periodically received work status information from the target node.
在本申请的一些实施例中,基于前述方案,在通过所述查询节点在所述区块链网络上广播所述目标备份区块的关联节点信息之后,下载和生成单元1020还用于:根据接收到所述目标节点定期发来的工作状态信息,确定所述目标节点恢复至在线状态,并将存储的所述目标备份区块清除。In some embodiments of this application, based on the foregoing scheme, after the associated node information of the target backup block is broadcast on the blockchain network through the query node, the download and generation unit 1020 is further configured to: determine that the target node has recovered to the online state based on the working status information received periodically from the target node, and clear the stored target backup block.
在本申请的一些实施例中,基于前述方案,所述区块链网络中的各节点均能够采集人脸数据。In some embodiments of this application, based on the aforementioned scheme, each node in the blockchain network is able to collect facial data.
在本申请的一些实施例中,基于前述方案,所述区块链网络中的各节点用于刷脸支付,所述区块链网络中的各节点与同一商户标识对应。In some embodiments of this application, based on the aforementioned scheme, each node in the blockchain network is used for facial recognition payment, and each node in the blockchain network corresponds to the same merchant identifier.
在本申请的一些实施例中,基于前述方案,在响应于人脸识别请求,根据所述查询节点上保存的区块记录,遍历所述区块链中的各个区块以得到人脸识别结果之后,遍历单元1050还用于:如果检索到与所述人脸识别请求中的人脸数据匹配的所述人脸相关数据,则通过所述查询节点向所述服务端发送支付指令,由所述服务端对所述人脸相关数据对应的支付账户进行支付操作;如果未检索到与所述人脸识别请求中的人脸数据匹配的所述人脸相关数据,则通过所述查询节点将所述人脸数据上传至所述服务端,由所述服务端在确定出与所述人脸数据匹配的支付账户之后,对所述支付账户进行支付操作。In some embodiments of this application, based on the aforementioned scheme, after responding to a face recognition request and traversing each block in the blockchain according to the block records stored on the query node to obtain the face recognition result, the traversal unit 1050 is further configured to: if face-related data matching the face data in the face recognition request is found, then a payment instruction is sent to the server through the query node, and the server performs a payment operation on the payment account corresponding to the face-related data; if no face-related data matching the face data in the face recognition request is found, then the face data is uploaded to the server through the query node, and the server performs a payment operation on the payment account after determining the payment account matching the face data.
在本申请的一些实施例中,基于前述方案,遍历单元1050配置为:如果检索到与所述人脸识别请求中的人脸数据匹配的所述人脸相关数据,则在所述查询节点连通了网络时向所述服务端发送支付指令,由所述服务端对所述人脸相关数据对应的支付账户进行支付操作。In some embodiments of this application, based on the aforementioned scheme, the traversal unit 1050 is configured to: if face-related data matching the face data in the face recognition request is retrieved, then when the query node is connected to the network, send a payment instruction to the server, and the server performs a payment operation on the payment account corresponding to the face-related data.
图11示出了适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。Figure 11 shows a schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application.
需要说明的是,图11示出的电子设备的计算机系统1100仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。It should be noted that the computer system 1100 of the electronic device shown in Figure 11 is only an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
如图11所示,计算机系统1100包括中央处理单元(Central Processing Unit,CPU)1101,其可以根据存储在只读存储器(Read-Only Memory,ROM)1102中的程序或者从存储部分1108加载到随机访问存储器(Random Access Memory,RAM)1103中的程序而执行各种适当的动作和处理,例如执行上述实施例中所述的方法。在RAM 1103中,还存储有系统操作所需的各种程序和数据。CPU 1101、ROM 1102以及RAM 1103通过总线1104彼此相连。输入/输出(Input/Output,I/O)接口1105也连接至总线1104。As shown in Figure 11, the computer system 1100 includes a Central Processing Unit (CPU) 1101, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 1102 or programs loaded from storage portion 1108 into Random Access Memory (RAM) 1103, such as performing the methods described in the above embodiments. Various programs and data required for system operation are also stored in RAM 1103. The CPU 1101, ROM 1102, and RAM 1103 are interconnected via bus 1104. An Input/Output (I/O) interface 1105 is also connected to bus 1104.
以下部件连接至I/O接口1105:包括键盘、鼠标等的输入部分1106;包括诸如阴极射线管(Cathode Ray Tube,CRT)、液晶显示器(Liquid Crystal Display,LCD)等以及扬声器等的输出部分1107;包括硬盘等的存储部分1108;以及包括诸如LAN(Local AreaNetwork,局域网)卡、调制解调器等的网络接口卡的通信部分1109。通信部分1109经由诸如因特网的网络执行通信处理。驱动器1110也根据需要连接至I/O接口1105。可拆卸介质1111,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器1110上,以便于从其上读出的计算机程序根据需要被安装入存储部分1108。The following components are connected to I/O interface 1105: an input section 1106 including a keyboard, mouse, etc.; an output section 1107 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to I/O interface 1105 as needed. Removable media 1111, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1110 as needed so that computer programs read from them can be installed into storage section 1108 as needed.
特别地,根据本申请的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本申请的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分1109从网络上被下载和安装,和/或从可拆卸介质1111被安装。在该计算机程序被中央处理单元(CPU)1101执行时,执行本申请的系统中限定的各种功能。Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1109, and/or installed from removable medium 1111. When the computer program is executed by central processing unit (CPU) 1101, it performs various functions defined in the system of this application.
需要说明的是,本申请实施例所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(Erasable Programmable Read Only Memory,EPROM)、闪存、光纤、便携式紧凑磁盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、有线等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。其中,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
描述于本申请实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现,所描述的单元也可以设置在处理器中。其中,这些单元的名称在某种情况下并不构成对该单元本身的限定。The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.
作为一方面,本申请还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该电子设备执行时,使得该电子设备实现上述实施例中所述的方法。In one aspect, this application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods described in the above embodiments.
应当注意,尽管在上文详细描述中提及了用于动作执行的设备的若干模块或者单元,但是这种划分并非强制性的。实际上,根据本申请的实施方式,上文描述的两个或更多模块或者单元的特征和功能可以在一个模块或者单元中具体化。反之,上文描述的一个模块或者单元的特征和功能可以进一步划分为由多个模块或者单元来具体化。It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
通过以上的实施方式的描述,本领域的技术人员易于理解,这里描述的示例实施方式可以通过软件实现,也可以通过软件结合必要的硬件的方式来实现。因此,根据本申请实施方式的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中或网络上,包括若干指令以使得一台计算设备(可以是个人计算机、服务器、触控终端、或者网络设备等)执行根据本申请实施方式的方法。Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this application.
本领域技术人员在考虑说明书及实践这里公开的实施方式后,将容易想到本申请的其它实施方案。本申请旨在涵盖本申请的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本申请的一般性原理并包括本申请未公开的本技术领域中的公知常识或惯用技术手段。Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
应当理解的是,本申请并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本申请的范围仅由所附的权利要求来限制。It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
本发明中的人脸信息为合法使用。The facial information used in this invention is legal.
Claims (15)
Publications (2)
| Publication Number | Publication Date |
|---|---|
| HK40053647A HK40053647A (en) | 2022-02-11 |
| HK40053647B true HK40053647B (en) | 2025-01-17 |
Family
ID=
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP7710448B2 (en) | Partially Ordered Blockchain | |
| US10560465B2 (en) | Real time anomaly detection for data streams | |
| US20220407725A1 (en) | File storage method, terminal, and storage medium | |
| US10270668B1 (en) | Identifying correlated events in a distributed system according to operational metrics | |
| CN113505260B (en) | Face recognition method, device, computer readable medium and electronic device | |
| EP3639465A1 (en) | Improved hardware security module management | |
| CN111241195A (en) | Database processing method, device, equipment and storage medium of distributed system | |
| CN111488372A (en) | Data processing method, device and storage medium | |
| JP7735645B2 (en) | Data processing method, device, electronic device, and computer program | |
| CN112632637A (en) | Tamper-proof evidence obtaining method, system, device, storage medium and electronic equipment | |
| US20200021602A1 (en) | Trace-based transaction validation and commitment | |
| CN111930753B (en) | Data retrieving method and device, electronic equipment and storage medium | |
| US12511406B2 (en) | Data processing method and apparatus, electronic device, and medium | |
| CN110866265A (en) | Data storage method, device and storage medium based on block chain | |
| US10977055B2 (en) | Method and system creating and using sub-data confidence fabrics | |
| CN112200680A (en) | Blockchain node management method, device, computer and readable storage medium | |
| CN112511515B (en) | Chain number cube for data chaining | |
| US11294734B2 (en) | Method and system optimizing the use of sub-data confidence fabrics | |
| HK40053647B (en) | Method and apparatus for recognizing human faces, computer readable medium and electronic device | |
| WO2024131083A1 (en) | Data processing method and apparatus, electronic device, computer storage medium and computer program product | |
| WO2025007540A1 (en) | Data processing method and apparatus based on blockchain, and device and medium | |
| CN112579413B (en) | Method, device, computer equipment and storage medium for changing server operation record | |
| CN118034994A (en) | Data processing method, device, electronic device and storage medium | |
| HK40053647A (en) | Method and apparatus for recognizing human faces, computer readable medium and electronic device | |
| CN114387109A (en) | A data processing device, method and business system based on blockchain |