An image recognition method and device applied to the browser side

By compiling the image recognition module as a WebAssembly binary module on the browser side, image comparison is performed directly on the browser side, the problem of image recognition on the browser side depends on background services, improve efficiency and security, and support diversified image recognition functions.

CN112115738BActive Publication Date: 2025-07-22BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201910530777.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-19
Publication Date
2025-07-22
Estimated Expiration
2039-06-19

AI Technical Summary

Technical Problem

Existing browser-side image recognition technology relies on backend services, resulting in high network bandwidth requirements, poor information security and poor compatibility.

Method used

Through module compilation, the image recognition module is compiled into WebAssembly's wasm binary module, and the image information is directly compared on the browser side to reduce the dependence on background services.

Benefits of technology

It improves the image recognition efficiency on the browser side, reduces the security risks of network transmission, enhances compatibility, and supports diverse image recognition needs such as face, gender, and age recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112115738B_ABST
    Figure CN112115738B_ABST
Patent Text Reader

Abstract

The present invention discloses an image recognition method and apparatus applied to the browser side, which relates to the field of computer technology. A specific implementation manner of the method includes: compiling an image recognition module into a binary module by means of module compilation; in response to an image service request, sending an image acquisition instruction to an image acquisition device and invoking an image recognition interface in the binary module; receiving the image information collected by the image acquisition device, and comparing the image information with the stored image information on the browser side through the image recognition interface to obtain a recognition result and return it. This implementation manner extends the capabilities of the browser through WebAssembly, enabling the browser to execute the compiled binary file; integrating the existing image recognition solution and the execution of the wasm binary file on the browser side by WebAssembly effectively solves the problem of the lack of efficient image recognition on the browser side, and the overall implementation has good compatibility and scalability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular, to an image recognition method and apparatus applied to a browser side. Background Art

[0002] With the development of Internet technology, mobile phones, computers, etc. have become important daily Internet tools, and users are increasingly concerned about the security of their privacy information. Among them, how to protect personal privacy in the browser side has become an issue that cannot be ignored.

[0003] Considering the tediousness and forgetfulness of password verification, currently, an image recognition service is usually integrated on the WEB interface of the browser side, such as face brushing payment and face brushing security authentication. Taking face recognition as an example, the main methods are as follows:

[0004] 1) Collect the user's head image information through the front camera and transmit the user's head image information to the background server; the background server combines the face database to recognize the user's head image and obtains the recognition result;

[0005] 2) The Chrome browser of Android comes with a FaceDetector API (Application Program Interface), and face recognition can be performed through the API.

[0006] In the process of implementing the present invention, the inventors found that the prior art has at least the following problems:

[0007] 1) In the first solution, it is necessary to transmit image information through the network, which has a certain requirement for network bandwidth; it is easily intercepted and tampered with by attackers during the transmission process (for example, using someone else's head image to make a payment), and the information security cannot be guaranteed; the image feature extraction and recognition process depends on the operation of the background server, and the performance requirements for the server are relatively high;

[0008] 2) In the second solution, except for the Chrome browser of Android, browsers of other operating systems do not support this API function, and the compatibility is relatively poor. Summary of the Invention

[0009] In view of this, an embodiment of the present invention provides an image recognition method and apparatus applied to a browser side, which can at least solve the problems of relying on the background service, long execution time, and poor compatibility in image recognition in the existing browser side.

[0010] To achieve the above object, according to one aspect of the embodiments of the present invention, an image recognition method applied to a browser side is provided, including:

[0011] Compiling an image recognition module into a binary module by means of module compilation;

[0012] In response to an image service request, send an image acquisition instruction to an image acquisition device and call the image recognition interface in the binary module;

[0013] Receive the image information collected by the image acquisition device, and through the image recognition interface, compare the image information with the stored image information on the browser side to obtain a recognition result and return it.

[0014] Optionally, after compiling the image recognition module into a binary module, it further includes: generating a binary file corresponding to the binary module, and transmitting the binary file to the server for storage;

[0015] The calling of the image recognition interface in the binary module further includes:

[0016] If the binary module is not found in the cache of the browser side, transmit a binary file loading request to the server;

[0017] Receive the binary file fed back by the server, and through the file compilation method, compile the binary file into the binary module to call the image recognition interface in the binary module.

[0018] Optionally, the calling of the image recognition interface in the binary module includes: loading a binary instance including the binary module, obtaining an instance object corresponding to the binary instance, and calling the image recognition interface mounted in the instance object.

[0019] Optionally, the image recognition is face recognition or face attribute recognition.

[0020] To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an image recognition device applied to the browser side, including:

[0021] A compilation module for compiling an image recognition module into a binary module by means of module compilation;

[0022] A request response module for sending an image acquisition instruction to an image acquisition device in response to an image service request and calling the image recognition interface in the binary module;

[0023] An image recognition module for receiving the image information collected by the image acquisition device, and through the image recognition interface, comparing the image information with the stored image information on the browser side to obtain a recognition result and return it.

[0024] Optionally, the compilation module is further configured to: generate a binary file corresponding to the binary module, and transmit the binary file to the server for storage;

[0025] The request response module is further configured to:

[0026] If the binary module is not found in the cache of the browser side, transmit a binary file loading request to the server;

[0027] Receive the binary file fed back by the server, and compile the binary file into the binary module by means of file compilation, so as to call the image recognition interface in the binary module.

[0028] Optionally, the request response module is configured to: load a binary instance including the binary module, obtain an instance object corresponding to the binary instance, and call the image recognition interface mounted in the instance object.

[0029] Optionally, the image recognition is face recognition or face attribute recognition.

[0030] To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an image recognition electronic device applied to the browser side.

[0031] The electronic device according to the embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the image recognition method applied to the browser side as described in any one of the above.

[0032] To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, the image recognition method applied to the browser side as described in any one of the above is implemented.

[0033] According to the solution provided by the present invention, one embodiment of the above invention has the following advantages or beneficial effects: WebAssembly is added on the browser side, and the performance is higher than that of pure JavaScript; image recognition is performed on the browser side, reducing the dependence on the background interface; in addition to face recognition, it can also recognize attributes such as the age and gender of a person, which is customizable and meets the diverse needs of users.

[0034] The further effects of the above non-conventional optional methods will be described in conjunction with specific embodiments below. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation to the present invention. Among them:

[0036] Figure 1 is a main flowchart showing a method for image recognition applied to a browser side according to an embodiment of the present invention;

[0037] Figure 2 is a flowchart showing a specific method for image recognition applied to a browser side according to an embodiment of the present invention;

[0038] Figure 3 is a main module diagram showing an image recognition device applied to a browser side according to an embodiment of the present invention;

[0039] Figure 4 is an exemplary system architecture diagram to which the embodiments of the present invention can be applied;

[0040] Figure 5 is a structural diagram of a computer system of a mobile device or a server side suitable for implementing the embodiments of the present invention. Detailed implementation manners

[0041] The following describes exemplary embodiments of the present invention with reference to the accompanying drawings. Various details of the embodiments of the present invention are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, descriptions of well-known functions and structures are omitted below for clarity and conciseness.

[0042] WebAssembly is a technology that enables the execution of C / C++ languages on the browser side. In theory, for scenarios supported by C++ but not by JavaScript, WebAssembly can be considered as an adhesive for support. Therefore, for binary modules that can be supported by WebAssembly, the present invention mainly takes the wasm module of WebAssembly as an example for illustration.

[0043] In addition to face recognition, the present invention is also applicable to scenarios such as object recognition, action recognition, age recognition, gender recognition, etc. that require image acquisition and recognition. The present invention mainly takes face recognition as an example for illustration.

[0044] See Figure 1 , which shows a main flowchart of a method for image recognition applied to a browser side provided by an embodiment of the present invention, including the following steps:

[0045] S101: Compile the image recognition module into a binary module through a module compilation method;

[0046] S102: In response to an image service request, send an image acquisition instruction to the image acquisition device and call the image recognition interface in the binary module;

[0047] S103: Receive the image information collected by the image acquisition device, and through the image recognition interface, compare the image information with the stored image information on the browser side to obtain a recognition result and return it.

[0048] In the above embodiment, for step S101, by means of existing mature image recognition technologies, such as OpenCV and C / C++ libraries, an image recognition module is developed through a specific computer language.

[0049] The present invention mainly selects the OpenCV technology. OpenCV is a cross-platform computer vision library composed of a series of C functions and a small number of C++ classes. It can run on multiple operating systems, has the advantages of being lightweight and efficient, and at the same time provides interfaces for languages such as Python, Ruby, and MATLAB, implementing many general algorithms in image processing and computer vision.

[0050] For the developed image recognition module, in a browser that supports WebAssembly, it can be compiled into a wasm binary module of WebAssembly through Emscripten (a compiler based on llvm, aiming to compile C / C++ into a wasm module).

[0051] In addition, besides Emscripten, other wasm assemblers can also be used, such as WasmFiddle and WasmExplorer. The present invention mainly selects Emscripten for binary module compilation.

[0052] The wasm module is cached in the browser side, while the corresponding wasm file of the wasm module is usually stored in the server side and is suitable for all browsers that support WebAssembly. The server stores the wasm file in a similar way to storing pictures, directly saving it as a binary file.

[0053] It should be noted that although WebAssembly code can be directly written in the assembly layer of the browser side, it is difficult for developers to write directly. Most developers usually write code in C / C++ or Rust first, and then compile it into WebAssembly and output it to reduce the difficulty of directly writing WebAssembly.

[0054] For step S102, the browser Web interface in the present invention can be set with an image recognition option. For example, when a user operates to make a payment on a web page and needs to enter a password to verify their identity, the process of entering the face recognition is similar to popping up a password box to enter a password. Only after successful verification can the next operation be carried out.

[0055] It should be noted that the embodiments of the present invention are not directed to all browsers, but to browsers that support WebAssembly, and do not distinguish between Android and IOS platforms. Only browsers that support WebAssembly can load the wasm module; otherwise, there will be no response result.

[0056] WebAssembly is a new coding method that can write code using non-Javascript programming languages and can run on browsers. Generally, WebAssembly is designed to be relatively small in size and can be represented in binary form, that is, a wasm file (one module corresponds to one path file). Therefore, the time to download resources will be smaller, especially in the case of slow network speed, and the effect is more obvious.

[0057] When code (such as C / C++) runs on the web interface of a browser in a machine, it is impossible to determine on which machine structure it will run. Therefore, WebAssembly is somewhat different from other assembly languages and is only a conceptual machine language, and can also be regarded as another target assembly language.

[0058] WebAssembly can be converted into machine code faster and more directly than other JavaScript code, but they do not directly correspond to specific machine code. Therefore, after the browser downloads WebAssembly, WebAssembly can be used to quickly convert the code into the assembly code of the target machine.

[0059] It should be noted that WebAssembly only extends the capabilities of the browser, enabling the browser to call other languages through WebAssebly, but it cannot truly replace JavaScript. For example, JavaScript can handle styles, page elements, events, etc. in the browser Web page, which WebAssembly cannot handle.

[0060] The browser itself does not have the function of collecting images. Therefore, the image collection here is still carried out by an image collection device, such as a camera.

[0061] The camera here can be the camera of the device where the browser is located (such as a laptop). However, if the device does not have a camera set (such as a desktop computer), the camera associated with the device can also be called to perform the operation of collecting images.

[0062] It should be noted that the sending of the image acquisition instruction and the invocation of the image recognition interface here can be carried out simultaneously or asynchronously; for example, first send the image acquisition instruction and then invoke the image recognition interface, or first invoke the image recognition interface and then send the image acquisition instruction.

[0063] Considering that the collected images can be processed immediately, the present invention mainly selects the method of first invoking the image recognition interface and then sending the image acquisition instruction, or both being synchronized.

[0064] For step S103, after calling the camera to collect images, if image recognition operations are required, the loaded image recognition interface is called to compare the collected image information with the image information stored in the database of the browser side (such as the device where it is located) or in the cloud, and the recognition result is returned to the invoker.

[0065] It should be noted that the image comparison here is completed on the browser side. Compared with the existing image recognition operations that rely on the server side, it can reduce the dependence on the network and at the same time reduce the time required for image comparison. Since there is no need to transmit image information to the server side, the present invention also reduces the possibility of information being tampered with and provides a certain guarantee for user privacy and security.

[0066] In addition to face recognition, the image recognition here can also identify various attributes such as the gender and age of the face according to the personalized needs of the user. These customized requirements are written in the C / C++ part, which is no different from the existing use of C / C++ for customization, except that it can be integrated into the browser side through WebAssembly and run.

[0067] For the method provided in the above embodiments, for browsers that support WebAssembly, the binary files compiled by WebAssembly can be executed, and with the help of a mature image recognition solution, image recognition can be efficiently performed locally, and the overall performance is higher than that of pure JavaScript, with good compatibility and scalability. And compared with directly writing the wasm module, the present invention compiles and converts the image recognition module to obtain the wasm module, which reduces the difficulty of direct writing.

[0068] See Figure 2 , which shows a schematic flow diagram of a specific image recognition method applied to the browser side according to an embodiment of the present invention, including the following steps:

[0069] S201: Develop an image recognition module based on image recognition method;

[0070] S202: Compile the image recognition module into a binary module through module compilation method;

[0071] S203: In response to an image service request, send an image acquisition instruction to the image acquisition device and trigger the loading operation of the binary module;

[0072] S204: If the binary module is not found in the browser - side cache, transmit a binary file loading request to the server;

[0073] S205: Receive the binary file fed back by the server, and compile the binary file into a binary module through file compilation method;

[0074] S206: If the binary module is found in the browser - side cache, load the binary module;

[0075] S207: Invoke the image recognition interface in the binary module;

[0076] S208: Receive the image information collected by the image acquisition device;

[0077] S209: Through the image recognition interface, compare the received image information with the stored image information on the browser side, obtain the recognition result and return it.

[0078] In the above - mentioned embodiment, for steps S201 and S202, refer to Figure 1 the description of step S101 shown, and for steps S203, S208 and S209, refer to Figure 1 the description of steps S102 and S103 shown, which will not be elaborated here.

[0079] In the above - mentioned embodiment, for steps S204 - S206, determine whether the wasm binary module is already cached in the browser side:

[0080] 1) If it is already cached, directly load it;

[0081] 2) If it is not cached, the wasm file needs to be loaded from the remote server; specifically:

[0082] ① Transmit a wasm file acquisition request to the server to receive the wasm file fed back by the server;

[0083] ②Create an ArrayBuffer (a memory area that can store various types of data) containing the wasm file, and use WebAssembly.instantiate() to compile the ArrayBuffer to obtain the wasm module; among them, WebAssembly.instantiate is a compilation method provided by the browser side.

[0084] Because the cache on the browser side can be cleared at any time or after expiration (for example, cleared once every 7 days). Once cleared, it is necessary to reload the wasm file from the server side and compile it to generate the wasm module.

[0085] For step S207, the wasm module contains an image recognition interface. Therefore, after loading / generating the wasm module, the contained image recognition interface can be called to perform image recognition operations. Specifically:

[0086] 1) Call an API interface of WebAssembly (WebAssembly.instantiate) to extract the binary instance from the browser cache; for example, a WebAssembly instance of the WebAssembly.Module type.

[0087] 2) Determine the instantiated Instance object through the extracted binary instance; among them, the image recognition interface is mounted in this Instance object.

[0088] 3) Call the image recognition interface mounted in the Instance object to perform image recognition operations on the browser side.

[0089] Among them, for 1), the WebAssembly instance can be stored in IndexedDB (a transactional database system) on the browser side. Among them, IndexedDB is suitable for locally saving resources containing application states, such as text, binary files, and any other cloneable objects.

[0090] By storing the WebAssembly instance in IndexedDB, there is no need to re-request from the server side and compile on the browser side every time the page is entered, thereby improving the page response performance.

[0091] For 2), Instance is a series of processes in the operating system and the memory blocks allocated for these processes. The getInstance() function can be used to obtain the currently instantiated Instance object of this class. If the object of this class has not been instantiated in the current system, the constructor of this class is called to instantiate an object and return it.

[0092] The method provided by the embodiments of the present invention extends the capabilities of the browser through WebAssembly, enabling the browser to execute compiled binary files; integrates the existing image recognition solution and the WebAssembly browser to execute wasm binary files, solving the problem of lacking the ability to efficiently recognize images on the browser side; recognizes user attributes such as gender and age, meeting the personalized needs of users, and does not require relying on the background service for image recognition.

[0093] See Figure 3 , which shows a schematic diagram of the main modules of an image recognition device 300 applied to the browser side provided by the embodiments of the present invention, including:

[0094] A compilation module 301, configured to compile an image recognition module into a binary module through module compilation;

[0095] A request response module 302, configured to send an image acquisition instruction to an image acquisition device in response to an image service request, and call an image recognition interface in the binary module;

[0096] An image recognition module 303, configured to receive image information collected by the image acquisition device, compare the image information with the stored image information on the browser side through the image recognition interface, obtain a recognition result and return it.

[0097] In the implementation device of the present invention, the compilation module 301 is further configured to:

[0098] Generate a binary file corresponding to the binary module, and transmit the binary file to the server for storage;

[0099] The request response module 302 is further configured to:

[0100] If the binary module is not found in the cache of the browser side, transmit a binary file loading request to the server;

[0101] Receive the binary file fed back by the server, compile the binary file into the binary module through file compilation, so as to call the image recognition interface in the binary module.

[0102] In the implementation device of the present invention, the request response module 302 is configured to: load a binary instance including the binary module, obtain an instance object corresponding to the binary instance, and call the image recognition interface mounted in the instance object.

[0103] In the implementation device of the present invention, the image recognition is face recognition or face attribute recognition.

[0104] In addition, the specific implementation details of the devices described in the embodiments of the present invention have been elaborated in detail in the above method, so the repeated content will not be described herein again.

[0105] Figure 4 An exemplary system architecture 400 to which the embodiments of the present invention can be applied is shown.

[0106] As Figure 4 shown, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405 (merely examples). The network 404 serves as a medium for providing a communication link between the terminal devices 401, 402, 403 and the server 405. The network 404 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0107] Users can use the terminal devices 401, 402, 403 to interact with the server 405 through the network 404 to receive or send messages, etc. Various communication client applications may be installed on the terminal devices 401, 402, 403.

[0108] The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, and desktop computers, etc.

[0109] The server 405 may be a server providing various services, such as a back-end management server (merely an example) that provides support for shopping websites browsed by users using the terminal devices 401, 402, 403. The back-end management server may analyze and process data such as product information query requests received, and feedback the processing results to the terminal devices.

[0110] It should be noted that the image recognition method applied to the browser side provided by the embodiments of the present invention is generally executed by the server 405. Correspondingly, the image recognition device applied to the browser side is generally disposed in the server 405.

[0111] It should be understood that Figure 4 the numbers of the terminal devices, the network, and the server in

[0112] are merely illustrative. According to the implementation requirements, there may be any number of terminal devices, networks, and servers. Figure 5 Below, reference is made to Figure 5 which shows a schematic structural diagram of a computer system 500 of a terminal device suitable for implementing the embodiments of the present invention.

[0113] As Figure 5 shown, computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage section 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0114] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as required. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as required so that a computer program read from it can be installed into the storage section 508 as required.

[0115] Specifically, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 509, and / or installed from the removable medium 511. When the computer program is executed by a central processing unit (CPU) 501, the above functions defined in the system of the present invention are executed.

[0116] It should be noted that the computer-readable medium shown in the present invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the above 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 of the above. More specific examples of a computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which the computer-readable program code is carried. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0117] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram can represent a module, a program segment, or a part of code, and the above module, program segment, or part of code contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, as well as the combination of blocks in a block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0118] The modules involved in the embodiments of the present invention can be implemented in software or in hardware. The described modules can also be provided in a processor. For example, it can be described as: a processor includes a compilation module, a request response module, and an image recognition module. Among them, the names of these modules do not constitute a limitation to the module itself in some cases. For example, the image recognition module can also be described as "a module that receives image information and performs recognition".

[0119] As another aspect, the present invention also provides a computer-readable medium, which can be included in the device described in the above embodiments; or it can exist alone without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by the device, the device includes:

[0120] Compile the image recognition module into a binary module through module compilation;

[0121] In response to an image service request, send an image acquisition instruction to an image acquisition device and call the image recognition interface in the binary module;

[0122] Receive the image information collected by the image acquisition device, and through the image recognition interface, compare the image information with the stored image information on the browser side to obtain a recognition result and return it.

[0123] According to the technical solution of the embodiments of the present invention, the capabilities of the browser are extended through WebAssembly, enabling the browser to execute binary files compiled by C / C++; integrating the existing image recognition solution and the WebAssembly browser to execute wasm binary files solves the lack of the ability to efficiently recognize images on the browser side; recognizing user attribute features such as gender and age meets the personalized needs of users, and there is no need to rely on the background service for image recognition.

[0124] The above specific implementation manners do not constitute a limitation to the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention. All actions to obtain signals, information, or data in this application are carried out on the premise of complying with the corresponding data protection regulations and policies of the location and obtaining authorization from the owner of the corresponding device.

Claims

1. An image recognition method applied to the browser side, characterized in that Including: Compiling the image recognition module into a binary module by means of module compilation; Generating a binary file corresponding to the binary module, and transmitting the binary file to a server for storage; In response to an image service request, sending an image acquisition instruction to an image acquisition device, and invoking an image recognition interface in the binary module, including: invoking an interface of WebAssembly, loading a binary instance including the binary module from a cache at the browser end, obtaining an instance object corresponding to the binary instance, and invoking the image recognition interface mounted in the instance object; if the binary module is not found in the cache at the browser end, transmitting a binary file loading request to the server; receiving the binary file fed back by the server, and compiling the binary file into the binary module by means of file compilation so as to invoke the image recognition interface in the binary module; wherein the browser end supports WebAssembly; Receiving the image information acquired by the image acquisition device, and comparing, at the browser end, the image information with the stored image information through the image recognition interface, obtaining a recognition result and returning it.

2. The method according to claim 1, wherein The image recognition is face recognition or face attribute recognition.

3. An image recognition device applied to the browser side, characterized in that, Including: A compiling module, configured to compile the image recognition module into a binary module by means of module compilation; Generating a binary file corresponding to the binary module, and transmitting the binary file to a server for storage; A request response module, configured to, in response to an image service request, send an image acquisition instruction to an image acquisition device, and invoke an image recognition interface in the binary module, including: invoking an interface of WebAssembly, loading a binary instance including the binary module from a cache at the browser end, obtaining an instance object corresponding to the binary instance, and invoking the image recognition interface mounted in the instance object; if the binary module is not found in the cache at the browser end, transmitting a binary file loading request to the server; receiving the binary file fed back by the server, and compiling the binary file into the binary module by means of file compilation so as to invoke the image recognition interface in the binary module; wherein the browser end supports WebAssembly; An image recognition module, configured to receive the image information acquired by the image acquisition device, and compare, at the browser end, the image information with the stored image information through the image recognition interface, obtaining a recognition result and returning it.

4. The device according to claim 3, wherein, The image recognition is face recognition or face attribute recognition.

5. An electronic device, characterized in that, Including: One or more processors; A storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, enabling the one or more processors to implement the method according to any one of claims 1-2.

6. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, implementing the method according to any one of claims 1-2.

Citation Information

Patent Citations

  • Method and device for utilizing camera in browser

    CN102789561A

  • Method and apparatus for uploading medical image file through browser

    CN108563728A