A method, device and equipment for format conversion of image data frame and storage medium
By reading and caching data in a preset quantity during image data frame format conversion, calculating memory requirements, limiting the amount of data converted in a single batch, and clearing the cache after conversion, the problems of high memory consumption and local out-of-order processing are solved, thus improving conversion efficiency.
Patent Information
- Application Number
- CN202211557783.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-06
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2042-12-06
AI Technical Summary
The conversion of image data frame formats consumes a lot of memory and has local out-of-order issues, resulting in low conversion efficiency.
By acquiring a data file containing multiple frames of image data, reading unread batch data according to a preset number of frames, calculating the required memory and safe memory, and caching the data if the safe memory is not exceeded, otherwise performing format conversion and clearing the data in the cache to avoid local out-of-order processing.
It effectively reduces memory consumption, improves the efficiency of image data frame format conversion, and avoids local out-of-order problems.
Smart Images

Figure CN115883846B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data format conversion, and more particularly, to a method and device for converting the format of image data frames, an apparatus, and a storage medium. BACKGROUND
[0002] With the development of intelligent technology, unmanned driving has been extensively researched and gradually put into real life. When an unmanned vehicle is driving, it will collect image data of the unmanned vehicle scene at regular intervals and save it to the vehicle storage. After the unmanned vehicle returns to the starting point, the collected image data of the unmanned vehicle scene needs to be processed to analyze the driving behavior of the unmanned vehicle. The format of the collected image data of the unmanned vehicle scene is.mbag format. Before processing the collected image data, the format needs to be converted to.parquet format.
[0003] At present, however, a large amount of memory is consumed in the format conversion process of image data frames, and due to the huge number of image data frames, the problem of local disorder occurs after format conversion, resulting in low efficiency of image data frame format conversion. SUMMARY
[0004] In view of the above problems, the present application is proposed to provide a method and device for converting the format of image data frames, an apparatus, and a storage medium to reduce the memory consumed in the format conversion of image data frames.
[0005] To achieve the above-mentioned purpose, the specific scheme is as follows:
[0006] A method for converting the format of image data frames, comprising:
[0007] obtaining a data file containing a plurality of frame image data;
[0008] reading the frame image data of a current batch in the data file that has not been read according to a preset frame reading quantity;
[0009] determining whether each frame image data in the data file has been read;
[0010] if not, calculating the required memory for converting the frame image data of the current batch and the frame image data in the buffer and the safe memory;
[0011] if the required memory does not exceed the safe memory, buffering the frame image data of the current batch in the buffer, and returning to execute the step of reading the frame image data of a current batch in the data file that has not been read according to a preset frame reading quantity;
[0012] If the required memory exceeds the safe memory, the current batch of frame image data and the buffered frame image data are converted to obtain current cache batch conversion data, and the current cache batch conversion data is output to a pre-established output file;
[0013] The buffered frame image data in the buffer is cleaned to obtain a cleaned frame image data buffer, and the step of reading the current batch of frame image data in the data file that has not been read according to the preset frame reading quantity is returned to be executed;
[0014] If yes, the current batch of frame image data is converted to obtain the current batch of conversion data;
[0015] The current batch of conversion data is output to the output file, and the output file containing the current batch of conversion data and the conversion data of each cache batch is determined.
[0016] Optionally, the required memory for converting the current batch of frame image data and the frame image data in the buffer includes:
[0017] The amount of currently used memory is obtained;
[0018] According to the memory amount, the required memory for converting the current batch of frame image data and the frame image data in the buffer is calculated.
[0019] Optionally, according to the memory amount and the data size, the required memory for converting the current batch of frame image data and the frame image data in the buffer is calculated, including:
[0020] The actual memory amount is obtained by subtracting the basic use memory from the memory amount, and the basic use memory is the basic consumption memory amount for frame image data format conversion;
[0021] The format conversion consumption memory amount is obtained by multiplying the actual memory amount by the format conversion memory consumption ratio;
[0022] The required memory for converting the current batch of frame image data and the frame image data in the buffer is obtained by adding the format conversion consumption memory amount and the basic use memory.
[0023] Optionally, the safe memory for converting the current batch of frame image data and the frame image data in the buffer includes:
[0024] The current available memory amount is obtained;
[0025] The current batch of frame image data and the frame image data in the buffer are accumulated to obtain temporary cache batch frame image data;
[0026] calculating a data size of the frame image data of the temporary cache batch;
[0027] calculating, according to the available memory amount and the data size, a safe memory for converting the frame image data of the current batch and the frame image data in the cache.
[0028] Optionally, calculating, according to the available memory amount and the data size, a safe memory for converting the frame image data of the current batch and the frame image data in the cache comprises:
[0029] multiplying the data size by a format conversion memory consumption ratio to obtain a memory consumption amount for converting the frame image data of the temporary cache batch;
[0030] subtracting the memory consumption amount of the temporary cache batch from the available memory amount to obtain the safe memory for converting the frame image data of the current batch and the frame image data in the cache.
[0031] Optionally, after performing format conversion on the frame image data of the current batch and the cached frame image data to obtain converted data of the current cache batch, the method further comprises:
[0032] determining a preset number of target frame image data in the cache;
[0033] cleaning the cached frame image data in the cache to obtain a cleaned cache of the cached frame image data;
[0034] cleaning, in the cache, the cached frame image data other than the target frame image data to obtain a cleaned cache containing the target frame image data.
[0035] Optionally, the method further comprises:
[0036] if the required memory does not exceed a first preset proportion of the safe memory, after caching the frame image data of the current batch in the cache, reading, according to a second preset proportion of a preset frame reading number, the frame image data of the current batch in the data file that has not been read, and performing the step of judging whether each frame image data in the data file has been read.
[0037] An image data frame format conversion device, comprising:
[0038] a data file acquisition unit configured to acquire a data file containing a plurality of frame image data;
[0039] a frame image batch reading unit, configured to read frame image data of a current batch in the data file according to a preset frame reading number;
[0040] a completion reading judging unit, configured to judge whether each frame image data in the data file is read completely, if not, execute a memory calculating unit, if yes, execute a second format converting unit;
[0041] the memory calculating unit, configured to calculate required memory and safe memory for converting the frame image data of the current batch and the frame image data in the buffer;
[0042] a frame data buffering unit, configured to buffer the frame image data of the current batch in the buffer if the required memory does not exceed the safe memory, and return to execute the frame image batch reading unit;
[0043] the first format converting unit, configured to convert the frame image data of the current batch and the buffered frame image data if the required memory exceeds the safe memory, to obtain conversion data of a current buffer batch, and output the conversion data of the current buffer batch to a pre-established output file;
[0044] a buffer cleaning unit, configured to clean the buffered frame image data in the buffer to obtain the buffer after cleaning the frame image data, and return to execute the frame image batch reading unit;
[0045] the second format converting unit, configured to convert the frame image data of the current batch to obtain conversion data of the current batch;
[0046] a file output unit, configured to output the conversion data of the current batch to the output file, and determine the output file containing the conversion data of the current batch and conversion data of each buffer batch.
[0047] Optionally, the memory calculating unit comprises:
[0048] a used memory obtaining unit, configured to obtain an amount of currently used memory;
[0049] a required memory calculating unit, configured to calculate required memory for converting the frame image data of the current batch and the frame image data in the buffer according to the amount of memory;
[0050] a safe memory calculating unit, configured to calculate safe memory for converting the frame image data of the current batch and the frame image data in the buffer.
[0051] Optionally, the memory calculating unit comprises:
[0052] The first memory calculating subunit is configured to subtract a basic used memory from the memory amount to obtain an actual memory amount, wherein the basic used memory is a basic consumed memory amount for performing the frame image data format conversion;
[0053] The second memory calculating subunit is configured to multiply the actual memory amount by a format conversion memory consumption ratio to obtain a format conversion consumed memory amount;
[0054] The third memory calculating subunit is configured to add the format conversion consumed memory amount and the basic used memory to obtain a required memory for converting the current batch of frame image data and the buffered frame image data.
[0055] Optionally, the safe memory calculating unit comprises:
[0056] The available memory obtaining unit is configured to obtain a current available memory amount;
[0057] The temporary buffer batch determining unit is configured to add the current batch of frame image data and the buffered frame image data to obtain a temporary buffer batch of frame image data;
[0058] The data size calculating unit is configured to calculate a data size of the temporary buffer batch of frame image data;
[0059] The safe memory determining unit is configured to calculate a safe memory for converting the current batch of frame image data and the buffered frame image data according to the available memory amount and the data size.
[0060] Optionally, the safe memory determining unit comprises:
[0061] The first safe memory determining subunit is configured to multiply the data size by a format conversion memory consumption ratio to obtain a memory consumption amount for converting the temporary buffer batch;
[0062] The second safe memory determining subunit is configured to subtract the memory consumption amount of the temporary buffer batch from the available memory amount to obtain the safe memory for converting the current batch of frame image data and the buffered frame image data.
[0063] Optionally, the device further comprises:
[0064] The target frame determining unit is configured to determine a preset number of target frame image data in the buffer after the first format converting unit converts the current batch of frame image data and the buffered frame image data to obtain a current buffer batch of converted data;
[0065] The buffer cleaning unit comprises:
[0066] The cache cleaning subunit is configured to clean the cached frame image data of the target frame image data in the cache, to obtain a cache containing the target frame image data after cleaning the frame image data.
[0067] Optionally, the device further comprises:
[0068] The proportion data reading unit is configured to, if the required memory does not exceed the first preset proportion of the safe memory, read the current batch of frame image data in the data file that has not been read according to the second preset proportion of the preset frame reading quantity after the current batch of frame image data is cached in the cache, and execute the reading judgment unit.
[0069] A format conversion device of image data frame comprises a memory and a processor;
[0070] The memory is configured to store a program.
[0071] The processor is configured to execute the program to implement each step of the format conversion method of image data frame.
[0072] A storage medium has a computer program stored thereon, and the computer program is executed by a processor to implement each step of the format conversion method of image data frame.
[0073] By the above technical scheme, the application obtains a data file containing multiple frame image data, reads frame image data of a current batch in the data file according to a preset frame reading quantity, judges whether each frame image data in the data file is read, if not, calculates required memory and safe memory for converting the frame image data of the current batch and the frame image data in the buffer, if the required memory does not exceed the safe memory, caches the frame image data of the current batch in the buffer, and returns to execute the step of reading frame image data of a current batch in the data file according to a preset frame reading quantity, if the required memory exceeds the safe memory, performs format conversion on the frame image data of the current batch and the cached frame image data to obtain conversion data of a current cache batch, outputs the conversion data of the current cache batch to a pre-established output file, cleans the cached frame image data in the buffer to obtain the buffer after the cleaned frame image data, and returns to execute the step of reading frame image data of a current batch in the data file according to a preset frame reading quantity, if yes, performs format conversion on the frame image data of the current batch to obtain conversion data of the current batch, outputs the conversion data of the current batch to the output file, and determines the output file containing the conversion data of the current batch and conversion data of each cache batch. As can be seen, by reading frame image data of a preset frame reading quantity, format conversion is performed on frame image data in multiple batches to avoid the problem of local disorder, and by setting safe memory to limit the amount of conversion data of a single batch and cleaning the buffer after conversion data, the consumption of memory is saved, and the format conversion efficiency of image data frames is improved. BRIEF DESCRIPTION OF DRAWINGS
[0074] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The detailed description is merely meant to teach a person of ordinary skill a way to make and use the application and is not intended to suggest the only way that the application could be implemented. The detailed description incorporates by reference the appended drawings. Like reference numerals are used to denote like parts throughout the various figures.
[0075] Figure 1 A flowchart of a process for implementing format conversion of image data frames is provided for an embodiment of the application;
[0076] Figure 2 A structural diagram of an apparatus for implementing format conversion of image data frames is provided for an embodiment of the application;
[0077] Figure 3 A structural diagram of an apparatus for implementing format conversion of image data frames is provided for an embodiment of the application. DETAILED DESCRIPTION
[0078] The technical solutions in the embodiments of the present application will be described clearly and completely in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0079] The scheme of the present application can be implemented based on a terminal with data processing capability, which can be a computer, a server, a cloud, etc.
[0080] Next, the image data frame format conversion method of the present application will be described in conjunction with the drawings Figure 1 The image data frame format conversion method of the present application can include the following steps:
[0081] Step S101, acquiring a data file containing a plurality of frame image data.
[0082] Specifically, the data file can be located in the on-board memory of the on-board system, and the data file can be acquired by connecting with the on-board memory of the on-board system.
[0083] The format of the frame image data included in the data file can be.mbag type.
[0084] Step S102, reading the current batch of frame image data in the data file according to a preset frame reading quantity.
[0085] Specifically, the preset frame reading quantity can represent the number of frame image data read each time. The preset frame reading quantity can be customized, such as 10 frames, 20 frames, etc.
[0086] Further, after reading the current batch of frame image data, the batch of frame image data in the data file is marked as read.
[0087] It can be understood that the frame reading quantity is set so that the frame image data can be read in a limited quantity, avoiding excessive memory consumption when converting frame image data due to excessive data quantity.
[0088] Step S103, determining whether each frame image data in the data file is read completely, if yes, executing step S109, if not, executing step S104.
[0089] Step S104, calculating the required memory and safe memory for converting the current batch of frame image data and the frame image data in the buffer.
[0090] Specifically, the required memory can represent at least the required memory for converting the frame image data of the current batch and the frame image data in the buffer, and the safe memory can represent a memory value that can guarantee that no abnormality caused by excessive memory consumption will occur when the format of the frame image data of the current batch and the frame image data in the buffer is converted.
[0091] Step S105: It is determined whether the required memory exceeds the safe memory. If yes, step S107 is executed; if no, step S106 is executed.
[0092] It can be understood that if the required memory exceeds the safe memory, it can be indicated that increasing the batch of frame image data will possibly cause excessive memory consumption in the format conversion, and step S107 can be executed. If the required memory does not exceed the safe memory, it can be indicated that more batches of frame image data can be accepted for format conversion to improve the utilization of memory, and step S106 can be executed.
[0093] Step S106: The frame image data of the current batch is buffered in the buffer, and step S102 is returned to be executed.
[0094] Specifically, if the required memory does not exceed the safe memory, the frame image data of the current batch can be buffered, and then more batches of frame image data can be accepted for format conversion.
[0095] Step S107: The frame image data of the current batch and the buffered frame image data are converted in format to obtain converted data of the current buffered batch, and the converted data of the current buffered batch is output to a pre-established output file.
[0096] The data format of the converted data obtained by converting the format of the frame image data is a.parquet type.
[0097] Specifically, if the required memory exceeds the safe memory, the frame image data of the current batch and the frame image data in the buffer need to be converted in format and output to the output file.
[0098] It can be understood that when the required memory exceeds the safe memory, the frame image data of the current batch and the frame image data in the buffer are converted in format together, which can maximize the utilization of memory and guarantee the efficiency of the format conversion of the frame image data.
[0099] Step S108: The buffered frame image data in the buffer is cleaned to obtain a buffer after the frame image data is cleaned, and step S102 is returned to be executed.
[0100] It can be understood that after the format conversion of the frame image data is performed, the buffer needs to be cleaned to accept the buffering of the next batch of frame image data.
[0101] In step S109, the current batch of frame image data is converted in format to obtain conversion data of the current batch.
[0102] Specifically, if the frame image data in the data file has been read completely, the current batch of frame image data can be represented as the last batch of frame image data in the data file, and then the current batch of frame image data can be converted in format to obtain conversion data of the current batch.
[0103] In step S110, the conversion data of the current batch is output to the output file, and an output file containing the conversion data of the current batch and the conversion data of each cached batch is determined.
[0104] Specifically, after the conversion data corresponding to the last batch of frame image data in the data file is output to the output file, the output file contains the conversion data corresponding to each frame image data in the data file.
[0105] The image data frame format conversion method provided by the embodiment comprises the following steps: obtaining a data file containing a plurality of frame image data; reading a current batch of frame image data in the data file that has not been read according to a preset frame reading quantity; judging whether each frame image data in the data file has been read completely; if not, calculating required memory and safe memory for converting the current batch of frame image data and the frame image data in the buffer; if the required memory does not exceed the safe memory, caching the current batch of frame image data in the buffer, and returning to execute the step of reading the current batch of frame image data in the data file that has not been read according to the preset frame reading quantity; if the required memory exceeds the safe memory, converting the current batch of frame image data and the cached frame image data in format to obtain conversion data of a current cached batch, outputting the conversion data of the current cached batch to a pre-established output file, cleaning the cached frame image data in the buffer to obtain the buffer after the cleaning of the frame image data, and returning to execute the step of reading the current batch of frame image data in the data file that has not been read according to the preset frame reading quantity; if yes, converting the current batch of frame image data in format to obtain conversion data of the current batch, outputting the conversion data of the current batch to the output file, and determining an output file containing the conversion data of the current batch and the conversion data of each cached batch. As can be seen, by reading frame image data of a preset frame reading quantity, converting frame image data in multiple batches can avoid the problem of local disorder, and by setting safe memory to limit the amount of conversion data of a single batch and cleaning the buffer after conversion data, the consumption of memory is saved, and the format conversion efficiency of image data frames is improved.
[0106] In some embodiments of the present application, the process of calculating the required memory for converting the current batch of frame image data and the frame image data in the buffer mentioned in the above embodiments can include:
[0107] S1, obtaining the current memory usage.
[0108] S2, calculating the required memory for converting the current batch of frame image data and the frame image data in the buffer according to the memory usage and the data size.
[0109] Specifically, the process of calculating the required memory for converting the current batch of frame image data and the frame image data in the buffer according to the memory usage and the data size can include:
[0110] S21, subtracting the basic usage memory from the memory usage to obtain the actual memory usage.
[0111] Specifically, the basic usage memory can represent the basic consumption memory usage for frame image data format conversion.
[0112] S22, multiplying the actual memory usage by the format conversion memory consumption ratio to obtain the format conversion consumption memory usage.
[0113] Specifically, the format conversion memory consumption ratio can represent the ratio of the consumed memory to the data size of each frame image data when converting the format.
[0114] S23, adding the format conversion consumption memory usage and the basic usage memory to obtain the required memory for converting the current batch of frame image data and the frame image data in the buffer.
[0115] For example, the current memory usage is 10, the basic usage memory is 2G, and the format conversion memory consumption ratio is 1.5, then the required memory for converting the current batch of frame image data and the frame image data in the buffer is (10G-2G)*1.5+2G=14G.
[0116] In some embodiments of the present application, the process of calculating the required memory for converting the current batch of frame image data and the frame image data in the buffer mentioned in the above embodiments can include:
[0117] S1, obtaining the current available memory usage.
[0118] Specifically, the available memory usage can represent the current remaining memory usage that can be used for format conversion of frame image data.
[0119] S2, accumulate the frame image data of the current batch and the frame image data in the buffer to obtain temporary cache batch frame image data.
[0120] For example, if the preset frame reading quantity is 10 frames, the current batch frame image data has 10 frames, and the frame image data in the buffer has two batches, then the frame image data in the buffer has 20 frames, and the temporary cache batch frame image data is the sum of the frame image data in the 20 frame buffer and the current batch frame image data, which is 30 frames of image.
[0121] S3, calculate the data size of the temporary cache batch frame image data.
[0122] For example, if the data size of every 10 frames is 1G, then the data size of the temporary cache batch frame image data is 30 / 10*1G=3G.
[0123] S4, according to the available memory quantity and the data size, calculate the safe memory for converting the current batch frame image data and the frame image data in the buffer.
[0124] Specifically, the process of calculating the safe memory for converting the current batch frame image data and the frame image data in the buffer according to the available memory quantity and the data size can include:
[0125] S41, multiply the data size by the format conversion memory consumption ratio to obtain the memory consumption quantity for converting the temporary cache batch.
[0126] Specifically, the format conversion memory consumption ratio can be used to represent the basic consumption memory quantity for frame image data format conversion.
[0127] S42, subtract the memory consumption quantity of the temporary cache batch from the available memory quantity to obtain the safe memory for converting the current batch frame image data and the frame image data in the buffer.
[0128] For example, if the current available memory quantity is 20G, the data size of the temporary cache batch frame image data is 3G, and the format conversion memory consumption ratio is 1.5, then the safe memory for converting the current batch frame image data and the frame image data in the buffer is 20G-1*3G*1.5=15.5G.
[0129] In consideration of avoiding frame disorder of the converted data after the format conversion of the frame image data, a certain number of frames can be reserved as a buffer, and in some embodiments of the present application, after the process of converting the frame image data of the current batch and the buffered frame image data to obtain the converted data of the current buffered batch, a preset number of target frame image data in the buffer can be determined.
[0130] Specifically, the preset number of target frame image data can be customized, and the target frame image data can be used for buffering the batch format conversion, so that the frame order of the converted data after the format conversion of the frame image data is the frame order corresponding to the frame image data.
[0131] Based on this, the process of cleaning the buffered frame image data in the buffer to obtain the cleaned frame image data after the buffer is further introduced, which can include:
[0132] In the buffer, the buffered frame image data except for the target frame image data is cleaned to obtain the buffer containing the target frame image data after the cleaning of the frame image data.
[0133] The format conversion method of the image data frame provided in the embodiment can determine a preset number of target frame image data in the buffer after the format conversion of the frame image data of the current batch and the buffered frame image data to obtain the converted data of the current buffered batch, so that the frame order of the converted data after the format conversion of the frame image data is the frame order corresponding to the frame image data.
[0134] In consideration of the fact that after reading the initial batch of frame image data, the data of a single batch of frame image data is too small to be converted, and multiple batches need to be read before the format conversion of the frame image data, based on this, the format conversion method of the image data frame provided in the present application can further include:
[0135] If the required memory does not exceed the first preset proportion of the safe memory, after buffering the frame image data of the current batch in the buffer, the frame image data of the current batch in the data file that has not been read is read according to the second preset proportion of the preset frame reading number, and the step S103 of the foregoing embodiment is executed.
[0136] Specifically, the first preset proportion of the safe memory can represent a memory value that does not exceed the safe memory, and the first preset proportion of the safe memory can be much smaller than the safe memory. The second preset proportion of the preset frame reading number can represent a number greater than the preset frame reading number, and the second preset proportion of the preset frame reading number can be a multiple of the preset frame reading number.
[0137] The device for implementing format conversion of image data frames provided by the embodiments of the present application is described below. The device for implementing format conversion of image data frames described below can be referred to the method for implementing format conversion of image data frames described above.
[0138] Referring to Figure 2 , Figure 2 The device for implementing format conversion of image data frames provided by the embodiments of the present application is described below. The device for implementing format conversion of image data frames described below can be referred to the method for implementing format conversion of image data frames described above.
[0139] As Figure 2 shown, the device can include:
[0140] a data file obtaining unit 11, configured to obtain a data file containing a plurality of frame image data;
[0141] a frame image batch reading unit 12, configured to read frame image data of a current batch in the data file according to a preset frame reading quantity;
[0142] a completion reading judging unit 13, configured to judge whether each frame image data in the data file is read completely, if not, execute a memory calculating unit 14, if yes, execute a second format converting unit 18;
[0143] the memory calculating unit 14, configured to calculate required memory and safe memory for converting the frame image data of the current batch and the frame image data in the buffer;
[0144] a frame data buffering unit 15, configured to buffer the frame image data of the current batch in the buffer if the required memory does not exceed the safe memory, and return to execute the frame image batch reading unit;
[0145] a first format converting unit 16, configured to convert the frame image data of the current batch and the buffered frame image data if the required memory exceeds the safe memory, to obtain conversion data of a current buffered batch, and output the conversion data of the current buffered batch to a pre-established output file;
[0146] a buffer cleaning unit 17, configured to clean the buffered frame image data in the buffer to obtain the buffer after cleaning the frame image data, and return to execute the frame image batch reading unit;
[0147] the second format converting unit 18, configured to convert the frame image data of the current batch to obtain conversion data of the current batch;
[0148] The file output unit 19 is configured to output the current batch of converted data to the output file, and determine the output file containing the current batch of converted data and each batch of converted data in the cache.
[0149] The device for format conversion of image data frames provided by the embodiments of the present application can be applied to a device for format conversion of image data frames, such as a terminal: a mobile phone, a computer, etc. Figure 3 The hardware structure block diagram of the device for format conversion of image data frames is shown in FIG. 1. Figure 3 The hardware structure of the device for format conversion of image data frames can include at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4.
[0150] In the embodiments of the present application, the number of the processor 1, the communication interface 2, the memory 3 and the communication bus 4 is at least one, and the processor 1, the communication interface 2 and the memory 3 complete the communication with each other through the communication bus 4.
[0151] The processor 1 can be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application, etc.
[0152] The memory 3 can include a high-speed RAM memory, and can also include a non-volatile memory, etc., such as at least one disk memory.
[0153] The memory stores a program, and the processor can call the program stored in the memory, and the program is used for:
[0154] obtaining a data file containing a plurality of frame image data;
[0155] reading a current batch of frame image data in the data file according to a preset frame reading quantity;
[0156] determining whether each frame image data in the data file is read completely;
[0157] if not, calculating required memory and safe memory for converting the current batch of frame image data and the frame image data in the cache;
[0158] if the required memory does not exceed the safe memory, caching the current batch of frame image data in the cache, and returning to execute the step of reading the current batch of frame image data in the data file according to the preset frame reading quantity;
[0159] If the required memory exceeds the safe memory, the current batch of frame image data and the buffered frame image data are converted to obtain conversion data of the current buffered batch, and the conversion data of the current buffered batch is output to a pre-established output file;
[0160] The buffered frame image data is cleaned in the buffer to obtain a cleaned frame image data after buffer, and the step of reading the current batch of frame image data in the data file which is not read according to the preset frame reading quantity is returned to be executed;
[0161] If yes, the current batch of frame image data is converted to obtain conversion data of the current batch;
[0162] The conversion data of the current batch is output to the output file, and the output file containing the conversion data of the current batch and the conversion data of each buffered batch is determined.
[0163] Optionally, the refinement function and the expansion function of the program can refer to the description above.
[0164] The embodiment of the application further provides a storage medium which can store a program suitable for processor execution, and the program is used for:
[0165] Obtaining a data file containing a plurality of frame image data;
[0166] Reading the current batch of frame image data in the data file which is not read according to the preset frame reading quantity;
[0167] Judging whether each frame image data in the data file is read completely;
[0168] If no, calculating required memory and safe memory for converting the current batch of frame image data and the frame image data in the buffer;
[0169] If the required memory does not exceed the safe memory, the current batch of frame image data is buffered in the buffer, and the step of reading the current batch of frame image data in the data file which is not read according to the preset frame reading quantity is returned to be executed;
[0170] If the required memory exceeds the safe memory, the current batch of frame image data and the buffered frame image data are converted to obtain conversion data of the current buffered batch, and the conversion data of the current buffered batch is output to a pre-established output file;
[0171] cleaning the buffered frame image data in the buffer to obtain a cleaned frame image data after buffer, and returning to perform the step of reading the frame image data of the current batch in the data file which has not been read according to the preset frame reading number;
[0172] If yes, the current batch of frame image data is converted to obtain the current batch of conversion data;
[0173] The current batch of conversion data is output to the output file, and the output file containing the current batch of conversion data and the conversion data of each buffered batch is determined.
[0174] Optionally, the refinement function and the extension function of the program can refer to the description above.
[0175] Finally, it should be noted that in this document, the terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0176] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The various embodiments can be combined as needed, and the same and similar parts refer to each other.
[0177] The above description of the disclosed embodiments enables a person skilled in the art to implement or use the present application. Various modifications to the embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method of format conversion of an image data frame, characterized by, The method comprises: acquiring a data file containing a plurality of frame image data; reading a current batch of frame image data in the data file according to a preset frame reading quantity; judging whether each frame image data in the data file is read completely; if not, calculating required memory and safe memory for converting the current batch of frame image data and frame image data in the buffer; if the required memory does not exceed the safe memory, buffering the current batch of frame image data in the buffer, and returning to the step of reading a current batch of frame image data in the data file according to a preset frame reading quantity; if the required memory exceeds the safe memory, performing format conversion on the current batch of frame image data and the buffered frame image data to obtain conversion data of a current buffer batch, and outputting the conversion data of the current buffer batch to a pre-established output file; cleaning the buffered frame image data in the buffer to obtain the buffer after cleaning the frame image data, and returning to the step of reading a current batch of frame image data in the data file according to a preset frame reading quantity; if yes, performing format conversion on the current batch of frame image data to obtain conversion data of the current batch; outputting the conversion data of the current batch to the output file to determine the output file containing the conversion data of the current batch and conversion data of each buffer batch.
2. The method of claim 1, wherein, The calculation of the required memory for converting the current batch of frame image data and the frame image data in the buffer comprises: acquiring a current memory usage; calculating the required memory for converting the current batch of frame image data and the frame image data in the buffer according to the memory usage.
3. The method of claim 2, wherein, The calculation of the required memory for converting the current batch of frame image data and the frame image data in the buffer according to the memory usage comprises: subtracting a basic usage memory from the memory usage to obtain an actual memory usage, the basic usage memory being a basic consumption memory usage for performing format conversion of frame image data; multiplying the actual memory usage by a format conversion memory consumption ratio to obtain a format conversion consumption memory usage; adding the format conversion consumption memory usage and the basic usage memory to obtain the required memory for converting the current batch of frame image data and the frame image data in the buffer.
4. The method of claim 1, wherein, The calculation of the safe memory for converting the current batch of frame image data and the frame image data in the buffer comprises: acquiring a current available memory usage; accumulating the current batch of frame image data and the frame image data in the buffer to obtain frame image data of a temporary buffer batch; calculating a data size of the frame image data of the temporary buffer batch; calculating the safe memory for converting the current batch of frame image data and the frame image data in the buffer according to the available memory usage and the data size.
5. The method of claim 4, wherein, The calculation of the safe memory for converting the current batch of frame image data and the frame image data in the buffer according to the available memory usage and the data size comprises: multiplying the data size by a format conversion memory consumption ratio to obtain a memory consumption amount for converting the temporary cache batch; subtracting the memory consumption amount of the temporary cache batch from the available memory amount to obtain a safe memory for converting the current batch of frame image data and the cached frame image data.
6. The method of claim 1, wherein, After the format conversion of the current batch of frame image data and the cached frame image data, the method further comprises: determining a preset number of target frame image data in the cache; cleaning the cached frame image data in the cache to obtain a cleaned cache of frame image data, comprising: cleaning the cached frame image data in the cache except for the target frame image data to obtain a cleaned cache containing the target frame image data.
7. The method of claim 1, wherein, Further comprising: if the required memory does not exceed the first preset proportion of the safe memory, after caching the current batch of frame image data in the cache, reading the current batch of frame image data in the data file that has not been read according to the second preset proportion of the preset frame reading number, and performing the step of judging whether each frame image data in the data file is read completely.
8. An apparatus for converting the format of an image data frame, characterized by comprising: Comprising: a data file acquisition unit configured to acquire a data file containing a plurality of frame image data; a frame image batch reading unit configured to read a current batch of frame image data in the data file that has not been read according to a preset frame reading number; a complete reading judgment unit configured to judge whether each frame image data in the data file is read completely, if not, execute the memory calculation unit, and if yes, execute the second format conversion unit; the memory calculation unit is configured to calculate the required memory and the safe memory for converting the current batch of frame image data and the frame image data in the cache; a frame data caching unit configured to cache the current batch of frame image data in the cache if the required memory does not exceed the safe memory, and return to execute the frame image batch reading unit; a first format conversion unit configured to perform format conversion on the current batch of frame image data and the cached frame image data to obtain a current cache batch of conversion data if the required memory exceeds the safe memory, and output the current cache batch of conversion data to a pre-established output file; a cache cleaning unit configured to clean the cached frame image data in the cache to obtain a cleaned cache of frame image data, and return to execute the frame image batch reading unit; the second format conversion unit is configured to perform format conversion on the current batch of frame image data to obtain the current batch of conversion data; a file output unit configured to output the current batch of conversion data to the output file, and determine an output file containing the current batch of conversion data and the conversion data of each cache batch.
9. An apparatus for format conversion of image data frames, characterized by comprising a memory and a processor; the memory is configured to store a program; The processor is configured to execute the program to implement the steps of the image data frame format conversion method according to any one of claims 1-7.
10. A storage medium having stored thereon a computer program, characterized in that The computer program, when executed by the processor, implements the steps of the image data frame format conversion method according to any one of claims 1-7.
Citation Information
Patent Citations
Picture format conversion method and device and computer storage medium
CN111489283A
Data management device, data management method, information processing client, and computer-readable medium
US20140354851A1