Image data acquisition method, device, storage medium and scanning apparatus
Patent Information
- Application Number
- CN202310784448.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-29
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2043-06-29
AI Technical Summary
[0004]本申请的目的旨在至少能解决上述的技术缺陷之一,特别是现有技术中的扫描设备无法独立使用扫描或相机,进而无法完全区分开相机和扫码头的内存,容易造成内存踩踏的技术缺陷
[0039]The image data acquisition method, apparatus, storage medium, and scanning device provided in this application are applied to scanning devices using the Qualcomm platform camera driver framework. When the scanning device detects the start of the scanning process and/or camera process, it can invoke the camera driver framework, which includes user space and kernel space. The kernel space includes a driver layer and a pre-added memory allocator. This allows the user space to allocate raw memory interfaces for the scanning process and/or camera process, and after labeling the raw memory interfaces according to the allocation objects, a target memory interface is obtained. This target memory interface is then sent to the driver layer in the kernel space. Since the labeling information of the target memory interface is obtained based on the allocation objects, the driver layer utilizes the target memory interface... After the annotation information is processed separately for the scanning process and/or camera process, the separately processed image data can be sent to the memory allocator. The memory allocator then stores the image data into different memory regions in the kernel buffer according to the target memory interface corresponding to the image data, thereby avoiding memory overflow caused by the simultaneous use of the camera process and the scanning process. Furthermore, the memory allocator of this application can also allocate corresponding file descriptors for the image data in different regions and upload the file descriptors to the user space. The modules in the user space corresponding to the scanning process and/or camera process can then read the image data in the corresponding memory region according to the file descriptors. This ensures that the scanning process and the camera process are independent of each other, and their data does not interfere with each other.
Smart Images

Figure CN116862745B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an image data acquisition method, apparatus, storage medium and scanning device. Background Technology
[0002] Currently, scanning devices based on the Qualcomm platform mainly treat scanning as a platform camera debugging process when acquiring image data, and directly call the relevant hardware through Google's camera driver framework to acquire image data.
[0003] When using Google's camera driver framework to directly call and obtain image data, the use of scanning and camera in the scanning device must be separated. In particular, when using the camera alone, scanning must be closed first. This makes it impossible for existing scanning devices to use scanning or camera independently. Furthermore, the camera called in this way cannot completely separate the memory of the camera and scanning device. Whoever requests the memory first has the right to use the current memory. When the scanning and camera processes open the camera hardware at the same time, it is more likely to cause memory overflow. Summary of the Invention
[0004] The purpose of this application is to at least solve one of the aforementioned technical defects, particularly the technical defect that existing scanning devices cannot use scanning or cameras independently, thus failing to completely separate the memory of the camera and the scanning device, which easily leads to memory overload.
[0005] This application provides an image data acquisition method, which is applied to a scanning device using a Qualcomm platform camera driver framework, including:
[0006] When the scanning process and / or camera process is detected to be starting, the camera driver framework is invoked. The camera driver framework includes user space and kernel space. The kernel space includes a driver layer and a pre-added memory allocator.
[0007] The user space allocates raw memory interfaces to the scanning process and / or the camera process, and after marking the raw memory interfaces according to the allocation objects, the target memory interfaces are obtained and the target memory interfaces are sent to the driver layer in the kernel space.
[0008] The driver layer is used to process the scanning process and / or the camera process separately according to the annotation information of the target memory interface, and the processed image data is stored in different memory intervals of the kernel buffer through the memory allocator according to the target memory interface;
[0009] After allocating corresponding file descriptors for image data in different memory ranges through the memory allocator, the file descriptors are uploaded to the user space so that the modules in the user space corresponding to the scanning process and / or the camera process can read the image data in the corresponding memory range according to the file descriptors.
[0010] Optionally, the user space includes a service layer and a hardware abstraction layer, wherein the service layer includes camera services and scanning services independent of the camera driver framework;
[0011] The step of allocating raw memory interfaces to the scanning process and / or the camera process through the user space, and then labeling the raw memory interfaces according to the allocation objects to obtain the target memory interface, includes:
[0012] The scanning service calls the hardware abstraction layer to allocate a first raw memory interface for the scanning process, and then marks the first raw memory interface according to the scanning process to obtain the first target memory interface.
[0013] And / or, by calling the hardware abstraction layer through the camera service to allocate a second raw memory interface for the camera process, and by annotating the second raw memory interface according to the camera process, a second target memory interface is obtained.
[0014] Optionally, the step of using the driver layer to process the scanning process and / or the camera process separately according to the annotation information of the target memory interface includes:
[0015] The driver layer distinguishes the scanning process and / or the camera process according to the labeling information of the target memory interface, and establishes communication connections with the camera hardware based on the distinction results, and then receives the image data returned by the camera hardware.
[0016] Optionally, the user space includes a service layer, which includes a camera service and a scanning service independent of the camera driver framework;
[0017] The step of reading image data from the corresponding memory region according to the file descriptor through the module corresponding to the scanning process and / or the camera process in the user space includes:
[0018] The camera service in the user space reads image data from the memory region corresponding to the camera process according to the file descriptor.
[0019] And / or, through the scanning service in the user space, read image data from the memory region corresponding to the scanning process according to the file descriptor.
[0020] This application also provides an image data acquisition device, including:
[0021] The camera driver invocation module is used to invoke the camera driver framework when the scanning process and / or camera process is detected to be starting. The camera driver framework includes user space and kernel space. The kernel space includes a driver layer and a pre-added memory allocator.
[0022] The memory interface allocation module is used to allocate raw memory interfaces to the scanning process and / or the camera process through the user space, and to obtain the target memory interface after marking the raw memory interface according to the allocation object, and to send the target memory interface to the driver layer in the kernel space.
[0023] The image data storage module is used to process the scanning process and / or the camera process separately using the driver layer according to the annotation information of the target memory interface, and to store the processed image data into different memory intervals of the kernel buffer through the memory allocator according to the target memory interface;
[0024] The image data reading module is used to allocate corresponding file descriptors for image data in different memory intervals through the memory allocator, and then upload the file descriptors to the user space, so that the module in the user space corresponding to the scanning process and / or the camera process can read the image data in the corresponding memory interval according to the file descriptors.
[0025] Optionally, the user space includes a service layer and a hardware abstraction layer, wherein the service layer includes camera services and scanning services independent of the camera driver framework;
[0026] The memory interface allocation module includes:
[0027] The first target memory interface allocation module is used to call the hardware abstraction layer through the scanning service to allocate a first raw memory interface for the scanning process, and to obtain the first target memory interface after marking the first raw memory interface according to the scanning process.
[0028] And / or, the second target memory interface allocation module is used to call the hardware abstraction layer through the camera service to allocate a second raw memory interface for the camera process, and to obtain the second target memory interface after marking the second raw memory interface according to the camera process.
[0029] Optionally, the image data storage module includes:
[0030] The image data storage submodule is used to distinguish the scanning process and / or the camera process according to the annotation information of the target memory interface using the driver layer, and to establish communication connections with the camera hardware respectively according to the distinction results, and then receive the image data returned by the camera hardware respectively.
[0031] Optionally, the user space includes a service layer, which includes a camera service and a scanning service independent of the camera driver framework;
[0032] The image data reading module includes:
[0033] A camera image data reading module is used to read image data from the memory region corresponding to the camera process according to the file descriptor through the camera service in the user space.
[0034] And / or, a scan image data reading module, used to read image data in the memory region corresponding to the scan process according to the file descriptor through the scan service in the user space.
[0035] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the image data acquisition method as described in any of the above embodiments.
[0036] This application also provides a scanning device, including: one or more processors, and a memory;
[0037] The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the image data acquisition method as described in any of the above embodiments.
[0038] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0039] The image data acquisition method, apparatus, storage medium, and scanning device provided in this application are applied to scanning devices using the Qualcomm platform camera driver framework. When the scanning device detects the start of the scanning process and / or camera process, it can invoke the camera driver framework, which includes user space and kernel space. The kernel space includes a driver layer and a pre-added memory allocator. This allows the user space to allocate raw memory interfaces for the scanning process and / or camera process, and after labeling the raw memory interfaces according to the allocation objects, a target memory interface is obtained. This target memory interface is then sent to the driver layer in the kernel space. Since the labeling information of the target memory interface is obtained based on the allocation objects, the driver layer utilizes the target memory interface... After the annotation information is processed separately for the scanning process and / or camera process, the separately processed image data can be sent to the memory allocator. The memory allocator then stores the image data into different memory regions in the kernel buffer according to the target memory interface corresponding to the image data, thereby avoiding memory overflow caused by the simultaneous use of the camera process and the scanning process. Furthermore, the memory allocator of this application can also allocate corresponding file descriptors for the image data in different regions and upload the file descriptors to the user space. The modules in the user space corresponding to the scanning process and / or camera process can then read the image data in the corresponding memory region according to the file descriptors. This ensures that the scanning process and the camera process are independent of each other, and their data does not interfere with each other. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0041] Figure 1 A flowchart illustrating an image data acquisition method provided in an embodiment of this application;
[0042] Figure 2 A flowchart illustrating the call to the improved camera driver framework provided in this application embodiment;
[0043] Figure 3 A flowchart illustrating the call to the pre-improved camera driver framework provided in this application embodiment;
[0044] Figure 4 This is a schematic diagram of the structure of an image data acquisition device provided in an embodiment of this application;
[0045] Figure 5This is a schematic diagram of the internal structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0046] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0047] Currently, when using Google's camera driver framework to directly call and obtain image data, the use of scanning and camera in the scanning device must be separated. In particular, when using the camera alone, scanning must be closed first. This makes it impossible for existing scanning devices to use scanning or camera independently. Furthermore, the camera called in this way cannot completely separate the memory of the camera and the scanning device. Whoever requests the memory first has the right to use the current memory. When the scanning and camera processes open the camera hardware at the same time, it is more likely to cause memory overflow.
[0048] Based on this, this application proposes the following technical solution, as detailed below:
[0049] In one embodiment, such as Figure 1 As shown, Figure 1 This is a flowchart illustrating an image data acquisition method provided in an embodiment of this application. This application provides an image data acquisition method applied to a scanning device using a Qualcomm platform camera driver framework, which may include:
[0050] S110: When the scanning process and / or camera process is detected to be starting, the camera driver framework is invoked.
[0051] In this step, when the scanning device detects the start of the scanning process and / or camera process, it can call the pre-configured camera driver framework to acquire image data.
[0052] Understandably, a camera driver framework based on the Qualcomm platform typically includes user space and kernel space. User space directly interacts with the application and loads relevant request data sent by the application into kernel space through a series of system calls. In kernel space, the driver layer interacts with the corresponding hardware device, such as the camera hardware, based on this request data. After obtaining the image data returned by the hardware device through the interface, it loads it into the kernel buffer. Then, the kernel space can copy the image data stored in the kernel buffer to user space, allowing for operations on the image data in user space, thereby enabling functions such as preview, taking photos, recording videos, opening, and closing.
[0053] As can be seen from the above camera driver framework calling process, the calling flow is consistent for both the scanning process and the camera process. This leads to the existing camera calling process being unable to completely separate the memory of the camera and the scanning head. When both the scanning and camera processes simultaneously open the camera hardware, memory overflow can easily occur. Therefore, this application can improve the module in the original user space responsible for allocating and releasing kernel buffers. Correspondingly, this application can also add a memory allocator in the kernel space to implement and manage operations related to the kernel buffer, thereby separating the memory corresponding to the scanning process and the camera process.
[0054] It should be noted that the scanning device in this application can be an industrial-grade PDA device or other terminal devices with scanning capabilities, without limitation. The camera driver framework configured in the scanning device is based on the Qualcomm platform, such as the Qualcomm CamX platform or other Qualcomm platforms. When the scanning device detects the startup of the scanning process and / or camera process in this application, it can be obtained by detecting the same application sequentially or by detecting different applications. For example, when monitoring the application status of the camera application, if the camera application creates both the camera process and the scanning process sequentially, it indicates that both the scanning process and the camera process are currently running. If the camera application creates one process and the scanning application creates one process, it also indicates that both the scanning process and the camera process are currently running. However, if only one process is running for both applications, it indicates that only one process is running.
[0055] S120: Allocate raw memory interfaces for the scanning process and / or camera process in user space, and obtain the target memory interface after marking the raw memory interface according to the allocation object, and send the target memory interface to the driver layer in kernel space.
[0056] In this step, after the scanning process and / or camera process are detected to start by S110 and the camera driver framework is called, this application can allocate a raw memory interface for the scanning process and / or camera process through the user space in the camera driver framework. Then, after marking the raw memory interface according to the allocation object to obtain the target memory interface, the target memory interface is sent to the driver layer in the kernel space.
[0057] Specifically, the user space of this application can separate the processes of the scanning process and the camera process, and allocate corresponding raw memory interfaces for the scanning process and / or the camera process respectively. After marking the raw memory interfaces according to the allocation object, the target memory interface is obtained. After the target memory interface is sent to the driver layer, the driver layer can not only know which process the target memory interface is allocated to through the marking information of the target memory interface, but also use the memory allocator to connect the target memory interface with the memory partitions of different areas in the kernel buffer, so as to store the data of different processes into different memory partitions.
[0058] S130: The driver layer processes the scanning process and / or camera process separately according to the annotation information of the target memory interface, and stores the processed image data into different memory ranges of the kernel buffer through the memory allocator according to the target memory interface.
[0059] In this step, after the original memory interface is marked according to the allocation object by S120 to obtain the target memory interface, the driver layer can process the scanning process and / or camera process separately according to the marking information of the target memory interface, and store the image data obtained after separate processing into the kernel buffer through the memory allocator. When storing image data, the memory allocator can store the image data into different memory ranges of the kernel buffer according to the target memory interface corresponding to the image data.
[0060] For example, when the target memory interface annotation information received by the driver layer indicates that the target memory interface is allocated for a scanning process, the driver layer can process the scanning process, such as communicating with the corresponding camera hardware based on the scanning process's process information to obtain image data; when the target memory interface annotation information received by the driver layer indicates that the target memory interface is allocated for a camera process, the driver layer can process the camera process, such as communicating with the corresponding camera hardware based on the camera process's process information to obtain image data; when the driver layer receives two target memory interfaces, and the annotation information of different target memory interfaces indicates that the target memory interfaces were allocated for different processes, the driver layer can process the different processes separately, such as communicating with the corresponding camera hardware based on the camera process's process information to obtain image data, and communicating with the corresponding camera hardware based on the scanning process's process information to obtain image data.
[0061] Furthermore, after acquiring the image data corresponding to the scanning process and / or the camera process, the memory allocator in the kernel space can store the image data of different processes into different memory intervals of the kernel buffer according to the target memory interface corresponding to the image data of different processes. For example, the image data corresponding to the scanning process can be stored into the memory interval of the kernel buffer corresponding to the scanning process through its corresponding target memory interface, and the image data corresponding to the camera process can be stored into the memory interval of the kernel buffer corresponding to the camera process through its corresponding target memory interface. This distinguishes the memory of the scanning process and the camera process. In this way, even if the scanning process and the camera process are opened and used at the same time, they can be processed separately through the driver layer and the corresponding image data can be stored separately through different memory partitions, thereby enabling the simultaneous use of scanning and camera without data interference.
[0062] S140: After allocating corresponding file descriptors for image data in different memory ranges through the memory allocator, the file descriptors are uploaded to the user space so that the modules in the user space corresponding to the scanning process and / or camera process can read the image data in the corresponding memory range according to the file descriptors.
[0063] In this step, after the processed image data is stored in different memory regions of the kernel buffer by the memory allocator according to the target memory interface via S130, the memory allocator can also allocate corresponding file descriptors for the image data in different memory regions. The file descriptor refers to the index corresponding to the image data in different memory regions. After the memory allocator uploads the file descriptor to the user space, the modules in the user space corresponding to the scanning process and / or camera process can read the image data of the corresponding memory region in the kernel buffer according to the file descriptor, and perform corresponding image operations on the read image data, such as preview, take a picture, record a video, open, close, etc.
[0064] It is understood that the kernel buffer in this application refers to a DMA-Buffer, which can be divided into an exporter and an importer. The exporter is used to implement and manage all operations related to the buffer, while the importer can be understood as one of the users of these shared buffers. This application can implement a memory allocator based on the DMA-BUF framework, which can be understood as a wrapper around the exporter. This memory allocator can define memory regions in the smallest unit (chunk) and then manage memory according to object size. For example, small memory is divided into several size classes, which are specifically used to allocate fixed-size memory blocks and managed by a table to reduce internal fragmentation, while large memory is managed in units of pages, in conjunction with the pages where small objects reside, to further reduce fragmentation. In addition, when the kernel buffer releases memory, the memory allocator can also merge small memory into large memory and retain the memory that can be retained based on certain conditions, so that it can respond quickly when used again; when it is not needed, it is released back to the system, which can also avoid long-term occupation.
[0065] In the above embodiments, when the scanning device detects the start of the scanning process and / or camera process, it can invoke the camera driver framework. This camera driver framework includes user space and kernel space, where the kernel space includes a driver layer and a pre-added memory allocator. This allows the user space to allocate raw memory interfaces for the scanning process and / or camera process, and after labeling the raw memory interfaces according to the allocation objects, a target memory interface is obtained. This target memory interface is then sent to the driver layer in the kernel space. Since the labeling information of the target memory interface is obtained based on the allocation objects, the driver layer uses this labeling information to process the scanning process and / or camera process separately. After processing, the separately processed image data can be sent to the memory allocator, so that the memory allocator can store the image data into different memory intervals in the kernel buffer according to the target memory interface corresponding to the image data. This avoids memory overflow caused by the simultaneous use of the camera process and the scanning process. Furthermore, the memory allocator of this application can also allocate corresponding file descriptors for the image data in different intervals and upload the file descriptors to the user space. The modules in the user space corresponding to the scanning process and / or the camera process can then read the image data in the corresponding memory interval according to the file descriptors. This makes the scanning process and the camera process independent of each other, and their data does not interfere with each other.
[0066] In one embodiment, such as Figure 2 , Figure 3 As shown, Figure 2The flowchart of the call to the improved camera driver framework provided in the embodiments of this application is as follows. Figure 3 The flowchart illustrates the calling process of the pre-improved camera driver framework provided in this application embodiment; the user space may include a service layer and a hardware abstraction layer, and the service layer may include camera services and scanning services independent of the camera driver framework.
[0067] In S120, raw memory interfaces are allocated to the scanning process and / or the camera process through the user space, and the target memory interface is obtained by labeling the raw memory interfaces according to the allocation object. This may include:
[0068] S121: The scanning service calls the hardware abstraction layer to allocate a first raw memory interface for the scanning process, and the first target memory interface is obtained by marking the first raw memory interface according to the scanning process.
[0069] And / or, S122: The camera service calls the hardware abstraction layer to allocate a second raw memory interface for the camera process, and the second target memory interface is obtained by annotating the second raw memory interface according to the camera process.
[0070] In this embodiment, when allocating raw memory interfaces for the scanning process and / or camera process through user space, the scanning service can call the hardware abstraction layer to allocate a first raw memory interface for the scanning process. After marking the first raw memory interface according to the scanning process, a first target memory interface is obtained. In this way, after the driver layer receives the first target memory interface, it can determine that the current process is the scanning process based on the marking information of the first target memory interface. Of course, if this application detects that the camera process has started, the memory interface can also be allocated according to the memory allocation method of the process described above. If the process detected by this application is both the scanning process and the camera process, the memory interfaces can be allocated to the corresponding processes according to the memory allocation methods of the scanning process and the camera process, and the memory interfaces can be marked.
[0071] Indicatively, such as Figure 2As shown, the improved camera driver framework of this application can include a Scanner Program, a Camera Service, a Camera HAL (Hardware Abstraction Layer), a Camera Driver, a Memory Allocator, and a DMA Buffer. When the Camera App sends a relevant request, the service layer can determine the corresponding process based on the request, assigning the scanning process to the Scanner Service and the camera process to the Camera Service. When the Scanner Service and / or the Camera Service are processing the corresponding processes, they can call the interface of the Hardware Abstraction Layer and, through this interface, call the functions of the Hardware Abstraction Layer to allocate raw memory interfaces for the scanning process and / or the camera process. The raw memory interfaces are then labeled according to the allocation objects, i.e., the scanning process and / or the camera process, to obtain the target memory interface. Thus, after receiving the target memory interface, the driver layer can process different processes separately, and the memory allocator can also store the image data obtained by different processes into different memory regions of the kernel buffer according to the target memory interface. Compared to... Figure 3 The unimproved camera driver framework uses the same calling process. In this application, the kernel buffer can be partitioned and stored for different processes. This can support two processes opening the camera at the same time, and avoid the memory trampling phenomenon caused by two processes opening the camera at the same time.
[0072] Understandably, the Scanner Program mentioned above is a framework independent of the Google system, which can perform operations such as opening, previewing, and closing the scanning head.
[0073] In one embodiment, S130, which utilizes the driver layer to process the scanning process and / or the camera process separately according to the annotation information of the target memory interface, may include:
[0074] S131: The driver layer distinguishes the scanning process and / or the camera process according to the labeling information of the target memory interface, and establishes communication connections with the camera hardware respectively based on the distinction results, and then receives the image data returned by the camera hardware respectively.
[0075] In this embodiment, when the driver layer receives a target memory interface, it can process the current process according to the annotation information of the target memory interface. For example, when the driver layer receives one target memory interface, and the annotation information shows that the target memory interface is the memory interface corresponding to the scanning process or the camera process, it can establish a communication connection with the corresponding camera hardware to obtain image data according to the process information of the scanning process or the camera process; when the driver layer receives two target memory interfaces, and the annotation information shows that the two target memory interfaces are the memory interfaces corresponding to the scanning process and the camera process, respectively, it can establish a communication connection with the corresponding camera hardware according to the process information of the scanning process and the camera process to obtain the relevant image data respectively, thereby distinguishing the two processes.
[0076] In one embodiment, the user space may include a service layer, which may include a camera service and a scanning service independent of the camera driver framework.
[0077] S140, where the module corresponding to the scanning process and / or the camera process in the user space reads image data from the corresponding memory region according to the file descriptor, may include:
[0078] S141: The camera service in the user space reads the image data in the memory region corresponding to the camera process according to the file descriptor.
[0079] And / or, S142: Read image data from the memory region corresponding to the scanning process according to the file descriptor through the scanning service in the user space.
[0080] In this embodiment, as Figure 2 As shown, when this application divides the service layer into a camera service and a scanning service independent of the camera driver framework, after the memory allocator generates the corresponding file descriptor, it can upload the file descriptor to the module in user space corresponding to the image data of that file descriptor. For example, when the memory allocator generates the corresponding file descriptor for the image data acquired by the scanning process, it can upload the file descriptor to the scanning service. After the scanning service obtains the file descriptor, it can read the image data in the corresponding memory area in the kernel buffer according to the file descriptor, perform relevant image operations on the read image data, and return it to the application for display. Similarly, when the memory allocator generates the corresponding file descriptor for the image data acquired by the camera process, it can also perform corresponding image data acquisition operations to obtain the relevant data, process it, and send it to the application for display.
[0081] The image data acquisition apparatus provided in the embodiments of this application is described below. The image data acquisition apparatus described below can be referred to in correspondence with the image data acquisition method described above.
[0082] In one embodiment, such as Figure 4 As shown, Figure 4 This is a schematic diagram of an image data acquisition device provided in an embodiment of this application. This application also provides an image data acquisition device, including a camera driver invocation module 210, a memory interface allocation module 220, an image data storage module 230, and an image data reading module 240, specifically comprising the following:
[0083] The camera driver invocation module 210 is used to invoke the camera driver framework when the scanning process and / or camera process is detected to start. The camera driver framework includes user space and kernel space. The kernel space includes a driver layer and a pre-added memory allocator.
[0084] The memory interface allocation module 220 is used to allocate raw memory interfaces to the scanning process and / or the camera process through the user space, and to obtain target memory interfaces by marking the raw memory interfaces according to the allocation objects, and to send the target memory interfaces to the driver layer in the kernel space.
[0085] The image data storage module 230 is used to process the scanning process and / or the camera process separately using the driver layer according to the annotation information of the target memory interface, and to store the processed image data into different memory ranges of the kernel buffer through the memory allocator according to the target memory interface.
[0086] The image data reading module 240 is used to allocate corresponding file descriptors for image data in different memory intervals through the memory allocator, and then upload the file descriptors to the user space so that the module in the user space corresponding to the scanning process and / or the camera process can read the image data in the corresponding memory interval according to the file descriptor.
[0087] In the above embodiments, when the scanning device detects the start of the scanning process and / or camera process, it can invoke the camera driver framework. This camera driver framework includes user space and kernel space, where the kernel space includes a driver layer and a pre-added memory allocator. This allows the user space to allocate raw memory interfaces for the scanning process and / or camera process, and after labeling the raw memory interfaces according to the allocation objects, a target memory interface is obtained. This target memory interface is then sent to the driver layer in the kernel space. Since the labeling information of the target memory interface is obtained based on the allocation objects, the driver layer uses this labeling information to process the scanning process and / or camera process separately. After processing, the separately processed image data can be sent to the memory allocator, so that the memory allocator can store the image data into different memory intervals in the kernel buffer according to the target memory interface corresponding to the image data. This avoids memory overflow caused by the simultaneous use of the camera process and the scanning process. Furthermore, the memory allocator of this application can also allocate corresponding file descriptors for the image data in different intervals and upload the file descriptors to the user space. The modules in the user space corresponding to the scanning process and / or the camera process can then read the image data in the corresponding memory interval according to the file descriptors. This makes the scanning process and the camera process independent of each other, and their data does not interfere with each other.
[0088] In one embodiment, the user space includes a service layer and a hardware abstraction layer, the service layer including camera services and scanning services independent of the camera driver framework.
[0089] The memory interface allocation module 220 includes:
[0090] The first target memory interface allocation module is used to call the hardware abstraction layer through the scanning service to allocate a first raw memory interface for the scanning process, and to obtain the first target memory interface after marking the first raw memory interface according to the scanning process.
[0091] And / or, the second target memory interface allocation module is used to call the hardware abstraction layer through the camera service to allocate a second raw memory interface for the camera process, and to obtain the second target memory interface after marking the second raw memory interface according to the camera process.
[0092] In one embodiment, the image data storage module 230 includes:
[0093] The image data storage submodule is used to distinguish the scanning process and / or the camera process according to the annotation information of the target memory interface using the driver layer, and to establish communication connections with the camera hardware respectively according to the distinction results, and then receive the image data returned by the camera hardware respectively.
[0094] In one embodiment, the user space includes a service layer that includes a camera service and a scanning service independent of the camera driver framework.
[0095] The image data reading module 240 includes:
[0096] The camera image data reading module is used to read image data from the memory region corresponding to the camera process according to the file descriptor through the camera service in the user space.
[0097] And / or, a scan image data reading module, used to read image data in the memory region corresponding to the scan process according to the file descriptor through the scan service in the user space.
[0098] In one embodiment, this application also provides a storage medium storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the image data acquisition method as described in any of the above embodiments.
[0099] In one embodiment, this application also provides a scanning device, including: one or more processors, and memory.
[0100] The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the image data acquisition method as described in any of the above embodiments.
[0101] Indicatively, such as Figure 5 As shown, Figure 5 This is a schematic diagram of the internal structure of a computer device 300 provided in an embodiment of this application. The computer device 300 can be provided as a server. (Refer to...) Figure 5 The computer device 300 includes a processing component 302, which further includes one or more processors, and memory resources represented by memory 301 for storing instructions, such as application programs, that can be executed by the processing component 302. The application programs stored in memory 301 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 302 is configured to execute instructions to perform the image data acquisition method of any of the above embodiments.
[0102] The computer device 300 may also include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate on an operating system stored in memory 301, such as Windows Server™, Mac OS X™, Unix™, Linux™, Free BSD™, or similar.
[0103] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0104] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0105] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0106] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for acquiring image data, characterized in that, The method is applied to scanning devices using Qualcomm platform camera driver frameworks, including: When the scanning process and / or camera process is detected to be starting, the camera driver framework is invoked. The camera driver framework includes user space and kernel space. The kernel space includes a driver layer and a pre-added memory allocator. The user space allocates raw memory interfaces to the scanning process and / or the camera process, and after marking the raw memory interfaces according to the allocation objects, the target memory interfaces are obtained and the target memory interfaces are sent to the driver layer in the kernel space. The driver layer is used to process the scanning process and / or the camera process separately according to the annotation information of the target memory interface, and the processed image data is stored in different memory intervals of the kernel buffer through the memory allocator according to the target memory interface; After allocating corresponding file descriptors for image data in different memory ranges through the memory allocator, the file descriptors are uploaded to the user space so that the modules in the user space corresponding to the scanning process and / or the camera process can read the image data in the corresponding memory range according to the file descriptors. The user space includes a service layer and a hardware abstraction layer. The service layer includes camera services and scanning services independent of the camera driver framework. The step of allocating raw memory interfaces to the scanning process and / or the camera process through the user space, and then labeling the raw memory interfaces according to the allocation objects to obtain the target memory interface, includes: The scanning service calls the hardware abstraction layer to allocate a first raw memory interface for the scanning process, and then marks the first raw memory interface according to the scanning process to obtain the first target memory interface. And / or, by calling the hardware abstraction layer through the camera service to allocate a second raw memory interface for the camera process, and by marking the second raw memory interface according to the camera process to obtain a second target memory interface; The step of using the driver layer to process the scanning process and / or the camera process separately according to the annotation information of the target memory interface includes: The driver layer distinguishes the scanning process and / or the camera process according to the labeling information of the target memory interface, and establishes communication connections with the camera hardware respectively based on the distinction results, and then receives the image data returned by the camera hardware respectively.
2. The image data acquisition method according to claim 1, characterized in that, The step of reading image data from the corresponding memory region according to the file descriptor through the module corresponding to the scanning process and / or the camera process in the user space includes: The camera service in the user space reads image data from the memory region corresponding to the camera process according to the file descriptor. And / or, through the scanning service in the user space, read image data from the memory region corresponding to the scanning process according to the file descriptor.
3. An image data acquisition device, characterized in that, include: The camera driver invocation module is used to invoke the camera driver framework when the scanning process and / or camera process is detected to be starting. The camera driver framework includes user space and kernel space. The kernel space includes a driver layer and a pre-added memory allocator. The memory interface allocation module is used to allocate raw memory interfaces to the scanning process and / or the camera process through the user space, and to obtain the target memory interface after marking the raw memory interface according to the allocation object, and to send the target memory interface to the driver layer in the kernel space. The image data storage module is used to process the scanning process and / or the camera process separately using the driver layer according to the annotation information of the target memory interface, and to store the processed image data into different memory intervals of the kernel buffer through the memory allocator according to the target memory interface; The image data reading module is used to allocate corresponding file descriptors for image data in different memory ranges through the memory allocator, and then upload the file descriptors to the user space, so that the module in the user space corresponding to the scanning process and / or the camera process can read the image data in the corresponding memory range according to the file descriptors. The user space includes a service layer and a hardware abstraction layer. The service layer includes camera services and scanning services independent of the camera driver framework. The memory interface allocation module includes: The first target memory interface allocation module is used to call the hardware abstraction layer through the scanning service to allocate a first raw memory interface for the scanning process, and to obtain the first target memory interface after marking the first raw memory interface according to the scanning process. And / or, the second target memory interface allocation module is used to call the hardware abstraction layer through the camera service to allocate a second raw memory interface for the camera process, and to obtain the second target memory interface after marking the second raw memory interface according to the camera process; The image data storage module includes: The image data storage submodule is used to distinguish the scanning process and / or the camera process according to the annotation information of the target memory interface using the driver layer, and to establish communication connections with the camera hardware respectively according to the distinction results, and then receive the image data returned by the camera hardware respectively.
4. The image data acquisition device according to claim 3, characterized in that, The image data reading module includes: A camera image data reading module is used to read image data from the memory region corresponding to the camera process according to the file descriptor through the camera service in the user space. And / or, a scan image data reading module, used to read image data in the memory region corresponding to the scan process according to the file descriptor through the scan service in the user space.
5. A storage medium, characterized in that: The storage medium stores computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the image data acquisition method as described in any one of claims 1 to 2.
6. A scanning device, characterized in that, include: One or more processors, and memory; The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the image data acquisition method as described in any one of claims 1 to 2.
Citation Information
Patent Citations
Camera and scanning service switching method and device, storage medium and computer equipment
CN115390933A
Memory management method based on multiple processes
CN115576716A