CN113535117A - Data storage method and device and electronic equipment - Google Patents

Data storage method and device and electronic equipment Download PDF

Info

Publication number
CN113535117A
CN113535117A CN202110682250.8A CN202110682250A CN113535117A CN 113535117 A CN113535117 A CN 113535117A CN 202110682250 A CN202110682250 A CN 202110682250A CN 113535117 A CN113535117 A CN 113535117A
Authority
CN
China
Prior art keywords
data
initialization
sequence group
stored
meeting
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110682250.8A
Other languages
Chinese (zh)
Inventor
余洪涛
谷涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Orbbec Inc
Original Assignee
Orbbec Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Orbbec Inc filed Critical Orbbec Inc
Priority to CN202110682250.8A priority Critical patent/CN113535117A/en
Publication of CN113535117A publication Critical patent/CN113535117A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F5/00Methods or arrangements for data conversion without changing the order or content of the data handled
    • G06F5/06Methods or arrangements for data conversion without changing the order or content of the data handled for changing the speed of data flow, i.e. speed regularising or timing, e.g. delay lines, FIFO buffers; over- or underrun control therefor
    • G06F5/08Methods or arrangements for data conversion without changing the order or content of the data handled for changing the speed of data flow, i.e. speed regularising or timing, e.g. delay lines, FIFO buffers; over- or underrun control therefor having a sequence of storage locations, the intermediate ones not being accessible for either enqueue or dequeue operations, e.g. using a shift register
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3867Concurrent instruction execution, e.g. pipeline or look ahead using instruction pipelines

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Image Processing (AREA)

Abstract

The application is applicable to the technical field of data processing, and particularly relates to a data storage method, a data storage device and electronic equipment, wherein the method comprises the following steps: acquiring data to be stored, and initializing the data to be stored to obtain an initialized data sequence group; giving an index corresponding to each data in the initialization data sequence group, wherein the index comprises address information of each data; and determining data meeting preset conditions in the initialization data sequence group, and storing the data meeting the preset conditions in parallel by using indexes corresponding to the data. The embodiment of the application can improve the data processing efficiency.

Description

Data storage method and device and electronic equipment
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a data storage method and apparatus, and an electronic device.
Background
And data processing, namely data acquisition, storage, retrieval, processing, transformation and transmission. Three common types of data storage include: a stack, a queue, and a priority queue.
In the related data calculation processing, it is generally necessary to determine data, and store the data satisfying the condition by determining whether the data satisfies the condition, for example, by pushing the data onto a stack, and discard the data not satisfying the condition. In general, a method of judging whether conditions are met or not and then storing the conditions one by one is directly adopted, element operation can only be carried out one by one, and the hardware platform is interrupted due to the fact that the conditions are judged and stored firstly every time, the performance of a processor is greatly limited, and the performance of an algorithm is poor.
Disclosure of Invention
In view of this, embodiments of the present application provide a data storage method and apparatus, and an electronic device, which can improve data processing efficiency.
In a first aspect, an embodiment of the present application provides a data storage method, including:
acquiring data to be stored, and initializing the data to be stored to obtain an initialized data sequence group;
giving an index corresponding to each data in the initialization data sequence group, wherein the index comprises address information of each data;
and determining data meeting preset conditions in the initialization data sequence group, and storing the data meeting the preset conditions in parallel by using indexes corresponding to the data.
The data storage method provided by the embodiment can avoid the interruption of the instruction pipeline caused by judging data (or elements) one by one in each step, and can improve the data processing speed.
As an implementation manner of the first aspect, the determining data meeting a preset condition in the initialization data sequence group, and storing the data meeting the preset condition in parallel by using an index corresponding to the data includes:
judging the relation between each data in the initialization data sequence group and a preset threshold value, and recording the comparison result of each data;
and acquiring data meeting preset conditions according to the comparison result, and storing the data meeting the preset conditions in parallel by using indexes corresponding to the data.
According to the implementation mode, the relation between each data in the initialized data sequence group and the preset threshold is judged first, and then the data meeting the preset conditions are determined, so that the method is simple, convenient and quick, and easy to implement.
As an implementation manner of the first aspect, the determining a relationship between each data in the initialization data sequence group and a preset threshold includes:
and comparing each data in the initialization data sequence group with a preset threshold value by using a comparison instruction.
The implementation mode is realized by comparing the instructions, and a new code does not need to be developed, so that the implementation mode is easy to implement.
As an implementation manner of the first aspect, the initializing the data to be stored to obtain an initialized data sequence group includes:
giving a serial number corresponding to each data in the data to be stored to obtain an initialized data sequence group; or
And preprocessing each data in the data to be stored, giving a serial number corresponding to each preprocessed data, and obtaining an initialized data sequence group.
The implementation mode initializes the data to be stored, improves the readability of the data and is convenient for subsequently judging whether the data meets the preset conditions.
As an implementation manner of the first aspect, the sequence numbers are sorted in an ascending order or a descending order.
In the implementation mode, the sequence numbers are sorted in an ascending order or a descending order, and the data processing accuracy is ensured by using the address or position information of the data in a simple mode.
As an implementation manner 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:
and coding the serial number of each data in the initialization data sequence group by adopting the bit mask sequence to obtain an index corresponding to each data.
The realization mode adopts the bit mask sequence to realize coding, does not need to develop new codes, and is easy to implement.
As an implementation manner of the first aspect, after the assigning an index corresponding to each data in the initialization data sequence group, the index including address information of each data, the method further includes:
dividing the initialization data sequence group into a plurality of initialization data sequence subgroups;
the determining the data meeting the preset condition in the initialization data sequence group and storing the data meeting the preset condition in parallel by using the index corresponding to the data includes:
and determining the data meeting the preset conditions in each initialization data sequence subgroup in parallel, and storing the data meeting the preset conditions in parallel by using the indexes corresponding to the data.
According to the implementation mode, the data which meet the preset conditions in each initialization data sequence group is determined in parallel, and the data processing efficiency is further improved.
In a second aspect, an embodiment of the present application provides a data storage device, including:
the device comprises an initialization module, a data storage module and a data processing module, wherein the initialization module is used for acquiring data to be stored and initializing the data to be stored to acquire an initialization data sequence group;
the index giving module is used for giving an index corresponding to each data in the initialization data sequence group, and the index comprises address information of each data;
and the storage module is used for determining the data meeting the preset conditions in the initialization data sequence group and storing the data meeting the preset conditions in parallel by using the indexes corresponding to the data.
In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the data storage method according to the first aspect or any implementation manner of the first aspect when executing the computer program.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored, and the computer program, when executed by a processor, implements the data storage method according to the first aspect or any implementation manner of the first aspect.
In a fifth aspect, an embodiment of the present application provides a computer program product, which, when run on an electronic device, causes the electronic device to execute the data storage method according to the first aspect or any implementation manner of the first aspect.
It can be understood that, for the beneficial effects of the second aspect to the fifth aspect, reference may be made to the description of the first aspect and any implementation manner of the first aspect, and details are not described herein again.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic flow chart illustrating an implementation of a data storage method according to an embodiment of the present application;
fig. 2 is a schematic flowchart illustrating a specific implementation of step S130 in a data storage method according to an embodiment of the present application;
FIG. 3 is a diagram illustrating a parallel stacking of data according to an embodiment of the present application;
FIG. 4 is a schematic flow chart illustrating an implementation of another data storage method according to an embodiment of the present application;
FIG. 5 is a schematic flow chart illustrating an implementation of another data storage method according to an embodiment of the present application;
FIG. 6 is a schematic structural diagram of a data storage device according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a storage module in a data storage device according to an embodiment of the present application
FIG. 8 is a schematic structural diagram of another data storage device according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
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.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
Further, in the description of the present application, "a plurality" means two or more. The terms "first," "second," "third," and "fourth," etc. are used merely to distinguish one description from another, and are not to be construed as indicating or implying relative importance.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
At present, in data storage, such as data stacking and the like, a method of judging whether a condition is met and then saving data is generally adopted one by one, the method can only operate one by one data, and whether the condition is met or not needs to be judged in each step, which can cause the pipeline of a hardware platform to be interrupted, thereby greatly limiting the performance of a processor and causing the performance of an algorithm to be poor.
Especially, in the image processing or filtering process, whether the pixel value meets the condition needs to be judged, if a mode of judging each pixel one by one is adopted, a pipeline of a hardware platform is interrupted, so that the calculation speed of the image processing process is greatly limited, and the output frame rate of the image is reduced.
In order to solve at least one of the above technical problems, embodiments of the present application provide a data storage method, which can avoid an instruction pipeline being interrupted due to that each step is judged one by data (or element), and can improve a data processing speed.
Fig. 1 is a schematic flow chart of an implementation process of a data storage method according to an embodiment of the present application, where the data storage method in this embodiment can be executed by an electronic device. Electronic devices include, but are not limited to, computers, tablets, servers, cell phones, cameras, wearable devices, or the like. The server includes but is not limited to a stand-alone server or a cloud server, etc. The data storage method in the embodiment is suitable for the situation that data needs to be stored. As shown in fig. 1, the data storage method may include steps S110 to S140.
And S110, acquiring the data to be stored, initializing the data to be stored and acquiring an initialized data sequence group.
The data to be stored is a group of data to be stored. Initializing the data to be stored to obtain an initialized data sequence group.
In some embodiments, the electronic device may itself collect the data to be stored. In these embodiments, the data to be stored may be acquired by the electronic device through its own hardware, for example, by a sensor or a camera of the electronic device. The image capturing devices include, but are not limited to: a camera or a camera module, etc.
In other embodiments, the electronic device may retrieve data to be stored from other devices that are independent of the device of the electronic device. The electronic device can actively acquire the data to be stored from other devices, and can also actively transmit the data to be stored to the electronic device by other devices. Other devices include, but are not limited to, video cameras, cell phones, or tablet computers, among other electronic devices.
In some embodiments, initializing the data includes assigning a corresponding sequence number to each data (or element), and obtaining an initialized data sequence group.
As an implementation manner of these embodiments, a sequence number corresponding to each data is assigned according to the arrangement order of the data, and an initialized data sequence group is obtained. As a non-limiting example, the set of data to be stored includes 32 data arranged in sequence, and the initialized data sequence set may 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}, the initialized set of data sequences comprises 32 data. This example illustrates the data with a sequence number, rather than the data itself. This example is numbering data in ascending order. In reality, the initialized data sequence group includes a sequence data to which a sequence number is assigned. In other examples, the sequence numbers may not start with 0, but instead may start with 1 or any positive integer. In some other examples, the initialization data sequence group may be numbered in a descending order, for example, a group of data to be stored includes 32 data, and the initialization data sequence group may be exemplified 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}.
In some other embodiments, initializing the acquired data may include: first, each data is preprocessed, including but not limited to: the data is subjected to one or more of normalization, standardization, unitization and the like, and the preprocessing can be determined according to the actual situation, and for example, the preprocessing can be designed according to the format of preset conditions and/or setting conditions and the like; and then, giving a corresponding serial number to each preprocessed data to obtain an initialized data sequence group. By preprocessing the data, the implementation of the subsequent process is facilitated, and the method and the device are easy to implement. For example, a set of data includes data from different data sources, and the data from the different data sources needs to be standardized, that is, each data is converted into a standard format or a preset format, so that each data has the same format as a preset condition, and readability of the data is improved, so as to determine a relationship between the two. For another example, the preset condition is a condition set for the normalized data, and if the preset threshold of the preset condition is set to a certain numerical value in the range of [0, 1], the data may be normalized to the range, on one hand, the relationship between the data and the preset threshold is convenient to judge, and on the other hand, the calculation amount and the storage space may be reduced.
And S120, giving an index corresponding to each data in the initialization data sequence group, wherein the index comprises the address information of each data.
As described above, the initialization data sequence group includes a plurality of data assigned with sequence numbers, and in step S120, an index corresponding to each data is assigned to the data according to the sequence number corresponding to the data, and the index indicates address information or position information of each data in the initialization data sequence group.
In some embodiments, the data in the initialization data sequence group may be encoded with a bit mask sequence, i.e., a bit mask sequence is an index corresponding to each data in the initialization data sequence group.
In the embodiments, the 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, so as to obtain an index corresponding to each data, which is very efficient.
As a non-limiting example, assume that the set of data to be stored includes 32 data, denoted as series [0] series [1] series [2] series [3] series [4] … … series [30] series [31 ]. The initialization data sequence group comprises 32 initialization data with serial numbers, and the initialization data sequence group adopting descending order arrangement comprises the following components: {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}. Wherein, 32 numbers in { } indicate the sequence number corresponding to the initialization data, and are not specific values of the initialization data itself.
The bit mask sequence for calculating the initialization data sequence group may adopt a bit mask i.
bitMask[i]=~((0×01<<(i))-1)。
Wherein, i represents the serial number of the data in the initialized data sequence group, namely the serial number corresponding to the (i + 1) th data; -representing an inversion operation; < < denotes the left shift operator.
In the initialized data sequence group, the number i ═ 0 corresponds to the sequence number of the first data series [0], and then the index corresponding to the data series [0], that is, the bit mask is bit mask [0] - ((0 × 01< (0)) -1) - (-11111111111111111111111111111111), that is, the address corresponding to the first data series [0] is 11111111111111111111111111111111; the second data is series [1], and its corresponding index or address is bitmask [1] ═ 11111111111111111111111111111111110; the third data is series [2], and its corresponding index or address is bitmask [2] ═ 11111111111111111111111111111100; h.. cndot.. cndot. cndot.; and so on, the index and address corresponding to the thirty-second data series [31] is bitmask [31] ═ 10000000000000000000000000000000.
The bit mask sequence may 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 of the bit mask is N, the sequence number corresponds to the index, and 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, if the sequence number is in a descending order, the index is also in a descending order, that is, the last data is actually the first data in a group of data to be stored, and the index bitmask [0] corresponding to the series [0] is 11111111111111111111111111111111; if the sequence number is in ascending order and the index is also in ascending order, that is, the initial data is actually the first bit of the input data, the index bitmask [0] corresponding to the series [0] is 10000000000000000000000000000000, and so on, and this is not limited here.
And S130, determining the data meeting the preset conditions in the initialization data sequence group, and storing the data meeting the preset conditions in parallel by using the indexes corresponding to the data.
The method comprises the steps of presetting a preset condition of a standard format, storing the preset condition in a memory, and calling when the preset condition is needed. The preset condition can be set by default of the system or can be customized by a user. Different preset conditions can be set according to different actual conditions, and the preset conditions are not particularly limited in the application. 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, and the like. The preset threshold value can be an empirical value or can be set by a user in a self-defined way.
And calling a preset condition, determining data meeting the preset condition in the initialized data sequence group, and storing each data meeting the preset condition according to the index.
As an implementation, referring to fig. 2, step S130 includes steps S131 to S132.
S131, judging the relation between each data in the initialization data sequence group and a preset threshold value, and recording the comparison result of each data.
And S132, acquiring data meeting the preset conditions according to the comparison result, and storing the data meeting the preset conditions in parallel by using the indexes corresponding to the data.
In some embodiments, each data in the initialization data sequence group may be compared with a preset threshold by using a compare (cmp) instruction, and the comparison result of each data with the preset threshold and the index corresponding to the data may be recorded. Then, target data meeting a preset condition is determined according to the comparison result, where the target data is data meeting the preset condition in the initialization data sequence group, for example, data greater than or equal to a preset threshold, or data greater than the preset threshold. And finally, storing each target data by using the respective index of the target data.
It should be noted that, in some embodiments, if the sequence numbers of the initialized data sequence group are in a descending order, the cmp instructions are shifted left one by one, and the comparison result between each piece of data and the preset threshold is obtained and stored. In other embodiments, the sequence numbers of the initialized data sequence group are in ascending order, the cmp comparison instructions are shifted to the right one by one, and the comparison result of each data is obtained and stored. It is to be understood that the present application is not limited thereto.
In some embodiments, the respective indexes of the target data are read in parallel, and the respective target data can be stored in parallel. At this time, each target data is stored in parallel in the same data stack or data queue, for example, each target data and its corresponding index are stored in parallel in the stack or queue according to the index.
In other embodiments, if the data stack storage space cannot satisfy the target data, multiple data stacks may be set, and each target data is stored in parallel by using the index corresponding to each target data. At this time, each target data is stored in a plurality of data stacks, for example, according to the index, a plurality of target data and the corresponding index thereof are stored in a stack or a queue in parallel each time, that is, a plurality of target data and the corresponding index thereof are stored in a plurality of stacks or queues each time until all the target data are stored in the stack or the queue.
As a non-limiting example, in the example that the initialization data sequence group includes 32 data, the indexes corresponding to the data may be obtained, and the number of bits in the indexes corresponding to the data is counted to be 1, that is, the corresponding addresses of the data in the initialization data sequence may be obtained in parallel, and the data meeting the preset condition may be directly stored in parallel by identifying the indexes and the addresses corresponding to the indexes, for example, the data is stacked in parallel.
As another non-limiting example, referring to fig. 3, the initialization data sequence set includes eight data, respectively: the judgment results of the first data, the second data, the third data, the … …, the seventh data and the eighth data and the preset conditions are sequentially recorded as data0, data1, data2, data3, data4, data5, data6 and data7, wherein the data2, data3 and data6 sequentially indicate that the third data, the fourth data and the seventh data meet the preset conditions, and the data0, the data1, the data4, the data5 and the 596data 2 sequentially 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 one data stack, where addr0 represents the bottom of the stack and addr7 represents the top of the stack. Therefore, after the third data, the fourth data and the seventh data are determined to meet the preset condition, the third data, the fourth data and the seventh data and the corresponding indexes thereof are stored in the data stacks addr0, addr1 and addr2 in parallel according to the indexes, that is, according to the position relationship of the data.
The data storage method provided by this embodiment initializes data to be stored into an initialized data sequence group, then judges whether each data in the initialized data sequence group meets a preset condition, and finally stores the data meeting the preset condition.
It should be noted that in some implementations, 32 data (or elements) can be operated by the same instruction cycle, and in other implementations, even more elements can be operated by the same instruction cycle, thereby further increasing the data processing speed.
Fig. 4 is a schematic flow chart of an implementation of a data storage method according to another embodiment of the present application, which further improves any of the foregoing data storage methods. The data storage method in the present embodiment may be executed by an electronic device. As shown in fig. 4, the data storage method may include steps S210 to S240. It should be understood that the method embodiment of fig. 4 is the same as the method embodiment described above, and the detailed description thereof is omitted here.
S210, obtaining data to be stored, initializing the data, and obtaining an initialized data sequence group.
And S220, giving an index corresponding to each data in the initialization data sequence group, wherein the index comprises the address information of each data.
And S230, dividing the initialization data sequence group into a plurality of initialization data sequence subgroups.
S240, determining the data meeting the preset conditions in each initialization data sequence subgroup in parallel, and storing the data meeting the preset conditions in parallel by using the indexes corresponding to the data.
In some embodiments, the initialization data sequence group may be further subdivided into a plurality of initialization data sequence subgroups, and for the plurality of initialization data sequence subgroups, a relationship between each data in each initialization data sequence subgroup and a preset threshold is determined in parallel, so as to obtain and store a comparison result of each data. In these embodiments, multiple data sequence subgroups can be compared in parallel, which can further improve the data processing efficiency.
It should be noted that the initialization data sequence group may be divided into a plurality of initialization data sequence subgroups with the same data amount, that is, the initialization data sequence group is divided into a plurality of initialization data sequence subgroups; it is also possible to divide the initialization data sequence into subsets with a predetermined number of data amounts, for example, a set of 32 data. The number of the initialization data sequence subgroups and the number of the included data are not limited in this embodiment.
As a non-limiting example, the initialization data sequence group is further divided into 3 initialization data sequence subgroups, the comparison result between the data in the 3 initialization data sequence subgroups and the preset threshold is obtained by using 3 cmp instructions, and then the data meeting the preset condition is saved according to the comparison result.
The following describes a data storage method provided by an embodiment of the present application through a specific application scenario. The application scene is a processing scene of image data. It should be understood that this application is not to be construed as limiting this application.
Fig. 5 is a schematic implementation flow diagram of a data storage method according to an embodiment of the present application, where the data storage method in this embodiment is used for storing image data. As shown in fig. 5, the data storage method includes steps S310 to S340.
S310, acquiring a target image, and initializing the target image to obtain an initialized pixel value sequence group.
In this embodiment, the electronic device captures a target image through its own imaging device, obtains pixel values in the target image, and assigns a sequence number corresponding to each pixel value to obtain an initialized pixel value sequence group.
It should be noted that initializing the target image may further include preprocessing the pixel values, and the preprocessing method may be designed according to a format of a preset threshold. The preprocessing method may include, but is not limited to, normalization, or unitization, etc. in order to compare the initialized pixel values with a preset threshold.
As a non-limiting example, if the predetermined threshold is set to a value within the range of [0, 1], the pixel values may be normalized to the range for comparison, so as to reduce the amount of calculation and the storage space.
It should be noted that the target image may be a depth image, a color image, a black-and-white image, or a grayscale image, and the corresponding pixel values are depth values, color values, black-and-white values, and grayscale values, and the application does not limit the type of the target image.
As a non-limiting example, the target image is taken as a depth image for illustration.
In some embodiments, the electronic device itself captures the depth image. In these embodiments, the electronic device itself includes a projection module, an acquisition module, and a depth calculation module. The projection module is used for projecting infrared beams to the target area, the acquisition module is used for acquiring electric signals formed by the infrared beams reflected back by the target area, and the depth calculation module is used for forming a depth image according to the electric signals.
In other embodiments, the electronic device acquires the depth image from another device. In these embodiments, the other devices include a projection module, an acquisition module, and a depth calculation module.
Specifically, the manner of acquiring the depth image may include any one of the following three manners.
The method comprises the following steps: the projection module projects a structured light beam to the target area, and the collection module receives the light beam reflected back by the target area and forms an electric signal. The electric signal is transmitted to a depth calculation module, the depth calculation module processes the electric signal, intensity information reflecting the light beam is calculated to form a structured light pattern, and finally matching calculation or trigonometric calculation is carried out based on the structured light pattern to obtain depth values of a plurality of pixel points so as to obtain a depth image of the target area.
The method II comprises the following steps: the projection module projects infrared beams to the target area, and the collection module receives the beams reflected by the target area and forms electric signals. The electric signal is transmitted to the depth calculation module, the depth calculation module processes the electric signal to calculate a phase difference, the flight time for the light beam to be transmitted from the projection module to the collection module to be received is indirectly calculated based on the phase difference, and the depth values of the plurality of pixel points are further calculated based on the flight time to obtain the depth image of the target area. It should be understood that the infrared beam may include pulsed and continuous wave types, and is not limited herein.
The mode III is as follows: the projection module projects infrared pulse beams to a target object, and the collection module receives the beams reflected by the target object and forms electric signals. The electric signals are transmitted to a depth calculation module, the depth calculation module counts the electric signals to obtain a waveform histogram, the flight time used for transmitting the electric signals to an acquisition module by a projection module is directly calculated according to the histogram, and the depth values of a plurality of pixel points are further calculated based on the flight time to obtain a depth image of a target area.
And S320, giving an index corresponding to each pixel value in the initialization pixel value sequence group, wherein the index comprises the position of each pixel value in the target image.
In this embodiment, according to the sequence number of the pixel value in step S310, an index corresponding to each pixel value is assigned, and the index includes the position information of the pixel value in the target image, i.e., the pixel position information.
In some implementations, the corresponding index can be designed according to the number of pixels in the target image. If the target image comprises N pixels, the sequence numbers of the N pixels in the target image are {0,1,2,3,4 }, N-1} in sequence. Giving an index corresponding to each pixel value by using a bit mask sequence, wherein the index corresponding to the pixel value with the sequence number of 0 is bit mask [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 the sequence number 1 is bitmap [1] ═ 1100 · 0000, the number of bits 0 is N-2, and the number of bits 1 is 2; h.. cndot.. cndot. cndot.; the index corresponding to the pixel value with the sequence number N-1 is bitmask [ N-1] ═ 1111 · 1111, the number of bits 0 is 0, the number of bits 1 is N, and so on.
S330, judging the relation between each pixel value of the pixel value sequence group and a preset threshold value, and recording the comparison result of each pixel value.
In this embodiment, a threshold may be preset according to a specific application of the target image, each pixel value in the target image is compared with the preset threshold by using a cmp instruction, and a comparison result of each pixel value and an index corresponding to the comparison result are recorded.
In some implementations, as the sequence numbers corresponding to the pixel values in the target image are in ascending order, the cmp instructions are shifted right one by one, and the comparison result of each pixel value is obtained and saved. This embodiment does not limit the ordering, and the sequence numbers corresponding to the pixel values in the target image may be in a descending order, and at this time, the cmp instructions need to be shifted left one by one.
In 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 initialized pixel value sequence group are further subdivided into a plurality of initialized pixel value sequence subgroups, the relationship between each pixel value in each initialized pixel value sequence subgroup and the preset threshold is judged in parallel, and then the comparison result of each pixel value is obtained and stored.
S340, obtaining the pixel values meeting the preset conditions by using the comparison results, and storing the pixel values meeting the preset conditions in parallel according to the corresponding indexes.
In this embodiment, pixel values meeting a preset condition, for example, pixel values greater than or equal to a preset threshold, may be obtained according to the comparison result, and according to the pixel values and corresponding indexes, the number of bits in the index corresponding to each pixel value is counted respectively, that is, corresponding position information of the pixel values in the initialization pixel value sequence group may be obtained, and the pixel values meeting the preset threshold may be directly stored in parallel, for example, in a stack or in a queue, by identifying the position information corresponding to the index and the index.
The image data storage method provided by the embodiment can avoid the interruption of the instruction pipeline, and improves the processing efficiency of the image data. In addition, in some implementation manners, data parallelization storage can be realized, and/or 32 elements or more can be operated in the same instruction cycle, and the like, so that the processing speed of the target image can be further increased, and the output frame rate of the image can be further increased.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
An embodiment of the present application further provides a data storage device. The data storage device is not described in detail in the foregoing embodiments of the method.
Referring to fig. 6, fig. 6 is a schematic block diagram of a data storage device according to an embodiment of the present application. The data storage device includes: an initialization module 61, an index assignment module 62 and a save module 63.
The initialization module 61 is configured to acquire data to be stored, initialize the data to be stored, and acquire an initialization data sequence group;
an index assigning module 62, configured to assign an index corresponding to each piece of data in the initialized data sequence group, where the index includes address information of each piece of data;
the saving module 63 is configured to determine data meeting a preset condition in the initialization data sequence group, and save the data meeting the preset condition by using an index corresponding to the data.
Optionally, as an implementation manner, as shown in fig. 7, the saving module 63 includes a determining submodule 6331 and a saving submodule 632.
The judging submodule 6331 is configured to judge a relationship between each data in the initialization data sequence group and a preset threshold, and record a comparison result of each data.
The saving sub-module 632 is configured to obtain data meeting the preset condition according to the comparison result, and save the data meeting the preset condition by using the index corresponding to the data.
Optionally, as an implementation manner, the determining submodule 6331 is specifically configured to:
and comparing each data in the initialization data sequence group with a preset threshold value by using a comparison instruction.
Optionally, as an implementation manner, the initialization module 61 is specifically configured to:
giving a serial number corresponding to each data in the data to be stored to obtain an initialized data sequence group; or
And preprocessing each data in the data to be stored, giving a serial number corresponding to each preprocessed data, and obtaining an initialized data sequence group.
Optionally, as an implementation manner, the sequence numbers are sorted in an ascending order or a descending order.
Optionally, as an implementation manner, the index assignment module 62 is specifically configured to:
and coding the serial number of each data in the initialization data sequence group by adopting the bit mask sequence to obtain an index corresponding to each data.
On the basis of the data storage device provided in any of the foregoing embodiments, an embodiment of the present application provides a data storage device, and a schematic block diagram of the data storage device is shown in fig. 8. As shown in fig. 8, the data storage device includes: an initialization module 61, an index assignment module 62, a division module 64, and a save module 63.
The initialization module 61 is configured to acquire data to be stored, initialize the data to be stored, and acquire an initialization data sequence group;
an index assigning module 62, configured to assign an index corresponding to each piece of data in the initialized data sequence group, where the index includes address information of each piece of data;
a dividing module 64, configured to divide the initialization data sequence group into a plurality of initialization data sequence subgroups;
and a saving module 63, configured to determine, in parallel, data that meets the preset condition in each initialized data sequence subgroup, and save the data that meets the preset condition by using an index corresponding to the data.
The data meeting the preset conditions in each initialization data sequence group are determined in parallel, and the data processing efficiency is further improved.
An embodiment of the present application also provides an electronic device, as shown in fig. 9, which may include one or more processors 90 (only one is shown in fig. 9), a memory 91, and a computer program 92, e.g., a data-storing program, stored in the memory 91 and executable on the one or more processors 90. The steps in the data storage method embodiments may be implemented by one or more processors 90 executing computer programs 92. Alternatively, the one or more processors 90, when executing the computer program 92, may implement the functions of the modules/units in the data storage device embodiments, which are not limited herein.
Those skilled in the art will appreciate that fig. 9 is merely an example of an electronic device and is not intended to limit the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or different components, e.g., the electronic device may also include input-output devices, network access devices, buses, etc.
In one embodiment, the Processor 90 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
In one embodiment, the storage 91 may be an internal storage unit of the electronic device, such as a hard disk or a 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 Memory Card (SMC), a Secure Digital (SD) card, a flash memory card (flash card), and the like provided 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 for storing 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.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules, so as to perform all or part of the functions described above. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program can implement the steps in the data storage method embodiment.
An embodiment of the present application provides a computer program product, which when run on an electronic device, enables the electronic device to implement the steps in the data storage method embodiment.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/electronic device and method may be implemented in other ways. For example, the above-described apparatus/electronic device embodiments are merely illustrative, and for example, a module or a unit may be divided into only one logic function, and may be implemented in other ways, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method according to the embodiments of the present invention may be realized, or a computer program that can be executed by a computer program to instruct related hardware may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the steps of the embodiments of the method may be realized. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, in accordance with legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunications signals.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A method of storing data, comprising:
acquiring data to be stored, and initializing the data to be stored to obtain an initialized data sequence group;
giving an index corresponding to each data in the initialization data sequence group, wherein the index comprises address information of each data;
and determining data meeting preset conditions in the initialization data sequence group, and storing the data meeting the preset conditions in parallel by using indexes corresponding to the data.
2. The data storage method according to claim 1, wherein the determining data meeting a preset condition in the initialized data sequence group and storing the data meeting the preset condition in parallel by using an index corresponding to the data comprises:
judging the relation between each data in the initialization data sequence group and a preset threshold value, and recording the comparison result of each data;
and acquiring data meeting preset conditions according to the comparison result, and storing the data meeting the preset conditions in parallel by using indexes corresponding to the data.
3. The data storage method according to claim 1 or 2, wherein the determining a relationship between each data in the initialization data sequence group and a preset threshold comprises:
and comparing each data in the initialization data sequence group with a preset threshold value by using a comparison instruction.
4. The data storage method according to claim 1 or 2, wherein the initializing the data to be stored to obtain an initialization data sequence group includes:
giving a serial number corresponding to each data in the data to be stored to obtain an initialized data sequence group; or
And preprocessing each data in the data to be stored, giving a serial number corresponding to each preprocessed data, and obtaining an initialized data sequence group.
5. The data storage method of claim 4 wherein the sequence numbers are sorted in ascending or descending order.
6. The data storage method according to claim 1 or 2, wherein the assigning an index corresponding to each data in the initialization data sequence group, the index including address information of each data, includes:
and coding the serial number of each data in the initialization data sequence group by adopting the bit mask sequence to obtain an index corresponding to each data.
7. The method according to claim 1 or 2, wherein the assigning an index corresponding to each data in the initialization data sequence group, the index including address information of each data, further comprises:
dividing the initialization data sequence group into a plurality of initialization data sequence subgroups;
the determining the data meeting the preset condition in the initialization data sequence group and storing the data meeting the preset condition in parallel by using the index corresponding to the data includes:
and determining the data meeting the preset conditions in each initialization data sequence subgroup in parallel, and storing the data meeting the preset conditions in parallel by using the indexes corresponding to the data.
8. A data storage device, comprising:
the device comprises an initialization module, a data storage module and a data processing module, wherein the initialization module is used for acquiring data to be stored and initializing the data to be stored to acquire an initialization data sequence group;
the index giving module is used for giving an index corresponding to each data in the initialization data sequence group, and the index comprises address information of each data;
and the storage module is used for determining the data meeting the preset conditions in the initialization data sequence group and storing the data meeting the preset conditions in parallel by using the indexes corresponding to the data.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the data storage method according to any one of claims 1 to 7 when executing the computer program.
10. A computer storage medium, in which a computer program is stored, which, when being executed by a processor, carries out the steps of the data storage method according to any one of claims 1 to 7.
CN202110682250.8A 2021-06-20 2021-06-20 Data storage method and device and electronic equipment Pending CN113535117A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110682250.8A CN113535117A (en) 2021-06-20 2021-06-20 Data storage method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110682250.8A CN113535117A (en) 2021-06-20 2021-06-20 Data storage method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN113535117A true CN113535117A (en) 2021-10-22

Family

ID=78125198

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110682250.8A Pending CN113535117A (en) 2021-06-20 2021-06-20 Data storage method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN113535117A (en)

Similar Documents

Publication Publication Date Title
CN107908998B (en) Two-dimensional code decoding method and device, terminal equipment and computer readable storage medium
CN112348778B (en) Object identification method, device, terminal equipment and storage medium
CN111131688B (en) Image processing method and device and mobile terminal
CN115205383A (en) Camera pose determination method and device, electronic equipment and storage medium
CN107330944B (en) Panoramic image identification method and device, terminal equipment and storage medium
CN108040244B (en) Snapshot method and device based on light field video stream and storage medium
CN114170432A (en) Image processing method, image identification method and related device
CN113535117A (en) Data storage method and device and electronic equipment
CN112837384A (en) Vehicle marking method and device and electronic equipment
CN108629219B (en) Method and device for identifying one-dimensional code
CN112200004B (en) Training method and device for image detection model and terminal equipment
CN113239738B (en) Image blurring detection method and blurring detection device
CN111739106B (en) Corner point coding method, calibration method, device, electronic equipment and storage medium
CN111291240B (en) Method for processing data and data processing device
CN113469130A (en) Shielded target detection method and device, storage medium and electronic device
CN112331310A (en) Medical image data display method and device, storage medium and intelligent equipment
CN111476528B (en) Data processing method, device, equipment and storage medium based on express delivery library
CN113160137A (en) Shrimp fry counting method, terminal device and storage medium
CN113673268B (en) Identification method, system and equipment for different brightness
CN113228051A (en) Image sensor for optical code recognition
CN116226789B (en) Data co-distribution judging method, device, equipment and medium based on artificial intelligence
CN113240723A (en) Monocular depth estimation method and device and depth evaluation equipment
CN112348905B (en) Color recognition method and device, terminal equipment and storage medium
CN117086885B (en) Calibration method and device for mechanical arm position, storage medium and electronic device
CN116363031B (en) Imaging method, device, equipment and medium based on multidimensional optical information fusion

Legal Events

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