Image data mirroring method, image data mirroring device, storage medium, and electronic device

文档序号:1847508 发布日期:2021-11-16 浏览:20次 中文

阅读说明:本技术 图像数据的镜像处理方法、装置、存储介质和电子装置 (Image data mirroring method, image data mirroring device, storage medium, and electronic device ) 是由 张宏 李永配 潘武 于 2021-08-17 设计创作,主要内容包括:本发明实施例提供了一种图像数据的镜像处理方法、装置、存储介质和电子装置,其中,该方法包括:按照多个第一图像数据的先后顺序,沿着目标存储器中多个存储位置的第一顺序依次将多个第一图像数据写入多个存储位置;沿着目标存储器的第二顺序,依次从多个存储位置中的每个存储位置读取第一图像数据,得到多个第一图像数据的镜像数据;沿着第一顺序,依次从多个存储位置中的每个存储位置读取第二图像数据,得到多个第二图像数据的镜像数据的方式。通过本发明,解决了相关技术中存在的对图像数据镜像处理时存储空间的占用量较大的问题,达到了降低图像数据镜像处理时存储空间的占用量的效果。(The embodiment of the invention provides a mirror image processing method, a mirror image processing device, a storage medium and an electronic device of image data, wherein the method comprises the following steps: writing the plurality of first image data into the plurality of storage positions in sequence along a first sequence of the plurality of storage positions in the target storage according to the sequence of the plurality of first image data; sequentially reading the first image data from each of the plurality of storage positions along a second sequence of the target memory to obtain mirror image data of the plurality of first image data; and sequentially reading the second image data from each of the plurality of storage positions along the first sequence to obtain mirror image data of the plurality of second image data. The invention solves the problem of larger occupation amount of the storage space during image data mirror image processing in the related technology, and achieves the effect of reducing the occupation amount of the storage space during image data mirror image processing.)

1. A method of mirroring image data, comprising:

writing the plurality of first image data into the plurality of storage positions in sequence along a first sequence of the plurality of storage positions in the target storage according to the sequence of the plurality of first image data;

sequentially reading the first image data from each of the plurality of storage positions along a second sequence of the target memory, wherein the second sequence is opposite to the first sequence, and obtaining a plurality of mirror image data of the first image data;

writing the plurality of second image data into the storage positions from which the first image data are read out in sequence along the second sequence according to the sequence of the plurality of second image data;

and sequentially reading the second image data from each of the storage positions along the first sequence to obtain mirror image data of the second image data.

2. The method of claim 1, wherein writing a plurality of second image data into the storage locations from which the first image data has been read out sequentially along the second order in a sequential order of the plurality of second image data comprises:

judging whether a storage position of the first image data which is read out exists in the target storage;

and under the condition that the storage position of the read first image data exists in the target memory, writing the second image data into the target memory along the second sequence according to the sequence of the second image data.

3. The method of claim 2, wherein determining whether a storage location in the target memory from which the first image data has been read out exists comprises one of:

detecting whether the number of first storage positions in the target memory is larger than a target number threshold, wherein the first storage positions are storage positions where an operation of reading first image data is performed, and determining that the storage positions where the first image data is read out exist in the target memory when the number of the storage positions where the reading operation is performed in the target memory is detected to be larger than the target number threshold;

and detecting whether the second storage position in the target memory has executed the operation of reading the first image data, wherein in the case that the second storage position in the target memory has executed the operation of reading the first image data, the storage position in the target memory, from which the first image data is read, is determined to be judged to exist.

4. The method of claim 1, wherein writing a plurality of second image data to the storage locations from which the first image data has been read out sequentially along the second order in a sequential order of the plurality of second image data comprises:

determining a direction opposite to a first writing direction indicated by the first order as a second writing direction;

and writing the plurality of second image data into the storage position from which the first image data is read out in sequence along the second writing direction according to the sequence of the plurality of second image data.

5. The method of claim 4, wherein determining the opposite direction of the first write direction indicated by the first order as the second write direction comprises:

determining a direction from a low address to a high address of a plurality of the storage locations as the second write direction if the first write direction is a direction from a high address to a low address of the plurality of the storage locations;

and determining a direction from a high address to a low address of a plurality of the storage locations as the second writing direction, in a case where the first writing direction is a direction from a low address to a high address of the plurality of the storage locations.

6. The method of claim 1, wherein the first image data is written to the plurality of storage locations in the target memory in a sequential order of the first image data before the first image data is written to the plurality of storage locations in the target memory in a first order, the method further comprising:

determining the data volume included by each first image data in the plurality of first image data according to a mirror image direction, wherein the mirror image direction is used for indicating the turning mode of an image to be turned;

and acquiring image pixels meeting the data quantity from the image to be turned as a plurality of pieces of first image data.

7. The method according to claim 6, wherein determining the amount of data included in each of the plurality of first image data according to the mirroring direction comprises one of:

under the condition that the mirror image direction is used for indicating that the overturning mode of the image to be overturned is up-down overturning, determining the data quantity included in each first image data to be a row of pixels in the image to be overturned;

and under the condition that the mirror image direction is used for indicating that the overturning mode of the image to be overturned is left-right overturning, determining the data size included in each first image data as one pixel in the image to be overturned.

8. An image data mirroring apparatus, comprising:

the first writing module is used for sequentially writing the plurality of first image data into the plurality of storage positions along a first sequence of the plurality of storage positions in the target memory according to the sequence of the plurality of first image data;

a first reading module, configured to sequentially read the first image data from each of the plurality of storage locations along a second order of the target memory, so as to obtain mirror image data of the plurality of first image data, where the second order is opposite to the first order;

the second writing module is used for sequentially writing the plurality of second image data into the storage positions where the first image data are read out along the second sequence according to the sequence of the plurality of second image data;

and the second reading module is used for sequentially reading the second image data from each of the plurality of storage positions along the first sequence to obtain mirror image data of the plurality of second image data.

9. A computer-readable storage medium, in which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.

10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method as claimed in any of claims 1 to 7 are implemented when the computer program is executed by the processor.

Technical Field

The embodiment of the invention relates to the field of image processing, in particular to a mirror image processing method and device of image data, a storage medium and an electronic device.

Background

Along with the application of security protection control is wider and wider, image acquisition equipment such as cameras have been installed in more and more places, have installed display equipment such as liquid crystal display, LED display screen, booth apart from LED display screen simultaneously. In some applications, due to construction and other reasons, the installation direction of the camera is not necessarily matched with the direction of the actual scene, which causes the situation that the display effect of the image acquired by the image acquisition device on the display device is inconsistent with the actual direction of the image, such as the display effect of a building or a person upside down, or the situation that the left direction and the right direction are opposite, and thus the image needs to be subjected to mirror image processing before the image is displayed.

In the related art, when the image is mirrored, two memories are usually required to alternately perform operations of forward writing and backward reading of continuous image data in a video stream, so that the image mirroring process needs to occupy more storage resources, which causes waste of the storage resources.

Aiming at the problem that storage resources are wasted when image data is subjected to mirroring in the related art, an effective solution is not provided at present.

Disclosure of Invention

The embodiment of the invention provides a mirror image processing method and device for image data, a storage medium and an electronic device, which are used for at least solving the problem that the occupation amount of a storage space is large when the image data is subjected to mirror image processing in the related technology.

According to an embodiment of the present invention, there is provided a mirroring method of image data, including: writing the plurality of first image data into the plurality of storage positions in sequence along a first sequence of the plurality of storage positions in the target storage according to the sequence of the plurality of first image data; sequentially reading the first image data from each of the plurality of storage positions along a second sequence of the target memory, wherein the second sequence is opposite to the first sequence, and obtaining a plurality of mirror image data of the first image data; writing the plurality of second image data into the storage positions from which the first image data are read out in sequence along the second sequence according to the sequence of the plurality of second image data; and sequentially reading the second image data from each of the storage positions along the first sequence to obtain mirror image data of the second image data.

Optionally, sequentially writing the plurality of second image data into the storage locations from which the first image data has been read out along the second order according to the sequential order of the plurality of second image data includes: judging whether a storage position of the first image data which is read out exists in the target storage; and under the condition that the storage position of the read first image data exists in the target memory, writing the second image data into the target memory along the second sequence according to the sequence of the second image data.

Optionally, the determining whether the storage location in the target memory from which the first image data has been read out exists includes one of: detecting whether the number of first storage positions in the target memory is larger than a target number threshold, wherein the first storage positions are storage positions where an operation of reading first image data is performed, and determining that the storage positions where the first image data is read out exist in the target memory when the number of the storage positions where the reading operation is performed in the target memory is detected to be larger than the target number threshold; and detecting whether the second storage position in the target memory has executed the operation of reading the first image data, wherein in the case that the second storage position in the target memory has executed the operation of reading the first image data, the storage position in the target memory, from which the first image data is read, is determined to be judged to exist.

Optionally, sequentially writing the plurality of second image data into the storage locations, from which the first image data has been read out, along the second order according to the sequence of the plurality of second image data includes: determining a direction opposite to a first writing direction indicated by the first order as a second writing direction; and writing the plurality of second image data into the storage position from which the first image data is read out in sequence along the second writing direction according to the sequence of the plurality of second image data.

Optionally, determining an opposite direction of the first writing direction indicated by the first order as the second writing direction comprises: determining a direction from a low address to a high address of a plurality of the storage locations as the second write direction if the first write direction is a direction from a high address to a low address of the plurality of the storage locations; and determining a direction from a high address to a low address of a plurality of the storage locations as the second writing direction, in a case where the first writing direction is a direction from a low address to a high address of the plurality of the storage locations.

Optionally, before writing the plurality of first image data into the plurality of storage locations in the target memory in sequence along the first order of the plurality of storage locations according to the precedence order of the plurality of first image data, the method further includes: determining the data volume included by each first image data in the plurality of first image data according to a mirror image direction, wherein the mirror image direction is used for indicating the turning mode of an image to be turned; and acquiring image pixels meeting the data quantity from the image to be turned as a plurality of pieces of first image data.

Optionally, determining the data amount included in each of the plurality of first image data according to the mirror image direction includes one of: under the condition that the mirror image direction is used for indicating that the overturning mode of the image to be overturned is up-down overturning, determining the data quantity included in each first image data to be a row of pixels in the image to be overturned; and under the condition that the mirror image direction is used for indicating that the overturning mode of the image to be overturned is left-right overturning, determining the data size included in each first image data as one pixel in the image to be overturned.

According to still another embodiment of the present invention, there is also provided a mirroring processing apparatus of image data including: the first writing module is used for sequentially writing the plurality of first image data into the plurality of storage positions along a first sequence of the plurality of storage positions in the target memory according to the sequence of the plurality of first image data; a second reading module, configured to sequentially read the first image data from each of the plurality of storage locations along a second order of the target memory, so as to obtain mirror image data of the plurality of first image data, where the second order is opposite to the first order; the second writing module is used for sequentially writing the plurality of second image data into the storage positions where the first image data are read out along the second sequence according to the sequence of the plurality of second image data; and the second reading module is used for sequentially reading the second image data from each of the plurality of storage positions along the first sequence to obtain mirror image data of the plurality of second image data.

According to a further embodiment of the present invention, there is also provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.

According to yet another embodiment of the present invention, there is also provided an electronic device, including a memory in which a computer program is stored and a processor configured to execute the computer program to perform the steps in any of the above method embodiments.

According to the invention, the plurality of first image data are written into the plurality of storage positions in sequence along the first sequence of the plurality of storage positions in the target storage according to the sequence of the plurality of first image data; sequentially reading the first image data from each of the plurality of storage positions along a second sequence of the target memory, wherein the second sequence is opposite to the first sequence, and obtaining mirror image data of the plurality of first image data; according to the sequence of the plurality of second image data, writing the plurality of second image data into the storage positions of the read first image data along a second sequence; a mode of sequentially reading the second image data from each of the plurality of storage locations along a first order to obtain mirror image data of the plurality of second image data, namely sequentially writing a plurality of first image data having a sequential order into the target memory according to the first order of the plurality of storage locations in the target memory, and sequentially reading the written first image data from the plurality of storage locations in the target memory along a second order opposite to the first order to obtain mirror image data of the first image data, wherein during reading the first image data stored in the target memory, a plurality of second images having a sequential order are sequentially written into the storage locations in the target storage space where the first image data has been read along the second order, even if one target memory is used to complete simultaneous writing and reading of the plurality of first image data and the plurality of second image data, the writing and reading sequence of the first image data and the second image data is opposite, so that the image data after the mirror image processing is obtained, namely, the mirror image operation on the continuous image data can be completed by using one target memory, therefore, the problem that the occupation amount of the storage space is large when the image data is subjected to the mirror image processing in the related technology is solved, and the effect of reducing the occupation amount of the storage space when the image data is subjected to the mirror image processing is achieved.

Drawings

Fig. 1 is a block diagram of a hardware configuration of a mobile terminal of a mirroring method of image data according to an embodiment of the present invention;

FIG. 2 is a flowchart of a method of mirroring image data according to an embodiment of the present invention;

FIG. 3 is a schematic diagram of a left and right mirroring method of an image to be flipped according to an embodiment of the present invention;

FIG. 4 is a schematic diagram of writing first image data in an on-chip memory according to an embodiment of the present invention;

FIG. 5 is a schematic diagram of writing second image data in an on-chip memory according to an embodiment of the present invention;

FIG. 6 is a schematic diagram of a top-down mirroring method of an image to be flipped according to an embodiment of the present invention;

fig. 7 is a schematic diagram of writing a first image to be turned over in the external memory according to the embodiment of the present invention;

fig. 8 is a schematic diagram of writing a second image to be flipped in the external memory according to the embodiment of the present invention;

FIG. 9 is a schematic diagram of a process for mirroring a video stream in accordance with an alternative embodiment of the present invention;

fig. 10 is a block diagram of a configuration of an image data mirroring processing apparatus according to an embodiment of the present invention.

Detailed Description

Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings in conjunction with the embodiments.

It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.

The method embodiments provided in the embodiments of the present invention may be executed in a mobile terminal, a computer terminal, or a similar computing device. Taking the example of being operated on a mobile terminal, fig. 1 is a block diagram of a hardware structure of the mobile terminal of the image data mirroring processing method according to the embodiment of the present invention. As shown in fig. 1, the mobile terminal may include one or more (only one shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 104 for storing data, wherein the mobile terminal may further include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration, and does not limit the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.

The memory 104 may be used to store a computer program, for example, a software program and a module of application software, such as a computer program corresponding to the image processing method of image data in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, so as to implement the method described above. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the mobile terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.

The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.

In the present embodiment, a method for mirroring image data is provided, and fig. 2 is a flowchart of a method for mirroring image data according to an embodiment of the present invention, as shown in fig. 2, the flowchart includes the following steps:

step S202, writing a plurality of first image data into a plurality of storage positions in sequence along a first sequence of the storage positions in a target memory according to the sequence of the first image data;

step S204, sequentially reading the first image data from each of the storage positions along a second sequence of the target memory to obtain mirror image data of the first image data, wherein the second sequence is opposite to the first sequence;

step S206, sequentially writing the plurality of second image data into the storage location where the first image data has been read out, along the second order according to the sequence of the plurality of second image data;

step S208, sequentially reading the second image data from each of the plurality of storage locations along the first sequence to obtain mirror image data of the plurality of second image data.

Through the steps, a plurality of first image data with a precedence order are sequentially written into the target memory according to a first order of a plurality of storage positions in the target memory, and the written first image data are sequentially read from the plurality of storage positions in the target memory along a second order opposite to the first order, so as to obtain mirror image data of the first image data, in the process of reading the first image data stored in the target memory, a plurality of second images with the precedence order are sequentially written into the storage positions, from which the first image data are read, in the target storage space along the second order, even if one target memory is used for completing simultaneous writing and reading operations of the plurality of first image data and the plurality of second image data, the writing and reading orders of the plurality of first image data and the plurality of second image data are opposite, so as to obtain image data after mirror image processing, that is to say, the mirror image operation of continuous image data can be completed by using one target memory, so that the problem that the occupation amount of the storage space is large when the image data is subjected to mirror image processing in the related technology is solved, and the effect of reducing the occupation amount of the storage space when the image data is subjected to mirror image processing is achieved.

In the technical solution provided in step S202, the first image data may be part or all of image data in a single image, or may be part or all of image data in a frame in a continuous video image.

Alternatively, in this embodiment, the first order may be, but is not limited to, determined based on a writing direction of the first image data in the plurality of storage locations, a writing order of the first image data in the plurality of storage locations, and the like, for example, the target memory includes a first storage location, a second storage location, a third storage location, a fourth storage location, and a fifth storage location, the first image data may be written into the respective storage locations sequentially according to a sequentially increasing storage location ordering direction, in which case the first order is determined according to the writing direction of the first image data, when the first image data is written in, the first image data is written in sequence according to the sequence of the first storage position, the third storage position, the fifth storage position, the second storage position and the fourth storage position, and at this time, the first sequence is determined according to the writing sequence, which is not limited in this scheme.

Optionally, in this embodiment, the number of storage locations in the target memory may be equal to or greater than the number of first image data to be written, and this scheme is not limited to this.

Optionally, in this embodiment, the target memory may be an on-chip memory, or may be an external memory, such as a DDR (Double data Rate), which is not limited in this disclosure.

In the technical solution provided in step S204, the reading of the first image data at each storage location may be copying the first image data at each storage location to obtain a read result, and deleting the first image data at the storage location where the first image data is copied, so as to release the storage location. The first image data at each storage location may also be cut to obtain a reading result, and the storage location is released, which is not limited in this embodiment.

In the technical solution provided in step S206 above, the plurality of second image data are image data adjacent to the plurality of first image data, for example, if the plurality of first image data are all pixel data in the target frame, the plurality of second image data are pixel data in a frame adjacent to the target frame in the target video.

Optionally, in this embodiment, the number of the plurality of second image data may be the same as or different from the number of the plurality of first image data, and this is not limited in this embodiment.

Fig. 3 is a schematic diagram of a left-right mirroring method for an image to be flipped according to an embodiment of the present invention, which may be applied to left-right mirroring an image to be flipped in a video, as shown in fig. 3, and the method may include, but is not limited to, the following processes:

in step S301, for left and right mirrored images to be flipped, an on-chip memory may be used to perform image mirroring (or an external memory may be used to perform image mirroring), and the image mirroring is divided into three parts, i.e., on-chip write control, on-chip memory, and on-chip read control, where the size of the on-chip memory is equal to the capacity of one row of pixels in the image to be flipped. The on-chip writing control part writes a plurality of first image data (each first image data is data corresponding to one pixel) in a first row of pixels of each frame of image to be turned in a received input video stream into the on-chip memory according to a first sequence of a plurality of storage positions of the on-chip memory, and fig. 4 is a schematic diagram of writing the first image data into the on-chip memory according to the embodiment of the invention, wherein the first sequence refers to writing from a low address to a high address when the first image data is written into the on-chip memory, as shown in fig. 4, until the first image data is completely written into the on-chip memory.

In step S302, the on-chip read control section starts reading down the mth first image data written with the high address in step S301 from the on-chip memory and gradually reads the M-1 st first image data, the M-2 nd first image data, and the M-3 rd first image data … … first image data to the low address in sequence several clock cycles before the arrival of a plurality of second image data (each second image data is data corresponding to one pixel) of the second row of pixels of the image to be inverted in the input video stream.

Step S303, when a plurality of second image data of a second row of pixels of the image to be inverted in the input video stream comes, a plurality of first image data of a high address portion of the on-chip memory are already read in step S302, the storage space is released, the on-chip write control portion writes a plurality of second pixel data of the second row of pixels into the on-chip memory along a second sequence of the on-chip memory in a sequential order, fig. 5 is a schematic diagram of writing the second image data into the on-chip memory according to an embodiment of the present invention, as shown in fig. 5, the second image data are written into the on-chip memory in a sequential order from a high address to a low address until all the data of the second row are written into the on-chip memory. And repeating the above steps, wherein the data output by the on-chip reading control is the image to be turned after the left and right mirror images.

Fig. 6 is a schematic diagram of an up-down mirroring method for an image to be flipped according to an embodiment of the present invention, which may be applied to perform left-right mirroring on the image to be flipped in a video, as shown in fig. 6, the method may include, but is not limited to, the following processes:

step S601, for the image to be flipped with the upper and lower mirror images, an external memory may be used to perform image mirroring (or an on-chip memory may be used to perform image mirroring), and the image mirroring is divided into three parts, i.e., external write control, external memory, and external read control, where the external memory needs to create a BUF (buffer) with the size of the image to be flipped as the buffer for the upper and lower mirror images. The external writing control part writes a plurality of first pixel rows of a first image to be turned in the received input video stream into the external memory in a first sequence of a plurality of storage positions of the external memory, and fig. 7 is a schematic diagram of writing the first image to be turned in the external memory according to the embodiment of the invention, and as shown in fig. 7, the first sequence refers to writing in the external memory in a sequence from a low address to a high address until all the plurality of first pixel rows in the first image to be turned are written into the external memory.

In step S602, the external read control section starts reading down the nth first pixel row, in which the high address is written in step S601, from the external memory and gradually reads out the N-1 th first pixel row, the N-2 th first pixel row, and the N-3 rd first pixel row … … first pixel row to the low address in sequence several clock cycles before the second pixel rows of the second to-be-flipped image of the to-be-flipped image in the input video stream come.

Step S603, when a plurality of second pixel rows of a second to-be-flipped image of the to-be-flipped image in the input video stream come, a plurality of first pixel rows of a high address portion of the external memory are already read in step S602, the storage space is released, the external write control portion writes the plurality of second pixel rows of the second to-be-flipped image into the external memory in a sequential order along a second order of the external memory, fig. 8 is a schematic diagram of writing the second to-be-flipped image into the external memory according to an embodiment of the present invention, and as shown in fig. 8, when the second order is written into the external memory, the second pixel rows are written in a sequential order from a high address to a low address until all the second pixel rows are written into the external memory. And repeating the above steps, wherein the data output by the external reading control is the image to be turned after the upper image and the lower image are mirrored.

As an optional implementation manner, sequentially writing, according to a sequential order of the plurality of second image data, the plurality of second image data into the storage location from which the first image data has been read out along the second order includes:

judging whether a storage position of the first image data which is read out exists in the target storage;

and under the condition that the storage position of the read first image data exists in the target memory, writing the second image data into the target memory along the second sequence according to the sequence of the second image data.

Alternatively, in this embodiment, the determination of whether the storage location of the read first image data in the target memory is stored in the read first image data may be performed by detecting whether the number of the read first image data in the target storage space is greater than a set threshold, and when the number of the read first image data is greater than the set threshold, determining that the storage location of the read first image data in the target memory is present.

As an optional implementation manner, the determining whether the storage location in the target memory from which the first image data has been read out exists includes one of:

detecting whether the number of first storage positions in the target memory is larger than a target number threshold, wherein the first storage positions are storage positions where an operation of reading first image data is performed, and determining that the storage positions where the first image data is read out exist in the target memory when the number of the storage positions where the reading operation is performed in the target memory is detected to be larger than the target number threshold;

and detecting whether the second storage position in the target memory has executed the operation of reading the first image data, wherein in the case that the second storage position in the target memory has executed the operation of reading the first image data, the storage position in the target memory, from which the first image data is read, is determined to be judged to exist.

Optionally, in this embodiment, the second storage location may be any storage location in the target storage. The second storage location may be randomly selected or preset, or may be dynamically adjusted according to the read/write parameters of the target memory.

As an optional implementation manner, sequentially writing, according to a sequential order of a plurality of second image data, the plurality of second image data into the storage location from which the first image data has been read out along the second order includes:

determining a direction opposite to a first writing direction indicated by the first order as a second writing direction;

and writing the plurality of second image data into the storage position from which the first image data is read out in sequence along the second writing direction according to the sequence of the plurality of second image data.

Optionally, in this embodiment, the writing positions of the first image data and the second image data are opposite, and when the first image data with the first order among the plurality of first image data is stored in the storage position with the largest number among the plurality of storage positions, the second image data with the last order among the plurality of second data is stored in the storage position with the largest number among the plurality of storage positions.

As an optional implementation, determining the opposite direction of the first writing direction indicated by the first order as the second writing direction includes:

determining a direction from a low address to a high address of a plurality of the storage locations as the second write direction if the first write direction is a direction from a high address to a low address of the plurality of the storage locations;

and determining a direction from a high address to a low address of a plurality of the storage locations as the second writing direction, in a case where the first writing direction is a direction from a low address to a high address of the plurality of the storage locations.

Optionally, in this embodiment, each storage location uniquely corresponds to one storage address, each storage location may be sequentially arranged according to a high-low order of the storage addresses, and each storage location may also be arranged according to a random order, for example, there are four storage locations in the memory, and the storage addresses are: the storage locations may be sequentially ordered according to the order of the first storage address, the second storage address, the third storage address, and the fourth storage address, or may be sequentially ordered according to the order of the fourth storage address, the second storage address, the first storage address, and the third storage address.

As an optional implementation manner, sequentially writing the plurality of first image data before the plurality of first image data are written into the plurality of storage locations along the first order of the plurality of storage locations in the target memory according to the precedence order of the plurality of first image data, further includes:

determining the data volume included by each first image data in the plurality of first image data according to a mirror image direction, wherein the mirror image direction is used for indicating the turning mode of an image to be turned;

and acquiring image pixels meeting the data quantity from the image to be turned as a plurality of pieces of first image data.

Optionally, in this embodiment, the mirroring direction may be determined according to a recognition result of image content in the image to be flipped, or may be determined according to instruction information sent by other devices, which is not limited in this scheme.

Optionally, in this embodiment, the flipping manner may be to flip the image to be flipped in any direction, for example: the image is turned over from top to bottom, from left to right, and towards the preset angle direction of the first edge of the image to be turned over.

Optionally, in this embodiment, each of the first image data may include, but is not limited to, one or more image pixels, and the plurality of image pixels are consecutive in the image to be flipped.

As an optional implementation manner, determining the data amount included in each of the plurality of first image data according to the mirror image direction includes one of:

under the condition that the mirror image direction is used for indicating that the overturning mode of the image to be overturned is up-down overturning, determining the data quantity included in each first image data to be a row of pixels in the image to be overturned;

and under the condition that the mirror image direction is used for indicating that the overturning mode of the image to be overturned is left-right overturning, determining the data size included in each first image data as one pixel in the image to be overturned.

Optionally, in this embodiment, in a case that the mirror direction is used to indicate that the flipping manner of the image to be flipped is top-to-bottom flipping, the data amount included in each first image data may also be a column of pixels in the image to be flipped.

Alternatively, in this embodiment, a row of pixels may include a plurality of pixels arranged in series.

The process of mirroring the image data described above is illustrated and described below by way of an alternative embodiment.

Fig. 9 is a schematic diagram of a video stream mirroring process according to an alternative embodiment of the present invention, and as shown in fig. 9, a video stream requiring mirroring is divided into three parts, i.e., on-chip write control, on-chip memory, and on-chip read control, for left and right mirroring. The size of the on-chip memory is the size of a line of pixel data of a target frame in a video stream, the on-chip writing control part writes a first line of pixel data of the target frame in the received input video stream into the on-chip memory in sequence, and writes the first line of pixel data into the on-chip memory from a low address to a high address in sequence when the first line of pixel data is written into the on-chip memory until all the first line of pixel data are written into the on-chip memory; the on-chip reading control part starts to read downwards from the on-chip memory at the Mth pixel written with a high address in a plurality of clock cycles before the second line of pixel data of the input video stream target frame comes, and gradually reads the Mth-1 pixel, the Mth-2 pixel and the Mth-3 pixel … … first pixel to a low address in sequence; when the second row of pixel data of the target frame of the input video stream comes, a plurality of pixel points of the high address part of the on-chip memory are read out, the storage space is released, and the cycle is repeated, so that the data output by the on-chip reading control is the video stream after left and right mirroring; for the upper mirror image and the lower mirror image, the upper mirror image and the lower mirror image are divided into three parts, namely external write control, an external memory (such as DDR) and external read control; the external memory needs to open up a BUF with the size of one frame data to be used as the cache of the upper mirror image and the lower mirror image; the external write control part writes first frame data of the video stream into the BUF in the external memory, and writes data of a first row of pixels to an Nth row from a low address to a high address in sequence when the first frame data is written into the external memory BUF until data of the Nth row of pixels of the last row is written into the external memory BUF; when the second frame data of the input video stream come a plurality of lines, the external reading control part starts to read part of the first frame data from the external memory BUF, and when the first frame data is read, the first frame data is read downwards from the Nth line of the high address, and the pixels of the (N-1) th line, the pixels of the (N-2) th line and the pixels of the (N-3) th line … … first line are gradually read from the low address in sequence; when the second frame data of the video stream is input temporarily, the pixel values of a plurality of lines of a high address part in the external memory BUF are read out, the storage space is released, the external write control part writes the second frame data into the external memory BUF in sequence, the second frame data are written into the external memory BUF in sequence from a high address to a low address when being written into the external memory BUF, the second frame data are completely written into the external memory BUF, the steps are repeated in a circulating mode, and the data output by the external read control are the video stream after the up-down mirror image.

Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.

There is also provided in this embodiment an apparatus for mirroring image data, and fig. 10 is a block diagram of a configuration of an apparatus for mirroring image data according to an embodiment of the present invention, as shown in fig. 10, the apparatus including:

a first writing module 1002, configured to sequentially write, according to a sequence of a plurality of first image data, the plurality of first image data into a plurality of storage locations along a first sequence of the plurality of storage locations in a target memory;

a first reading module 1004, configured to sequentially read the first image data from each of the plurality of storage locations along a second order of the target memory, resulting in mirror image data of the plurality of first image data, where the second order is opposite to the first order;

a second writing module 1006, configured to sequentially write a plurality of second image data into the storage locations where the first image data has been read out along the second order according to a sequence of the plurality of second image data;

the second reading module 1008 is configured to sequentially read the second image data from each of the plurality of storage locations along the first order, so as to obtain mirror image data of the plurality of second image data.

Optionally, the second writing module includes: a judging unit configured to judge whether or not a storage location where the first image data has been read out exists in the target memory; and the first writing unit is used for sequentially writing the plurality of second image data into the target memory along the second sequence according to the sequence of the plurality of second image data under the condition that the storage position of the read first image data exists in the target memory.

Optionally, the judging unit includes one of: detecting whether the number of first storage positions in the target memory is larger than a target number threshold, wherein the first storage positions are storage positions where an operation of reading first image data is performed, and determining that the storage positions where the first image data is read out exist in the target memory when the number of the storage positions where the reading operation is performed in the target memory is detected to be larger than the target number threshold; and detecting whether the second storage position in the target memory has executed the operation of reading the first image data, wherein in the case that the second storage position in the target memory has executed the operation of reading the first image data, the storage position in the target memory, from which the first image data is read, is determined to be judged to exist.

Optionally, the second writing module includes: a determination unit configured to determine a direction opposite to a first writing direction indicated by the first order as a second writing direction; and the second writing unit is used for sequentially writing the plurality of second image data into the storage positions where the first image data are read out along the second writing direction according to the sequence of the plurality of second image data.

Optionally, the determining unit is configured to: determining a direction from a low address to a high address of a plurality of the storage locations as the second write direction if the first write direction is a direction from a high address to a low address of the plurality of the storage locations; and determining a direction from a high address to a low address of a plurality of the storage locations as the second writing direction, in a case where the first writing direction is a direction from a low address to a high address of the plurality of the storage locations.

Optionally, the apparatus further comprises: the determining module is configured to determine, according to a sequence of the plurality of first image data, a data amount included in each of the plurality of first image data according to a mirror direction before the plurality of first image data are sequentially written into the plurality of storage locations along a first sequence of the plurality of storage locations in the target memory, where the mirror direction is used to indicate a flipping manner of an image to be flipped; and the acquisition module is used for acquiring image pixels meeting the data volume from the image to be turned as a plurality of pieces of first image data.

Optionally, the determining module comprises one of: a first determining unit, configured to determine, when the mirroring direction is used to indicate that the flipping manner of the image to be flipped is top-to-bottom flipping, that a data amount included in each of the first image data is a row of pixels in the image to be flipped; and a second determining unit, configured to determine, when the mirroring direction is used to indicate that the flipping manner of the image to be flipped is left-right flipping, that the data amount included in each of the first image data is one pixel in the image to be flipped.

It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.

Embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above-mentioned method embodiments when executed.

In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.

Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.

In an exemplary embodiment, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.

For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary embodiments, and details of this embodiment are not repeated herein.

It will be apparent to those skilled in the art that the various modules or steps of the invention described above may be implemented using a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and they may be implemented using program code executable by the computing devices, such that they may be stored in a memory device and executed by the computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into various integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.

The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

19页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:脸部变换方法、装置、设备、存储介质以及产品

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!