CN114595084A - Method for sharing video between system-level processes on Linux operating system - Google Patents

Method for sharing video between system-level processes on Linux operating system Download PDF

Info

Publication number
CN114595084A
CN114595084A CN202210500318.0A CN202210500318A CN114595084A CN 114595084 A CN114595084 A CN 114595084A CN 202210500318 A CN202210500318 A CN 202210500318A CN 114595084 A CN114595084 A CN 114595084A
Authority
CN
China
Prior art keywords
video
end process
memory
virtual file
video data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210500318.0A
Other languages
Chinese (zh)
Inventor
刘旸
刘云鹤
蒋林轩
史晶
张超
彭欢
郭俊余
张铎
魏立峰
程启
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kirin Software Co Ltd
Original Assignee
Kirin Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kirin Software Co Ltd filed Critical Kirin Software Co Ltd
Priority to CN202210500318.0A priority Critical patent/CN114595084A/en
Publication of CN114595084A publication Critical patent/CN114595084A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources

Abstract

The invention relates to the technical field of video transmission, in particular to a method for sharing video between system-level processes on a Linux operating system, which comprises the following steps: s1, creating a memory virtual file; s2, collecting video data by a back-end process; s3, writing each frame of image of the video data into the memory virtual file; s4, after the writing is finished, the back-end process sends an image writing finishing signal to the front-end process; and S5, the front-end process receives the image writing completion signal, and reads each frame of image of the video data from the memory virtual file for drawing. The method provides a system-level inter-process video message transmission mode based on a Linux operating system.

Description

Method for sharing video between system-level processes on Linux operating system
Technical Field
The invention relates to the technical field of video transmission, in particular to a method for sharing video among system-level processes on a Linux operating system, electronic equipment and a readable storage medium.
Background
With the increasing popularity of face recognition technology, more and more operating systems choose face recognition as a way to unlock a login device. However, when the face recognition login technology is applied to the operating system level, a design architecture with a front-end process and a back-end process separated is often adopted, that is, the back-end process is responsible for collecting and verifying face data, and the front-end process is responsible for drawing a corresponding UI interface; one problem in the field of operating systems is then involved: the problem of inter-process communication needs to synchronize the relevant state information when the back-end process collects and verifies to the front-end process UI process.
According to research, the processing of the commonly used operating systems such as Windows, android and IOS in the current market during face recognition login only adopts dynamic graphs to represent the state and result of the face recognition process, and the face recognition pictures are not displayed in real time. However, in some application scenarios, a user needs to display a real-time image for face recognition by determining the position of a face due to the uncertainty of the position of a face acquisition device (camera) to improve the accuracy and accuracy of recognition, so that the transmission of video data between the processes at the operating system level is increasingly important.
Disclosure of Invention
Solves the technical problem
Aiming at the defects in the prior art, the invention provides a method for sharing video between system-level processes on a Linux operating system.
Technical scheme
In order to achieve the purpose, the invention is realized by the following technical scheme:
the invention provides a method for sharing video between system level processes on a Linux operating system, which is characterized by comprising the following steps:
s1, creating a memory virtual file;
s2, collecting video data by a back-end process;
s3, writing each frame of image of the video data into the memory virtual file;
s4, after the writing is finished, the back-end process sends an image writing finishing signal to the front-end process;
and S5, the front-end process receives the image writing completion signal, and reads each frame of image of the video data from the memory virtual file for drawing.
Further, step S1 further includes obtaining a file descriptor of the memory virtual file, and step S3 writes each frame image of the video data into the memory virtual file through the pointing of the file descriptor.
Further, step S1 specifically includes: the memory virtual file is created through memfd _ create, the created api return value is synchronized to the front-end process through an authentication interface, and the api return value is the file descriptor.
Further, the back-end process collects the video data through a camera.
Furthermore, the cameras are instantiated by using opencv related classes, and video frames of the cameras are read circularly to obtain the video data.
Further, the inter-system-level process video sharing method on the Linux operating system is used for face recognition.
Further, after the face recognition is completed, the back-end process stops obtaining the video data, and the memory virtual file is released.
Furthermore, information is transmitted between the front-end process and the back-end process through a dbus channel.
Based on the same inventive idea, the invention provides an electronic device comprising a processor and a memory, the memory having stored thereon a computer program which, when executed by the processor, implements the method of any of the above.
Based on the same inventive concept, the present invention provides a readable storage medium having stored therein a computer program which, when executed by a processor, implements the method of any of the above.
Advantageous effects
1) The invention provides a transmission mode of video messages among processes based on a Linux operating system, and can solve the problem that a face acquisition picture cannot be displayed in real time when face identification authentication is carried out at the level of the Linux operating system;
2) the invention uses the memory virtual file to transfer the video data, and because the operation is directly carried out in the memory, the IO expense caused by creating the actual disk file is avoided;
3) when the video message transmission is finished, the created memory virtual file and the file descriptor are released, so that the generation of memory garbage is avoided, and further, the influence on the performance when the video message transmission is carried out for multiple times is avoided.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the invention, and that for a person skilled in the art, other drawings can be derived from them without inventive effort.
FIG. 1 is a schematic diagram illustrating steps of a method for inter-system-level video sharing in a Linux operating system according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for sharing video between system-level processes in a Linux operating system according to an embodiment of the present invention;
fig. 3 is a flowchart of a process framework of the inter-system-level process video sharing method for Linux operating system applied to face recognition according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention. It is to be understood that the embodiments described are only a few embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
First, technical terms used in the present invention are explained:
and (4) process: a process is a process in which programs with independent functions run on a data set, and is an independent unit for resource allocation and scheduling of a system. Inter-process communication: the user spaces of processes are independent of each other, generally inaccessible to each other, and the propagation or exchange of information between different processes is called interprocess communication. Video frame: each image constituting video information. Memory virtual file: this file is like a normal file and can therefore be modified, truncated, memory mapped, etc. Unlike a normal file, this file is saved in the RAM. dbus channel: linux is a kind of interprocess message transmission bus. Linux: herein, a desktop operating system developed based on Linux, such as ubuntu, centros, Unified Operating System (UOS), kylin operating system (kylin os), etc., is referred to.
Referring to fig. 1, an embodiment of the present invention provides a method for sharing video between system-level processes in a Linux operating system, which includes the following steps:
s1, creating a memory virtual file;
s2, collecting video data by a back-end process;
s3, writing each frame of image of the video data into the memory virtual file;
s4, after the writing is finished, the back-end process sends an image writing finishing signal to the front-end process;
and S5, the front-end process receives the image writing completion signal, and reads each frame of image of the video data from the memory virtual file for drawing.
The method can provide a transmission mode of video messages among processes based on a Linux operating system, and video data is transferred and stored by using the memory virtual file.
In specific implementation, referring to fig. 2, on the Linux operating system, there are two processes, one is a process a pulled up by a system service, i.e., the backend process, which is responsible for acquiring the video data and performing a related authority authentication processing action; another process is the front-end process, which is responsible for drawing the relevant interface, for example, the process may be a UI image drawing process. Although the subsequent end process is in the application level process, the related window can be drawn independently to draw the collected image. However, when the system is applied to an operating system, the system is often pulled up as a system service due to designing operations such as operating system authority authentication, login and the like, and particularly, the system can be regarded as a system process on a Linux operating system. Since no relevant graphics resource is used for image display, relevant video image frame data must be transmitted to the front-end process for drawing, namely inter-process communication of video messages on Linux is involved.
When the user interacts with the front-end process, the user performs related operations to request video information, the front-end process calls a rear-end interface to acquire video information to obtain the video data, and the rear-end process starts to acquire video image frames and creates a memory virtual file; and then, the back-end process writes each acquired frame of video image into the memory virtual file, after the writing is finished, an image writing finishing signal is sent to the front-end process, and the front-end process receives the image writing finishing signal, reads related frame image data from the previously received memory virtual file, draws on a related interface, for example, draws on a UI interface, and repeats in this cycle, so as to realize the display of the video on the UI interface. And when the front-end process terminates the related video, calling the related interface provided by the back-end process again to terminate the acquisition of the video image of the back-end process.
In this embodiment, the step S1 further includes obtaining a file descriptor of the memory virtual file, and the step S3 writes each frame of image of the video data into the memory virtual file through the pointing direction of the file descriptor. Specifically, the back-end process may create the memory virtual file through memfd _ create, obtain a file descriptor fd of the memory virtual file, and return the fd to the front-end process through a dbus channel (dbus may specify a transfer parameter as file descriptor); and the back-end process writes each acquired frame of video image into the memory virtual file pointed by the file descriptor, and sends an image writing completion signal to the front end through the dbus channel after the writing is completed.
In this embodiment, the backend process typically collects the video data through a camera. Specifically, the camera is instantiated by using an opencv related class, and a video frame of the camera is read circularly to obtain the video data. The method has wide application in the field of face recognition, provides a transmission mode of video messages among processes based on a Linux operating system, and can solve the problem that a face acquisition picture cannot be displayed in real time when face recognition authentication is carried out at the level of the Linux operating system.
Specifically, referring to fig. 2, when the system is started to log in, a face recognition manner is adopted to log in, at this time, the front-end process is a login interface process, and the back-end process is a related biometric management process. When a user selects face recognition login on a login interface, the front-end process calls an authentication interface of the back-end process face recognition module, and the back-end process performs the following operations in an authentication process:
1) creating a memory virtual file, and acquiring a file descriptor: and creating by using memfd _ create, wherein the api return value is the file descriptor of the successfully created virtual memory file, and synchronizing to the front-end process through the authentication interface.
2) And starting the camera, reading the video stream of the picture acquired by the camera, instantiating the camera by using opencv related classes, and circularly reading the video frame of the camera.
3) And writing each frame image into the memory virtual file pointed by the file descriptor, and specifically writing image binary data into the file through a system interface write.
4) And the back-end process sends an image writing completion signal to the front-end process.
5) And the front-end process receives the image writing completion signal and reads video frame data from the memory virtual file for drawing.
In this embodiment, after the face recognition is completed, the backend process closes the camera to stop reading the video data from the camera, releases the relevant memory virtual file and file descriptor, and releases the created memory virtual file and file descriptor, thereby avoiding the generation of memory garbage, and further avoiding the influence on performance when video messages are transmitted for many times.
Based on the same inventive concept, the invention further provides an electronic device, which includes a processor and a memory, where the memory stores a computer program, and when the computer program is executed by the processor, the method for retrieving full-text file data based on authority control is implemented.
The processor may be, in some embodiments, a Central Processing Unit (CPU), a controller, a microcontroller, a microprocessor (e.g., a GPU), or other data Processing chip. The processor is typically used to control the overall operation of the electronic device. In this embodiment, the processor is configured to run a program code stored in the memory or process data, for example, a program code of a system level inter-process video sharing method on the Linux operating system.
The memory includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the storage may be an internal storage unit of the electronic device, such as a hard disk or a memory of the electronic device. In other embodiments, the memory may also be an external storage device of the electronic device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the electronic device. Of course, the memory may also include both internal and external memory units of the electronic device. In this embodiment, the memory is generally configured to store an operating method installed in the electronic device and various types of application software, for example, a program code of a system level inter-process video sharing method on the Linux operating system. Further, the memory may be used to temporarily store various types of data that have been output or are to be output.
Based on the same idea, the invention further provides a readable storage medium, wherein a computer program is stored in the readable storage medium, and when the computer program is executed by a processor, the method for sharing the inter-system-level process video on the Linux operating system is realized.
In conclusion, the invention has the advantages that the invention provides a transmission mode of video information among processes based on the Linux operating system, and can solve the problem that the face acquisition picture can not be displayed in real time when face recognition authentication is carried out at the level of the Linux operating system; furthermore, the invention uses the memory virtual file to transfer the video data, and because the operation is directly carried out in the memory, the IO expense caused by creating the actual disk file is avoided; finally, when the video message transmission is finished, the created memory virtual file and the file descriptor are released, so that the generation of memory garbage is avoided, and further, the influence on the performance when the video message transmission is carried out for multiple times is avoided.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not cause the essence of the corresponding technical solutions to depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for sharing video between system level processes on a Linux operating system is characterized by comprising the following steps:
s1, creating a memory virtual file;
s2, collecting video data by a back-end process;
s3, writing each frame of image of the video data into the memory virtual file;
s4, after the writing is finished, the back-end process sends an image writing finishing signal to the front-end process;
and S5, the front-end process receives the image writing completion signal, and reads each frame of image of the video data from the memory virtual file for drawing.
2. The method of claim 1, wherein step S1 further comprises obtaining a file descriptor of the memory virtual file, and step S3 writes each frame image of the video data into the memory virtual file by pointing the file descriptor.
3. The method for sharing system level inter-process video on Linux operating system of claim 2, wherein step S1 specifically includes: the memory virtual file is created through memfd _ create, the created api return value is synchronized to the front-end process through an authentication interface, and the api return value is the file descriptor.
4. The method for system level inter-process video sharing on a Linux operating system of claim 1, wherein the back-end process captures the video data through a camera.
5. The method as claimed in claim 4, wherein the cameras are instantiated by opencv correlation classes, and video frames of the cameras are read in a circulating manner to obtain the video data.
6. The inter-system-level-on-Linux-operating-system video sharing method of claim 5, wherein the inter-system-level-on-Linux-operating-system video sharing method is used for face recognition.
7. The method of claim 6, wherein after face recognition is completed, the backend process stops obtaining the video data and releases the memory virtual file.
8. The method of claim 1, wherein information is communicated between the front-end process and the back-end process via a dbus channel.
9. An electronic device comprising a processor and a memory, the memory having stored thereon a computer program which, when executed by the processor, implements the method of any of claims 1 to 8.
10. A readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method of any one of claims 1 to 8.
CN202210500318.0A 2022-05-10 2022-05-10 Method for sharing video between system-level processes on Linux operating system Pending CN114595084A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210500318.0A CN114595084A (en) 2022-05-10 2022-05-10 Method for sharing video between system-level processes on Linux operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210500318.0A CN114595084A (en) 2022-05-10 2022-05-10 Method for sharing video between system-level processes on Linux operating system

Publications (1)

Publication Number Publication Date
CN114595084A true CN114595084A (en) 2022-06-07

Family

ID=81813213

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210500318.0A Pending CN114595084A (en) 2022-05-10 2022-05-10 Method for sharing video between system-level processes on Linux operating system

Country Status (1)

Country Link
CN (1) CN114595084A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024021096A1 (en) * 2022-07-29 2024-02-01 京东方科技集团股份有限公司 Data sharing method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105868028A (en) * 2015-01-23 2016-08-17 华为技术有限公司 Method and device for sharing data between processes, and terminal
CN107622541A (en) * 2017-08-08 2018-01-23 建荣半导体(深圳)有限公司 A kind of storage device, USB camera and its driving recording method, system
CN110443114A (en) * 2019-06-19 2019-11-12 平安科技(深圳)有限公司 Face identification method, device, computer equipment and readable storage medium storing program for executing
CN112906075A (en) * 2021-03-15 2021-06-04 北京字节跳动网络技术有限公司 Memory sharing method and device
CN114296951A (en) * 2021-12-07 2022-04-08 北京天融信网络安全技术有限公司 Method, system, terminal and storage medium for inter-process data sharing

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105868028A (en) * 2015-01-23 2016-08-17 华为技术有限公司 Method and device for sharing data between processes, and terminal
CN107622541A (en) * 2017-08-08 2018-01-23 建荣半导体(深圳)有限公司 A kind of storage device, USB camera and its driving recording method, system
CN110443114A (en) * 2019-06-19 2019-11-12 平安科技(深圳)有限公司 Face identification method, device, computer equipment and readable storage medium storing program for executing
CN112906075A (en) * 2021-03-15 2021-06-04 北京字节跳动网络技术有限公司 Memory sharing method and device
CN114296951A (en) * 2021-12-07 2022-04-08 北京天融信网络安全技术有限公司 Method, system, terminal and storage medium for inter-process data sharing

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024021096A1 (en) * 2022-07-29 2024-02-01 京东方科技集团股份有限公司 Data sharing method and device

Similar Documents

Publication Publication Date Title
US11048913B2 (en) Focusing method, device and computer apparatus for realizing clear human face
CN111163345B (en) Image rendering method and device
EP2763034A1 (en) Method and device for image-capturing application screen for use in mobile terminal
CN114880259B (en) Data processing method, device, system, electronic equipment and storage medium
CN111782492A (en) Page first screen loading duration testing method and device, computer equipment and medium
CN114051145B (en) Video compression processing method, device and medium
CN111026493B (en) Interface rendering processing method and device
CN116662038B (en) Industrial information detection method, device, equipment and medium based on shared memory
CN114595084A (en) Method for sharing video between system-level processes on Linux operating system
CN113032080A (en) Page implementation method, application program, electronic device and storage medium
CN110390295B (en) Image information identification method and device and storage medium
CN116546228B (en) Plug flow method, device, equipment and storage medium for virtual scene
CN111930641A (en) Image data processing method and intelligent equipment
CN115309315B (en) Screenshot method, system and medium for X application in Wayland environment
CN113535293B (en) Android device screen capturing method, system and medium
CN112837158A (en) Stock data acquisition and storage method, device and system based on cloud computing technology
CN114945072A (en) Dual-camera frame synchronization processing method and device, user terminal and storage medium
CN112843691A (en) Method and device for shooting image, electronic equipment and storage medium
CN112181641A (en) Thread processing method, device, equipment and storage medium
KR101698484B1 (en) Method and apparatus for performing JAVA application
CN113780228B (en) Person evidence comparison method, system, terminal and medium
CN114071225B (en) Frame animation playing method, device and system
CN114710685B (en) Video stream processing method and device, terminal equipment and storage medium
CN116909998B (en) Method and device for processing files under overlay file system
CN116188245A (en) Memory optimization method for camera image rotation and terminal equipment

Legal Events

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