Data storage method, device and electronic device
By initializing and indexing the stored data, and saving data that meets the conditions in parallel, the hardware platform pipeline interruption problem caused by data-by-data judgment in the prior art is solved, and data processing speed and processor performance are improved.
Patent Information
- Application Number
- CN202110682250.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-20
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2041-06-20
AI Technical Summary
In the data processing process, the prior art determines whether the conditions are met by data after data processing, which causes the hardware platform pipeline to be interrupted, limits the processor performance and leads to poor algorithm performance.
By obtaining the data to be stored, initializing it into a data sequence group, assigning each data index, and using the index to save data that meets the preset conditions in parallel, avoiding interruption of instruction pipelines caused by data-by-data judgment.
Improves data processing speed, avoids interruption of instruction pipelines, and improves processor performance and algorithm efficiency.
Smart Images

Figure CN113535117B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data storage method, device and electronic device. Background Art
[0002] Data processing is the collection, storage, retrieval, processing, transformation and transmission of data. The three most common types of data storage are stacks, queues and priority queues.
[0003] In the process of data calculation and processing, it is usually necessary to judge the data. By judging whether the data meets the conditions, the data that meets the conditions will be saved, such as being pushed into a stack, and the data that does not meet the conditions will be discarded. Under normal circumstances, the method of directly judging whether the conditions are met one by one and then storing them is adopted. This method can only operate on elements one by one, and each time it needs to be judged before storage, which will cause the hardware platform pipeline to be interrupted, greatly limiting the performance of the processor and causing the algorithm performance to deteriorate. Summary of the invention
[0004] In view of this, embodiments of the present application provide a data storage method, device, and electronic device, which can improve data processing efficiency.
[0005] In a first aspect, an embodiment of the present application provides a data storage method, including:
[0006] Acquire data to be stored, and initialize the data to be stored to obtain an initialized data sequence group;
[0007] Assigning an index corresponding to each data in the initialization data sequence group, where the index includes address information of each data;
[0008] Determine the data that meets the preset conditions in the initialization data sequence group, and save the data that meets the preset conditions in parallel using the index corresponding to the data.
[0009] The data storage method provided in this embodiment can avoid interruption of the instruction pipeline caused by judging each data (or element) one by one in each step, and can improve the data processing speed.
[0010] As an implementation of the first aspect, determining data in the initialization data sequence group that meets a preset condition, and using an index corresponding to the data to save the data that meets the preset condition in parallel, includes:
[0011] Determine the relationship between each data in the initialization data sequence group and a preset threshold, and record the comparison result of each data;
[0012] According to the comparison result, data meeting the preset condition is obtained, and the data meeting the preset condition is saved in parallel using the index corresponding to the data.
[0013] This implementation method first determines the relationship between each data in the initialization data sequence group and the preset threshold value, and then determines the data that meets the preset conditions. It is simple, fast and easy to implement.
[0014] As an implementation of the first aspect, the determining a relationship between each data in the initialization data sequence group and a preset threshold value includes:
[0015] Each data in the initialization data sequence group is compared with a preset threshold value using a comparison instruction.
[0016] This implementation is achieved through comparison instructions, and no new code needs to be developed, making this implementation easy to implement.
[0017] As an implementation of the first aspect, the initializing the data to be stored to obtain an initialization data sequence group includes:
[0018] Assigning a sequence number corresponding to each data in the data to be stored to obtain an initialization data sequence group; or
[0019] Preprocess each data in the data to be stored, assign a corresponding sequence number to each preprocessed data, and obtain an initialized data sequence group.
[0020] This implementation method initializes the data to be stored, improves the readability of the data, and facilitates subsequent determination of whether the data meets preset conditions.
[0021] As an implementation manner of the first aspect, the serial numbers are sorted in ascending or descending order.
[0022] In this implementation, the serial numbers are sorted in ascending or descending order, and the address or location information of the data is used in a simple manner to ensure the accuracy of data processing.
[0023] As an implementation of the first aspect, the assigning an index corresponding to each data in the initialization data sequence group, where the index includes address information of each data, includes:
[0024] The bit mask sequence is used to encode the sequence number of each data in the initialization data sequence group to obtain the index corresponding to each data.
[0025] This implementation adopts a bit mask sequence to implement encoding, and does not require the development of new codes, making this implementation easy to implement.
[0026] As an implementation of the first aspect, the assigning of an index corresponding to each data in the initialization data sequence group, after the index includes address information of each data, further includes:
[0027] Dividing the initialization data sequence group into a plurality of initialization data sequence subgroups;
[0028] The determining of data in the initialization data sequence group that meets the preset condition, and using the index corresponding to the data to save the data that meets the preset condition in parallel, includes:
[0029] The data meeting the preset conditions in each subgroup of the initialized data sequence are determined in parallel, and the data meeting the preset conditions are saved in parallel using the index corresponding to the data.
[0030] This implementation method determines the data that meets the preset conditions in each initialization data sequence group in parallel, further improving the data processing efficiency.
[0031] In a second aspect, an embodiment of the present application provides a data storage device, including:
[0032] An initialization module, used for acquiring data to be stored, and initializing the data to be stored to obtain an initialization data sequence group;
[0033] An index assigning module, used to assign an index corresponding to each data in the initialization data sequence group, where the index includes address information of each data;
[0034] The saving module is used to determine the data that meets the preset conditions in the initialization data sequence group, and save the data that meets the preset conditions in parallel using the index corresponding to the data.
[0035] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements the data storage method as described in the first aspect or any implementation method of the first aspect.
[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data storage method as described in the first aspect or any implementation of the first aspect is implemented.
[0037] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the data storage method as described in the first aspect or any implementation manner of the first aspect.
[0038] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions of the first aspect mentioned above and any implementation method of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0040] Figure 1 This is a schematic diagram of an implementation flow of a data storage method provided by an embodiment of the present application;
[0041] Figure 2 This is a schematic diagram of a specific implementation flow of step S130 in a data storage method provided in an embodiment of the present application;
[0042] Figure 3 This is a schematic diagram of parallel data stacking provided by an embodiment of the present application;
[0043] Figure 4 This is a schematic diagram of the implementation process of another data storage method provided by an embodiment of the present application;
[0044] Figure 5 This is a schematic diagram of the implementation process of another data storage method provided by an embodiment of the present application;
[0045] Figure 6 This is a schematic diagram of the structure of a data storage device provided by an embodiment of the present application;
[0046] Figure 7 This is a schematic diagram of a storage module in a data storage device provided in an embodiment of the present application.
[0047] Figure 8 is a schematic diagram of the structure of another data storage device provided by an embodiment of the present application;
[0048] Fig. 9 It is a structural schematic diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0049] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.
[0050] The term "and / or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0051] "One embodiment" or "some embodiments" described in the specification of this application means that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the sentences "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0052] In addition, in the description of the present application, "plurality" means two or more. The terms "first", "second", "third", and "fourth" are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0053] In order to illustrate the technical solution of the present invention, a specific embodiment is provided below for illustration.
[0054] At present, when storing data, such as pushing data into a stack, the method usually adopted is to judge whether the conditions are met for each data one by one and then save the data. This method can only operate on each data one by one, and each step needs to judge whether the conditions are met, which will cause the hardware platform pipeline to be interrupted, thereby greatly limiting the performance of the processor and causing the algorithm performance to deteriorate.
[0055] Especially in the process of image processing or filtering, it is necessary to judge whether the pixel value meets the conditions. If each pixel is judged one by one, the pipeline of the hardware platform will be interrupted, which greatly limits the calculation speed of the image processing process and reduces the output frame rate of the image.
[0056] In order to solve at least one of the above technical problems, an embodiment of the present application provides a data storage method, which can avoid the interruption of the instruction pipeline caused by judging each data (or element) one by one in each step, and can improve the data processing speed.
[0057] Figure 1This is a schematic diagram of the implementation process of a data storage method provided in one embodiment of the present application. The data storage method in this embodiment can be executed by an electronic device. The electronic device includes but is not limited to a computer, a tablet computer, a server, a mobile phone, a camera or a wearable device. The server includes but is not limited to an independent server or a cloud server. The data storage method in this embodiment is applicable to situations where data needs to be stored. Figure 1 As shown, the data storage method may include steps S110 to S140.
[0058] S110, acquiring data to be stored, and initializing the data to be stored to obtain an initialized data sequence group.
[0059] The data to be stored is a group of data to be stored. The data to be stored is initialized to obtain an initialized data sequence group.
[0060] In some embodiments, the electronic device can collect the data to be stored by itself. In these embodiments, the data to be stored can be collected by the electronic device through its own hardware, for example, the data to be stored is obtained through a sensor or camera device of the electronic device. The camera device includes but is not limited to: a camera or a camera module.
[0061] In some other embodiments, the electronic device can obtain the data to be stored from other devices, and the other devices are independent of the electronic device. The electronic device can actively obtain the data to be stored from other devices, or the other devices can actively transmit the data to be stored to the electronic device. This application does not limit the way in which the electronic device obtains the data to be stored from other devices. Other devices include but are not limited to electronic devices such as video cameras, cameras, mobile phones or tablet computers.
[0062] In some embodiments, initializing the data includes assigning a corresponding serial number to each data (or element) to obtain an initialized data sequence group.
[0063] As an implementation of these embodiments, a sequence number corresponding to each data is assigned according to the order in which the data is arranged, and an initialized data sequence group is obtained. As a non-limiting example, a group of data to be stored includes 32 data arranged in sequence, and the initialized data sequence group can be: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, and the initialized data sequence group includes 32 data. This example uses sequence numbers to illustrate data, not the data itself. This example uses an ascending arrangement to number the data. It should be noted that, in fact, the initialized data sequence group includes a sequence of data assigned with sequence numbers. In some other examples, the sequence number may not start from 0, but may instead start numbering from 1 or any positive integer. In some other examples, the initialization data sequence group can be numbered in descending order. For example, a group of data to be stored includes 32 data, and the initialization data sequence group can be illustrated as: {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}.
[0064] In some other embodiments, initializing the acquired data may include: first, preprocessing each data, the preprocessing includes but is not limited to: normalizing, standardizing and unitizing the data, etc., one or more, the preprocessing may depend on the actual situation, for example, it may be designed according to the format of the preset condition and / or the setting condition, etc.; then, assigning a sequence number corresponding to each preprocessed data to obtain an initialized data sequence group. By preprocessing the data, it is convenient to implement the subsequent process, so that the present application is easy to implement. For example, a group of data includes data from different data sources, and it is necessary to standardize the data from different data sources, that is, convert each data into a standard format or a preset format, so that each data has the same format as the preset condition, improve the readability of the data, and facilitate the judgment of the relationship between the two. For example, the preset condition is a condition set for the normalized data. If the preset threshold of the preset condition is set to a value in the range of [0, 1], the data can be normalized to within the range. On the one hand, it is convenient to judge the relationship between the data and the preset threshold, and on the other hand, it can reduce the amount of calculation and storage space.
[0065] S120, assigning an index corresponding to each data in the initialization data sequence group, where the index includes address information of each data.
[0066] As mentioned above, the initialization data sequence group includes multiple data assigned with serial numbers. In step S120, an index corresponding to each data is assigned according to the serial number corresponding to the data. The index represents the address information or position information of each data in the initialization data sequence group.
[0067] In some embodiments, a bit mask sequence may be used to encode the data in the initialization data sequence group, that is, the bit mask sequence is an index corresponding to each data in the initialization data sequence group.
[0068] In these embodiments, a bit mask sequence is used to perform a logical operation on the initialization data sequence group to encode each data in the initialization data sequence group and obtain an index corresponding to each data, which is very efficient.
[0069] As a non-limiting example, assume that a group of data to be stored includes 32 data, recorded as serise[0]serise[1]serise[2]serise[3]serise[4] ...serise
[30] serise
[31] . The initialization data sequence group includes 32 initialization data assigned with serial numbers, and the initialization data sequence group arranged in descending order is: {31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0}. Among them, the 32 numbers in {} represent the serial numbers corresponding to the initialization data, not the specific values of the initialization data themselves.
[0070] The bit mask sequence of the initialization data sequence group can be calculated using bitMask[i].
[0071] bitMask[i]=~((0×01<<(i))-1).
[0072] Among them, i represents the sequence number of the data in the initialization data sequence group, that is, the sequence number corresponding to the i+1th data; ~ represents the negation operation; << represents the left shift operator.
[0073] In the initialized data sequence group, the number i=0 corresponds to the sequence number of the first data serise[0], so the index corresponding to the data serise[0], that is, the bit mask is bitmask[0]=~((0×01<<(0))-1)=1111 1111 11111111 1111 1111 1111 1111, that is, the address corresponding to the first data serise[0] is 1111 11111111 1111 1111 1111 1111 1111; the second data is serise[1], and its corresponding index or address is bitmask[1]=1111 1111 1111 1111 1111 1111 1110; the third data is serise[2], and its corresponding index or address is bitmask[2]=1111 1111 1111 1111 1111 11111100;······; and so on. The index and address corresponding to the thirty-second data serise
[31] is bitmask
[31] =1000 0000 0000 0000 0000 0000 0000 0000.
[0074] It should be noted that the bit mask sequence can be designed according to the number of data in the initialization data sequence group. Preferably, if the initialization data sequence group includes N data, the number of bits in the bit mask is N, and the sequence number corresponds to the index. The sequence number design is determined according to the specific position of each data in a group of data to be stored. In this example, the sequence number is in descending order, and the index is also in descending order, that is, the last data is actually the first data in a group of data to be stored, then the index bitmask[0] corresponding to serise[0]=1111 1111 1111 1111 1111 1111 1111; if the sequence number is in ascending order, the index is also in ascending order, that is, the initialization data is actually the first input data, then the index bitmask[0] corresponding to serise[0]=10000000 0000 0000 0000 0000 0000 0000, and so on, without limitation here.
[0075] S130, determining data that meets preset conditions in the initialization data sequence group, and saving the data that meets the preset conditions in parallel using indexes corresponding to the data.
[0076] Among them, preset conditions in a standard format are pre-set, and the preset conditions are stored in a memory and can be called when needed. The preset conditions can be set by the system default or customized by the user. Different preset conditions can be set according to different actual conditions, and this application does not specifically limit the preset conditions. As a non-limiting example, the preset condition is greater than or equal to a preset threshold; as another non-limiting example, the preset condition is greater than a preset threshold, etc. The preset threshold can be an empirical value or can be customized by the user.
[0077] The preset condition is called to first determine the data in the initialized data sequence group that meets the preset condition, and then store each data that meets the preset condition according to the index.
[0078] As an implementation method, see Figure 2 As shown, step S130 includes steps S131 to S132.
[0079] S131, determining the relationship between each data in the initialization data sequence group and a preset threshold, and recording the comparison result of each data.
[0080] S132, acquiring data that meets the preset conditions according to the comparison result, and saving the data that meets the preset conditions in parallel using the index corresponding to the data.
[0081] In some embodiments, a compare (compare, cmp) instruction can be used to compare each data in the initialization data sequence group with a preset threshold, and the comparison result of each data with the preset threshold and the index corresponding to the data are recorded. Then, the target data that meets the preset conditions is determined according to the comparison result. The target data is the data in the initialization data sequence group that meets the preset conditions, such as data greater than or equal to the preset threshold, or data greater than the preset threshold. Finally, each target data is saved using its respective index.
[0082] It should be noted that, in some embodiments, if the sequence number of the initialized data sequence group is in descending order, the cmp instructions are shifted left one by one, and the comparison result of each data and the preset threshold is obtained and saved. In some other embodiments, if the sequence number of the initialized data sequence group is in ascending order, the cmp comparison instructions are shifted right one by one, and the comparison result of each data is obtained and saved. It should be understood that the present application is not limited to this.
[0083] In some embodiments, the indexes corresponding to the target data are read in parallel and the target data can be saved in parallel. At this time, the target data are stored in the same data stack or data queue in parallel, for example, according to the index, the target data and its corresponding index are stored in the stack or queue in parallel.
[0084] In some other embodiments, if the data stack storage space cannot meet the target data, multiple data stacks can be set, and then the target data can be saved in parallel using the indexes corresponding to the target data. In this case, each target data is stored in multiple data stacks, for example, according to the index, multiple target data and their corresponding indexes are stored in stacks or queues in parallel each time, that is, multiple target data and their indexes are stored in multiple stacks or queues each time until all the target data are stored in the stacks or queues.
[0085] As a non-limiting example, continuing with the example that the aforementioned initialization data sequence group includes 32 data, the index corresponding to the data can be obtained, and the number of bits that are 1 in the corresponding index can be statistically counted respectively, so that the corresponding address of the data in the initialization data sequence can be obtained in parallel, and by identifying the index and the address corresponding to the index, the data that meets the preset conditions can be directly saved in parallel, such as being pushed into a stack in parallel.
[0086] As another non-limiting example, see Figure 3 As shown, the initialization data sequence group includes eight data, namely: first data, second data, third data, ..., seventh data and eighth data, and the judgment results of the first data, second data, third data, ..., seventh data and eighth data and the preset conditions are respectively recorded as data0, data1, data2, data3, data4, data5, data6, data7, wherein data2, data3 and data6 respectively indicate that the third data, the fourth data and the seventh data meet the preset conditions, and data0, data1, data4, data5 and data7 respectively indicate that the first data, the second data, the fifth data, the sixth data and the eighth data do not meet the preset conditions. addr0, addr1, addr2, addr3, addr4, addr5, addr6 and addr7 represent the storage address of a data stack, wherein addr0 represents the bottom of the stack and addr7 represents the top of the stack. Therefore, after determining that the third data, the fourth data and the seventh data meet the preset conditions, the third data, the fourth data and the seventh data and their corresponding indexes are stored in parallel in the data stacks addr0, addr1 and addr2 according to the index, that is, according to the position relationship of the data.
[0087] The data storage method provided in this embodiment initializes the data to be stored into an initialization data sequence group, then determines whether each data in the initialization data sequence group meets a preset condition, and finally stores the data that meets the preset condition. This embodiment first uniformly determines whether each data meets the condition, and then stores the data that meets the condition. There is no need to determine whether the data meets the condition one by one. If the data meets the condition, it is stored, which can avoid interruption of the instruction pipeline and speed up data processing.
[0088] It should be noted that in some implementations, the same instruction cycle can operate on 32 data (or elements), and in other implementations, the same instruction cycle can operate on even more elements, thereby further improving the data processing speed.
[0089] Figure 4 FIG. 1 is a schematic diagram of an implementation flow of a data storage method provided by another embodiment of the present application, which further improves any of the aforementioned data storage methods. The data storage method in this embodiment can be executed by an electronic device. Figure 4 As shown, the data storage method may include steps S210 to S240. It should be understood that Figure 4 For the similarities between the method embodiment and the aforementioned method embodiment, please refer to the description of the aforementioned method embodiment, which will not be repeated here.
[0090] S210, acquiring data to be stored, initializing the data, and obtaining an initialized data sequence group.
[0091] S220, assigning an index corresponding to each data in the initialization data sequence group, where the index includes address information of each data.
[0092] S230, dividing the initialization data sequence group into a plurality of initialization data sequence subgroups.
[0093] S240, determining in parallel the data that meets the preset conditions in each of the initialization data sequence subgroups, and saving in parallel the data that meets the preset conditions using the index corresponding to the data.
[0094] In some embodiments, the initialization data sequence group can be further subdivided into multiple initialization data sequence subgroups, and for multiple initialization data sequence subgroups, the relationship between each data in each initialization data sequence subgroup and a preset threshold is determined in parallel, and then the comparison result of each data is obtained and saved. In these embodiments, multiple data sequence subgroups can be compared in parallel, which can further improve the data processing efficiency.
[0095] It should be noted that the initialization data sequence group can be divided into a plurality of initialization data sequence subgroups having the same amount of data, that is, the initialization data sequence group can be evenly divided into a plurality of initialization data sequence subgroups; or it can be divided into initialization data sequence subgroups having a preset number of data amounts, for example, 32 data as one group. This embodiment does not limit the number of initialization data sequence subgroups and the number of data included.
[0096] As a non-limiting example, the initialization data sequence group is further divided into three initialization data sequence subgroups, and three cmp instructions are used to obtain comparison results between the data in the three initialization data sequence subgroups and preset thresholds, and then data that meets the preset conditions is saved based on the comparison results.
[0097] The data storage method provided by an embodiment of the present application is described below through a specific application scenario. This application scenario is a processing scenario of image data. It should be understood that this application scenario cannot be interpreted as a limitation on the present application.
[0098] Figure 5 FIG. 1 is a schematic diagram of an implementation flow of a data storage method provided by an embodiment of the present application. The data storage method in this embodiment is used for storing image data. Figure 5 As shown, the data storage method includes steps S310 to S340.
[0099] S310, acquiring a target image, and initializing the target image to obtain an initialization pixel value sequence group.
[0100] In this embodiment, the electronic device captures the target image through its own camera device, obtains pixel values in the target image, assigns a corresponding serial number to each pixel value, and obtains an initialized pixel value sequence group.
[0101] It should be noted that initializing the target image may also include preprocessing the pixel values, and the preprocessing method may be designed according to the format of the preset threshold. The preprocessing method may include but is not limited to normalization, standardization or unitization, so as to compare the initialized pixel value with the preset threshold.
[0102] As a non-limiting example, if the preset threshold is set to a value in the range of [0, 1], the pixel values may be normalized to be within the range for comparison to reduce the amount of calculation and storage space.
[0103] It should be noted that the target image can be a depth image, a color image, a black and white image or a grayscale image, etc. The corresponding pixel values are depth values, color values, black and white values and grayscale values. This application does not limit the type of target image.
[0104] As a non-limiting example, the target image is taken as a depth image for illustration.
[0105] In some embodiments, the electronic device itself collects the depth image. In these embodiments, the electronic device itself includes a projection module, a collection module and a depth calculation module. The projection module is used to project an infrared beam to the target area, the collection module is used to collect the electrical signal formed by the infrared beam reflected back from the target area, and the depth calculation module is used to form a depth image according to the electrical signal.
[0106] In some other embodiments, the electronic device obtains the depth image from other devices. In these embodiments, the other devices include a projection module, a collection module and a depth calculation module.
[0107] Specifically, the depth image may be acquired in any of the following three ways.
[0108] Method ①: The projection module projects a structured light beam to the target area, and the acquisition module receives the beam reflected by the target area and forms an electrical signal. The electrical signal is transmitted to the depth calculation module, which processes the electrical signal and calculates the intensity information reflecting the beam to form a structured light pattern. Finally, matching calculation or triangulation calculation is performed based on the structured light pattern to obtain the depth values of multiple pixels to obtain the depth image of the target area.
[0109] Method ②: The projection module projects an infrared beam to the target area, and the acquisition module receives the beam reflected back from the target area and forms an electrical signal. The electrical signal is transmitted to the depth calculation module, which processes the electrical signal to calculate the phase difference, and based on the phase difference indirectly calculates the flight time taken for the beam to be emitted from the projection module to be received by the acquisition module, and further calculates the depth values of multiple pixels based on the flight time to obtain a depth image of the target area. It should be understood that the infrared beam may include pulse type and continuous wave type, which is not limited here.
[0110] Method ③: The projection module projects an infrared pulse beam to the target object, and the acquisition module receives the beam reflected by the target object and forms an electrical signal. The electrical signal is transmitted to the depth calculation module, which counts the electrical signal to obtain a waveform histogram, and directly calculates the flight time from the projection module to the acquisition module based on the histogram, and further calculates the depth values of multiple pixels based on the flight time to obtain a depth image of the target area.
[0111] S320, assigning an index corresponding to each pixel value in the initialization pixel value sequence group, where the index includes the position of each pixel value in the target image.
[0112] In this embodiment, an index corresponding to each pixel value is assigned according to the sequence number of the pixel value in step S310, and the index includes the position information of the pixel value in the target image, that is, the pixel position information.
[0113] In some implementations, the corresponding index can be designed according to the number of pixels in the target image. If the target image includes N pixels, the serial numbers of the N pixels in the target image are {0, 1, 2, 3, 4, ······, N-1}. The index corresponding to each pixel value is assigned using a bit mask sequence. The index corresponding to the pixel value with serial number 0 is bitmask[0]=1000···0000, the number of bits being 0 is N-1, and the number of bits being 1 is 1; the index corresponding to the pixel value with serial number 1 is bitmask[1]=1100···0000, the number of bits being 0 is N-2, and the number of bits being 1 is 2; ······; the index corresponding to the pixel value with serial number N-1 is bitmask[N-1]=1111···1111, the number of bits being 0 is 0, and the number of bits being 1 is N, and so on.
[0114] S330, determining the relationship between each pixel value of the pixel value sequence group and a preset threshold, and recording the comparison result of each pixel value.
[0115] In this embodiment, a threshold value may be preset according to a specific application of the target image, and each pixel value in the target image may be compared with the preset threshold value using a cmp instruction, and the comparison result of each pixel value and its corresponding index may be recorded.
[0116] In some implementations, since the serial numbers corresponding to the pixel values in the target image are in ascending order, the cmp instructions are shifted right one by one to obtain and save the comparison result of each pixel value. This embodiment does not limit this sorting, and the serial numbers corresponding to the pixel values in the target image can be in descending order, in which case the cmp instructions need to be shifted left one by one.
[0117] In some other embodiments, further, after step S320, a step of further subdividing the initialization pixel value sequence group into a plurality of pixel groups may be added. Specifically, the pixel values in the initialization pixel value sequence group are further subdivided into a plurality of initialization pixel value sequence subgroups, and the relationship between each pixel value and a preset threshold value in each initialization pixel value sequence subgroup is determined in parallel, and then the comparison result of each pixel value is obtained and saved. These embodiments can further improve data processing efficiency.
[0118] S340, using the comparison result to obtain pixel values that meet the preset conditions, and saving the pixel values that meet the preset conditions in parallel according to the corresponding indexes.
[0119] In this embodiment, pixel values that meet preset conditions, such as pixel values that are greater than or equal to a preset threshold, can be obtained based on the comparison results. According to the pixel values and the corresponding indexes, the number of bits that are 1 in the index corresponding to each pixel value is counted respectively, so that the corresponding position information of the pixel value in the initialized pixel value sequence group can be obtained. By identifying the index and the position information corresponding to the index, the pixel values that meet the preset threshold can be directly saved in parallel, such as being pushed into a stack or a queue.
[0120] The image data storage method provided in this embodiment can avoid interruption of the judgment instruction pipeline, thereby improving the processing efficiency of image data. In addition, in some implementations, data parallel storage can be achieved, and / or the same instruction cycle can operate 32 elements or more, etc., which can further speed up the processing speed of the target image and thus improve the output frame rate of the image.
[0121] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0122] An embodiment of the present application also provides a data storage device. For details not described in detail in the data storage device, please refer to the description in the above method embodiment.
[0123] See also Figure 6 , Figure 6 6 is a schematic block diagram of a data storage device provided by an embodiment of the present application. The data storage device comprises: an initialization module 61 , an index assignment module 62 and a storage module 63 .
[0124] The initialization module 61 is used to obtain data to be stored, and initialize the data to be stored to obtain an initialization data sequence group;
[0125] An index assigning module 62, used to assign an index corresponding to each data in the initialization data sequence group, where the index includes address information of each data;
[0126] The saving module 63 is used to determine the data that meets the preset conditions in the initialization data sequence group, and save the data that meets the preset conditions using the index corresponding to the data.
[0127] Optionally, as an implementation method, Figure 7 As shown, the saving module 63 includes a judging submodule 6331 and a saving submodule 632 .
[0128] The judgment submodule 6331 is used to judge the relationship between each data in the initialization data sequence group and a preset threshold value, and record the comparison result of each data.
[0129] The saving submodule 632 is used to obtain data that meets the preset conditions according to the comparison result, and save the data that meets the preset conditions using the index corresponding to the data.
[0130] Optionally, as an implementation, the judgment submodule 6331 is specifically used to:
[0131] Each data in the initialization data sequence group is compared with a preset threshold value using a comparison instruction.
[0132] Optionally, as an implementation, the initialization module 61 is specifically used to:
[0133] Assigning a sequence number corresponding to each data in the data to be stored to obtain an initialization data sequence group; or
[0134] Preprocess each data in the data to be stored, assign a corresponding sequence number to each preprocessed data, and obtain an initialized data sequence group.
[0135] Optionally, as an implementation manner, the serial numbers are sorted in ascending or descending order.
[0136] Optionally, as an implementation, the index assigning module 62 is specifically configured to:
[0137] The bit mask sequence is used to encode the sequence number of each data in the initialization data sequence group to obtain the index corresponding to each data.
[0138] Based on the data storage device provided in any of the above embodiments, an embodiment of the present application provides a data storage device. Figure 8 As shown. Figure 8 As shown, the data storage device includes: an initialization module 61, an index assignment module 62, a division module 64 and a storage module 63.
[0139] The initialization module 61 is used to obtain data to be stored, and initialize the data to be stored to obtain an initialization data sequence group;
[0140] An index assigning module 62, used to assign an index corresponding to each data in the initialization data sequence group, where the index includes address information of each data;
[0141] A division module 64, configured to divide the initialization data sequence group into a plurality of initialization data sequence subgroups;
[0142] The saving module 63 is used to determine in parallel the data that meets the preset conditions in each initialization data sequence subgroup, and save the data that meets the preset conditions using the index corresponding to the data.
[0143] This embodiment determines the data meeting the preset conditions in each initialization data sequence group in parallel, thereby further improving the data processing efficiency.
[0144] An embodiment of the present application also provides an electronic device, such as Fig. 9 As shown, the electronic device may include one or more processors 90 ( Fig. 9 Only one is shown in the figure), a memory 91 and a computer program 92 stored in the memory 91 and executable on one or more processors 90, for example, a data storage program. When one or more processors 90 execute the computer program 92, the various steps in the data storage method embodiment can be implemented. Alternatively, when one or more processors 90 execute the computer program 92, the functions of the various modules / units in the data storage device embodiment can be implemented, which is not limited here.
[0145] Those skilled in the art will understand that Fig. 9 The electronic device is merely an example of an electronic device and does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0146] In one embodiment, the processor 90 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0147] In one embodiment, the memory 91 may be an internal storage unit of an electronic device, such as a hard disk or memory of the electronic device. The memory 91 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 card, etc. equipped on the electronic device. Further, the memory 91 may also include both an internal storage unit of the electronic device and an external storage device. The memory 91 is used to store computer programs and other programs and data required by the electronic device. The memory 91 may also be used to temporarily store data that has been output or is to be output.
[0148] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0149] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the embodiment of the data storage method can be implemented.
[0150] An embodiment of the present application provides a computer program product. When the computer program product is executed on an electronic device, the electronic device can implement the steps in the data storage method embodiment.
[0151] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0152] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0153] In the embodiments provided by the present invention, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0154] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0155] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0156] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and the computer program that can be completed by instructing the relevant hardware through a computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0157] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. A data storage method, characterized in that: include: Acquiring data to be stored, and initializing the data to be stored to obtain an initialization data sequence group; including: Assigning a sequence number corresponding to each data in the data to be stored to obtain an initialization data sequence group; or Preprocessing each data in the data to be stored, assigning a sequence number corresponding to each preprocessed data, and obtaining an initialized data sequence group; Assigning an index corresponding to each data in the initialization data sequence group, where the index includes address information of each data; Dividing the initialization data sequence group into a plurality of initialization data sequence subgroups; Determining in parallel the data that meets the preset conditions in each of the initialization data sequence subgroups, and saving in parallel the data that meets the preset conditions using the index corresponding to the data; comprising: Determine the relationship between each data in the initialization data sequence group and a preset threshold, and record the comparison result of each data; According to the comparison result, data meeting the preset condition is obtained, and the data meeting the preset condition is saved in parallel using the index corresponding to the data.
2. The data storage method according to claim 1, characterized in that: The determining the relationship between each data in the initialization data sequence group and a preset threshold value includes: Each data in the initialization data sequence group is compared with a preset threshold value using a comparison instruction.
3. The data storage method according to claim 1, characterized in that: The serial numbers are sorted in ascending or descending order.
4. The data storage method according to claim 1, characterized in that: The index corresponding to each data in the initialization data sequence group is assigned, and the index contains address information of each data, including: The bit mask sequence is used to encode the sequence number of each data in the initialization data sequence group to obtain the index corresponding to each data.
5. A data storage device, characterized in that: include: An initialization module, used to obtain data to be stored, initialize the data to be stored to obtain an initialization data sequence group; including: Assigning a sequence number corresponding to each data in the data to be stored to obtain an initialization data sequence group; or Preprocessing each data in the data to be stored, assigning a sequence number corresponding to each preprocessed data, and obtaining an initialized data sequence group; An index assigning module, used to assign an index corresponding to each data in the initialization data sequence group, the index including address information of each data; and divide the initialization data sequence group into a plurality of initialization data sequence subgroups; A saving module, used to determine in parallel the data that meets the preset conditions in each of the initialization data sequence subgroups, and save in parallel the data that meets the preset conditions using the index corresponding to the data; comprising: Determine the relationship between each data in the initialization data sequence group and a preset threshold, and record the comparison result of each data; According to the comparison result, data meeting the preset condition is obtained, and the data meeting the preset condition is saved in parallel using the index corresponding to the data.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the data storage method according to any one of claims 1 to 4 are implemented.
7. A computer storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the data storage method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Picture searching method and device, storage medium and electronic device
CN112115292A