Image data cutting method and device, electronic equipment and storage medium
By cropping and data transferring non-target areas of the image to be processed in image processing, the problem of not being able to crop across VO channels is solved, and image data cropping across VO channels is realized, ensuring the output efficiency and display effect of image data.
Patent Information
- Application Number
- CN202310945924.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-28
- Publication Date
- 2025-02-14
AI Technical Summary
The prior art cannot perform cropping operations in image data spanning multiple VO channels, resulting in the impact of display effects.
By obtaining the image to be processed, if the size of the target area is smaller than the preset threshold, the image is cropped based on the non-target area to obtain the initial cropped image, and the initial cropped image is transferred to the data according to the position data of the adjacent area and the target area. Achieve the generation of target cropped images.
Overcome the hardware's limitation on crop size, realize image data cropping across VO channels, ensure the output efficiency of image data and avoid display lag.
Smart Images

Figure CN119444781A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image data cropping method, device, electronic equipment and storage medium. Background Art
[0002] After decoding and preprocessing the encoded image, the decoder obtains the image to be processed and sends the image to be processed to the VO (Video Out) channel. When the processed image data spans multiple VO channels, such as Figure 1 As shown, the image to be processed needs to be divided into multiple blocks.
[0003] When the width of the segmented image data is small, due to the hardware limitation on the cropping size in the decoder, the width of the segmented image data cannot meet the limitation on the cropping size. Therefore, the decoder cannot perform cropping operations on the image to be processed that spans multiple VO channels, affecting the display effect of the image to be processed. Summary of the invention
[0004] The present invention provides an image data cropping method, device, electronic device and storage medium, which are used to solve the defect that cross-VO channel cropping cannot be performed in the prior art, overcome the limitation of the cropping size by hardware, and realize cross-VO channel cropping.
[0005] The present invention provides an image data clipping method, comprising:
[0006] Acquire an image to be processed, wherein the image to be processed includes a target area and a non-target area;
[0007] When the size of the target area is smaller than a preset threshold, the image to be processed is cropped based on the non-target area to obtain an initial cropped image, wherein the initial cropped image includes the target area and an adjacent area corresponding to the target area, and the size of the initial cropped image is greater than or equal to the preset threshold, and the adjacent area is located within the non-target area;
[0008] Based on the position data of the adjacent area and the target area, data of the initial cropped image is transferred to obtain a target cropped image.
[0009] According to the image data cropping method provided by the present invention, the data of the initial cropped image is transferred based on the position data of the adjacent area and the target area to obtain the target cropped image, including:
[0010] When the position data indicates that the adjacent area is on the left or upper side of the target area, the initial cropped image is transferred to a first memory to obtain transferred data, and the transferred data is transferred to a second memory to obtain the target cropped image, wherein the storage space size of the first memory is determined based on the sum of the sizes of the initial cropped image and the adjacent area, and the storage space size of the second memory is determined based on the sum of the sizes of the target area and the adjacent area;
[0011] When the position data indicates that the target area is on the left or above the adjacent area, the initial cropped image is transferred to a third memory to obtain the target cropped image, and the storage space size of the third memory is determined based on the size of the initial cropped image.
[0012] According to the image data cropping method provided by the present invention, transferring the initial cropped image to a first memory to obtain transferred data includes:
[0013] Creating a first memory based on the sum of the size of the initial cropped image and the size of the adjacent region;
[0014] Writing invalid data into the first memory, wherein the amount of the invalid data is determined based on the size of the adjacent region;
[0015] The initial cropped image is transferred to the first memory to obtain transferred data, wherein the invalid data is adjacent to a target area in the initial cropped image.
[0016] According to the image data cropping method provided by the present invention, the transferring of the transferred data to the second memory to obtain the target cropped image includes:
[0017] creating a second memory based on the sum of the sizes of the target area and the adjacent area;
[0018] The target data and the invalid data corresponding to the target area in the transferred data are written into the second memory to obtain the target cropped image.
[0019] According to the image data cropping method provided by the present invention, after transferring the transferred data to the second memory, the method further includes:
[0020] Clear the transferred data in the first memory.
[0021] According to the image data cropping method provided by the present invention, the image to be processed is cropped based on the non-target area to obtain an initial cropped image, including:
[0022] Determining a cropping position based on an edge position of the adjacent area away from the target area;
[0023] The image to be processed is cropped based on the cropping position to obtain an initial cropped image.
[0024] According to the image data cropping method provided by the present invention, the method further includes:
[0025] The target cropped image is sent to an FPGA processor, and the FPGA processor is used to perform data processing on the target cropped image, and send the target cropped image after data processing to a display device.
[0026] The present invention also provides an image data cutting device, comprising:
[0027] An acquisition module, used for acquiring an image to be processed, wherein the image to be processed includes a target area and a non-target area;
[0028] A cropping module, configured to crop the image to be processed based on the non-target area to obtain an initial cropped image when the size of the target area is smaller than a preset threshold, wherein the initial cropped image includes the target area and an adjacent area corresponding to the target area, and the size of the initial cropped image is greater than or equal to the preset threshold, and the adjacent area is located within the non-target area;
[0029] The transfer module is used to transfer the data of the initial cropped image based on the position data of the adjacent area and the target area to obtain a target cropped image.
[0030] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned image data cropping methods is implemented.
[0031] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the image data cropping method described in any one of the above is implemented.
[0032] The image data cropping method, device, electronic device and storage medium provided by the present invention can, after acquiring an image to be processed including a target area and a non-target area, crop the non-target area to make the size of the obtained initial cropped image greater than or equal to the preset threshold if the size of the target area is smaller than a preset threshold. Afterwards, data of the initial cropped image is transferred based on position data of adjacent areas and the target area in the initial cropped image to achieve secondary cropping of the initial cropped image, overcome hardware limitations on cropping size, and achieve cropping across video output channels to ensure output efficiency of image data and avoid display freezes of image data. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 It is a schematic diagram of an application scenario of an image data clipping method provided by the prior art;
[0035] Figure 2 This is one of the flowcharts of the image data cropping method provided by an embodiment of the present invention;
[0036] Figure 3 This is one of the example schematic diagrams of the image data cropping method provided by an embodiment of the present invention;
[0037] Figure 4 This is the second example schematic diagram of the image data cropping method provided by the embodiment of the present invention;
[0038] Figure 5 This is a second flow chart of the image data cropping method provided by an embodiment of the present invention;
[0039] Figure 6 is a structural schematic diagram of an image data cropping device provided by an embodiment of the present invention;
[0040] Figure 7 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] Figure 1 is a schematic diagram of an application scenario of an image data clipping method provided by the prior art, such as Figure 1As shown, the TV wall 1 includes 4 VO channels, the image to be processed is in the middle of the TV wall 1, spanning the 4 VO channels, and the 4 VO channels divide the image to be processed into 4 blocks, namely, area VO1, area VO2, area VO3 and area VO4, that is, the image to be processed is obtained by splicing area VO1, area VO2, area VO3 and area VO4. When the image to be processed is decoded and preprocessed and then cropped, due to the minimum limit on the cropping size by the decoding chip (such as RK3568, RK3588) or TDE (TWO Dimensional Engine) module on the decoder, when the size of any area in the image to be processed is less than the minimum limit, the cross-VO channel cropping cannot be achieved, which results in the inability to output the image normally in a specific scene, or the problem of video freeze caused by switching to CPU or GPU processing.
[0043] In view of the above problems, an embodiment of the present invention provides an image data cropping method. Figure 2 FIG. 1 is a flow chart of an image data cropping method provided by an embodiment of the present invention. Figure 2 As shown, the method includes:
[0044] Step 210: Acquire an image to be processed, where the image to be processed includes a target area and a non-target area.
[0045] Specifically, the image data cropping method provided in the embodiment of the present invention is applied to the cropping process of image data across VO (VideoOut, video output) channels in a decoder.
[0046] Optionally, the size of the image to be processed obtained above is greater than or equal to a preset threshold for limiting the size of image cropping in the decoder. Taking the image to be processed including area VO1 and area VO2 as an example, the image to be processed is divided into a non-target area and a target area, and the non-target area and the target area are adjacent and mutually exclusive, wherein: area VO1 is a non-target area, and area VO2 is a target area, that is, the image displayed after cropping the image to be processed is the image corresponding to area VO2.
[0047] Optionally, the above-mentioned image to be processed may be obtained by dividing video data into frames.
[0048] Step 220: When the size of the target area is smaller than a preset threshold, the image to be processed is cropped based on the non-target area to obtain an initial cropped image, wherein the initial cropped image includes the target area and an adjacent area corresponding to the target area, and the size of the initial cropped image is greater than or equal to the preset threshold, and the adjacent area is located within the non-target area.
[0049] Specifically, the above size can be the width or height of the image. When the size of the target area is smaller than the preset threshold, the target area is supplemented and cropped based on the non-target area, so that the size of the cropped initial cropped image is greater than or equal to the preset threshold, and the initial cropped image includes the target area and the adjacent area of the target area, and the adjacent area is in the non-target area, which preliminarily overcomes the size limitation of the image cropping by the hardware in the decoder.
[0050] Optionally, the cropping the image to be processed based on the non-target area to obtain an initial cropped image includes:
[0051] determining an adjacent area of the target area in the non-target area;
[0052] Determining a cropping position based on an edge position of the adjacent area away from the target area;
[0053] The image to be processed is cropped based on the cropping position to obtain an initial cropped image.
[0054] Specifically, when cropping the image to be processed, an adjacent area is determined in the non-target area starting from the adjacent positions of the non-target area and the target area, and the target area is supplemented by the adjacent area to meet the preset threshold of the image cropping of the hardware in the decoder. After determining the adjacent area, the cropping position is determined according to the edge position of the adjacent area away from the target area, and the image to be processed is cropped according to the cropping position to obtain an initial cropped image, which preliminarily overcomes the size limitation of the image cropping by the hardware in the decoder.
[0055] For example, the image to be processed includes area VO1 and area VO2, area VO1 is a non-target area, area VO2 is a target area, area VO1 is on the left of area VO2, and the preset threshold is 128 columns. The width of area VO1 is 300, and the width of area VO2 is 110 columns. In the prior art, since the width of area VO2 is less than the preset threshold, the decoder in the prior art cannot perform a cropping operation on the image to be processed. In the embodiment of the present invention, Figure 3 is one of the exemplary schematic diagrams of the image data cropping method provided by the embodiment of the present invention. Figure 3As shown, starting from the adjacent position of the area VO1 and the area VO2, an adjacent area A with a width of 18 columns is determined in the area VO1, and taking the left coordinate of the area VO1 as a reference, that is, taking the left coordinate of the area VO1 as (0,0) as an example, it can be determined that the edge position coordinate of the adjacent area A away from the target area VO2 is (282,0), and the edge position is determined as the cropping position. The image to be processed is cropped according to the cropping position to obtain an initial cropped image, which has a width of 128 columns and is composed of images corresponding to the adjacent area A with a width of 18 columns and the area VO2 with a width of 110 columns.
[0056] For example, Figure 4 FIG. 2 is a second example schematic diagram of the image data cropping method provided by an embodiment of the present invention. Figure 4 As shown, the image to be processed includes region VO3 and region VO4, region VO3 is the target region, region VO4 is the non-target region, region VO3 is on the left side of region VO4, and the preset threshold is 128 columns. For example, the width of region VO3 is 110 columns, and the width of region VO4 is 300 columns. In the prior art, since the width of region VO3 is less than the preset threshold, the decoder cannot perform a cropping operation on the image to be processed. In the embodiment of the present invention, starting from the adjacent position of region VO3 and region VO4, an adjacent region C with a width of 18 columns is determined in region VO4. Taking the left coordinate of region VO3 as a reference, that is, taking the left coordinate of region VO3 as (0,0) as an example, the edge position coordinate of adjacent region C away from target region VO3 can be determined as (128,0), and the edge position is determined as the cropping position. The image to be processed is cropped according to the cropping position to obtain an initial cropped image. The initial cropped image has a width of 128 columns and is composed of an image corresponding to region VO3 with a width of 110 columns and an adjacent region C with a width of 18 columns.
[0057] It should be noted that when the size is width, the column can be used as the unit of image data, and when the size is height, the row can be used as the unit of image data.
[0058] Step 230: Based on the position data of the adjacent area and the target area, transfer the data of the initial cropped image to obtain a target cropped image.
[0059] Specifically, after the initial cropped image is determined, the number of times the data of the initial cropped image is transferred is determined based on the position data of the adjacent area and the target area, that is, the adjacent area is on the left or upper side of the target area, or the adjacent area is on the right or lower side of the target, so as to obtain the target cropped image.
[0060] Optional, Figure 5 FIG. 2 is a flow chart of the image data cropping method provided by an embodiment of the present invention. Figure 5 As shown, the method also includes:
[0061] The target cropped image is sent to an FPGA processor, and the FPGA processor is used to perform data processing on the target cropped image, and send the target cropped image after data processing to a display device.
[0062] Specifically, after receiving the encoded image, the decoder decodes the encoded image through the VDEC (Video decoding) module to obtain decoded image data, pre-processes the decoded image data through the VPSS (Video Process Sub-System) to obtain the image to be processed, and outputs the image to be processed to the VO (Video Out) channel. After cropping and data transfer in the TDE module, the target cropped image is obtained. After determining the target cropped image, since the target cropped image may also include invalid data, the target cropped data needs to be sent to the FPGA (Field Programmable Gate Array) processor for data processing. The FPGA processor can clear the invalid data in the target cropped image and improve the display effect of the target cropped image after it is displayed.
[0063] It should be noted that the VDEC module is used to decode video data, and the supported formats may include H264, h265, and jpeg, etc. VPSS supports unified preprocessing of input images, such as denoising and deinterlacing, and then performs scaling and sharpening on each output channel, and finally outputs images of multiple resolutions.
[0064] Optionally, transferring data of the initial cropped image based on the position data of the adjacent area and the target area to obtain a target cropped image includes:
[0065] When the position data indicates that the adjacent area is on the left or upper side of the target area, the initial cropped image is transferred to a first memory to obtain transferred data, and the transferred data is transferred to a second memory to obtain the target cropped image, the storage space size of the first memory is determined based on the sum of the sizes of the initial cropped image and the adjacent area, and the storage space size of the second memory is determined based on the sum of the sizes of the target area and the adjacent area.
[0066] When the position data indicates that the target area is on the left or above the adjacent area, the initial cropped image is transferred to a third memory to obtain the target cropped image, and the storage space size of the third memory is determined based on the size of the initial cropped image.
[0067] Specifically, after determining the target cropped image, the target cropped image needs to be sent to the FPGA processor for data processing. Since the FPGA processor is limited by resources, it cannot process invalid data on the left or upper side of the target area, and can only process invalid data on the right or lower side of the target area. Therefore, it is necessary to perform subsequent processing according to the position data of the adjacent area and the target data. That is, when the adjacent area is on the left or upper side of the target data, the initial cropped image is transferred to the first memory in the decoder to obtain the transferred data, and based on the size of the adjacent area, part of the transferred data is transferred to the second memory to obtain the target cropped image, which includes the target area and the invalid data on the right or lower side of the target area. When the target data is on the left or upper side of the adjacent area, after the initial cropped image is transferred to the third memory, the adjacent area in the initial cropped image is on the right or lower side of the target area, and the adjacent area is regarded as invalid data for the target area. After the target cropped image is sent to the FPGA processor, the target cropped image can be directly processed without secondary transfer.
[0068] In addition, after the initial cropped image is transferred to the first memory or the third memory, the TDE module can crop the next frame of the image to be processed, optimize the image data cropping process, and improve the processing efficiency.
[0069] It should be noted that, in the image to be processed, when the non-target area and the target area are distributed left and right, the cropping direction of the image to be processed is up and down; when the non-target area and the target area are distributed up and down, the cropping direction of the image to be processed is left and right.
[0070] When the non-target area and the target area are distributed left and right and the adjacent area is on the left side of the target area, the initial cropped image is transferred to the first memory to obtain the transferred data, and the transferred data is transferred to the second memory to obtain the target cropped image, the storage space size of the first memory is determined based on the sum of the widths of the initial cropped image and the adjacent area, and the storage space size of the second memory is determined based on the sum of the widths of the target area and the adjacent area. When the non-target area and the target area are distributed left and right and the target area is on the left side of the adjacent area, the initial cropped image is transferred to the third memory to obtain the target cropped image, and the storage space size of the third memory is determined based on the width of the initial cropped image.
[0071] In addition, when the non-target area and the target area are distributed up and down and the adjacent area is on the upper side of the target area, the initial cropped image is transferred to the first memory to obtain the transferred data, and the transferred data is transferred to the second memory to obtain the target cropped image, the storage space size of the first memory is determined based on the sum of the heights of the initial cropped image and the adjacent area, and the storage space size of the second memory is determined based on the sum of the heights of the target area and the adjacent area. When the non-target area and the target area are distributed up and down and the target area is on the upper side of the adjacent area, the initial cropped image is transferred to the third memory to obtain the target cropped image, and the storage space size of the third memory is determined based on the height of the initial cropped image.
[0072] Optional, such as Figure 3 As shown, the transferring of the initial cropped image to the first memory to obtain the transferred data includes:
[0073] Creating a first memory based on the sum of the size of the initial cropped image and the size of the adjacent region;
[0074] Writing invalid data into the first memory, wherein the amount of the invalid data is determined based on the size of the adjacent region;
[0075] The initial cropped image is transferred to the first memory to obtain transferred data, wherein the invalid data is adjacent to a target area in the initial cropped image.
[0076] Specifically, before transferring the initial cropped image, a first memory needs to be created first. Since the adjacent area is on the left or upper side of the initial cropped image, invalid data needs to be added to the right or lower side of the initial cropped image. Therefore, an empty first memory is created according to the sum of the sizes of the initial cropped image and the adjacent area, and after the first memory is created, invalid data is written, and the invalid data can be all 0 data. After writing the data, the initial cropped image is transferred to the first memory, so that the invalid data is on the right or lower side of the target area, and the amount of invalid data is equal to the amount of data in the adjacent area, and the transferred data is obtained.
[0077] In addition, the initial cropped image may be first transferred to the first memory, and then invalid data may be added to the right or bottom of the target area. The embodiment of the present invention does not restrict the writing order of the initial cropped image and invalid data, and ensures that the written invalid data is on the right or bottom of the target area.
[0078] For example, Figure 3As shown, after obtaining the initial cropped image, a first empty memory with a width of 146 columns is created, and invalid data B with a width of 18 columns is written into the first memory. After that, the initial cropped image is written into the first memory, and the invalid data B is placed on the right or bottom side of the target area VO2, and the width of the invalid data B is equal to the width of the adjacent area A.
[0079] Optional, such as Figure 3 As shown, the transferring the transferred data to the second memory to obtain the target cropped image includes:
[0080] creating a second memory based on the sum of the sizes of the target area and the adjacent area;
[0081] The target data and the invalid data corresponding to the target area in the transferred data are written into the second memory to obtain the target cropped image.
[0082] Specifically, after obtaining the transferred data, the TDE module in the decoder writes the target data corresponding to the target area in the transferred data and the invalid data on the right or bottom side of the target area into the second memory, thereby obtaining the target cropped image, which facilitates sending the target cropped image to the FPGA for data processing.
[0083] For example, Figure 3 As shown, when the position data is that the adjacent area is on the left or upper side of the target area, and the transferred data is obtained, the FPGA processor is limited by resources and cannot process the invalid data on the left or upper side of the target area, and can only process the invalid data on the right or lower side of the target area. At the same time, the TDE module has a size limit on the data to be transferred, and the size limit is determined by the preset threshold corresponding to the decoder. Therefore, a second memory with a width of 128 columns is created. Since the width of area A is 18 columns, the data of area VO2 and area B are transferred to the second memory based on the left coordinate of area A, starting from the coordinate (18,0), to obtain the target cropped image. Since the invalid data corresponding to area B is on the right or lower side of area VO2, after the target cropped image is sent to the FPGA processor, the FPGA processor can automatically process the invalid data of area B to obtain the target image of area VO2, and send the target image to the display device for display. After the transferred data in the first memory is transferred to the second memory, the transferred data in the first memory can be cleared, so that the first memory can receive the initial cropped image corresponding to the next frame of the image to be processed. In addition, after the target cropped image in the second memory is sent to the FPGA processor and displayed, the target cropped image in the second memory can be cleared to facilitate receiving the target cropped image corresponding to the next frame of image to be processed, so as to improve processing efficiency and avoid video freeze.
[0084] For example, Figure 4 As shown, when the position data indicates that the adjacent area is on the right or lower side of the target area and the initial cropped image is obtained, a third memory with a width of 128 columns is created, and the data of area VO3 and area C are transferred to the third memory to obtain the target cropped image. Since the data corresponding to area C is on the right or lower side of area VO2, and area C is regarded as invalid data relative to area VO2, after the target cropped image is sent to the FPGA processor, the FPGA processor can automatically process the data of area C to obtain the target image of area VO3, and send the target image to the display device for display, breaking through the hardware limitation on the cropping size, and realizing the rapid cropping of the image to be processed, thereby achieving the purpose of rapid cropping of arbitrary coordinates. At the same time, without affecting the startup speed, the storage device and CPU overhead are saved. After the target cropped image is sent to the FPGA processor, the data in the third memory can be cleared, so that the third memory can receive the initial cropped image corresponding to the next frame of the image to be processed, improve the processing efficiency, and avoid video freeze.
[0085] Optionally, after transferring the transferred data to the second memory, the method further includes:
[0086] Clear the transferred data in the first memory.
[0087] Specifically, after the transferred data is transferred to the second memory, the transferred data in the first memory can be cleared to facilitate the transfer of the initial cropped image corresponding to the next frame of image to be processed to the first memory, so as to optimize the data cropping process, realize parallel processing of multiple frames of image to be processed, improve processing efficiency, ensure normal image output, and avoid video freezes.
[0088] The image data cropping method provided by the embodiment of the present invention can, after acquiring an image to be processed including a target area and a non-target area, if the size of the target area is smaller than a preset threshold, crop the non-target area to make the size of the obtained initial cropped image greater than or equal to the preset threshold, and then transfer the data of the initial cropped image according to the position data of the adjacent areas and the target area in the initial cropped image to achieve secondary cropping of the initial cropped image, overcome the hardware limitation on the cropping size, and achieve fast cropping across video output channels to ensure the output efficiency of the image data and avoid display jams of the image data.
[0089] The image data cropping device provided by the present invention is described below. The image data cropping device described below and the image data cropping method described above can be referred to each other.
[0090] The embodiment of the present invention further provides an image data cutting device, Figure 6 is a schematic diagram of the structure of an image data cropping device provided by an embodiment of the present invention. Figure 6As shown, the image data cropping device 600 includes: an acquisition module 610, a cropping module 620 and a transfer module 630, wherein:
[0091] An acquisition module 610 is used to acquire an image to be processed, where the image to be processed includes a target area and a non-target area;
[0092] A cropping module 620 is used to crop the image to be processed based on the non-target area to obtain an initial cropped image when the size of the target area is smaller than a preset threshold, wherein the initial cropped image includes the target area and an adjacent area corresponding to the target area, and the size of the initial cropped image is greater than or equal to the preset threshold, and the adjacent area is located in the non-target area;
[0093] The transfer module 630 is used to transfer the data of the initial cropped image based on the position data of the adjacent area and the target area to obtain a target cropped image.
[0094] The image data cropping device provided by the present invention, after acquiring an image to be processed including a target area and a non-target area, if the size of the target area is smaller than a preset threshold, can crop the non-target area to make the size of the obtained initial cropped image greater than or equal to the preset threshold, and then, according to the position data of the adjacent area and the target area in the initial cropped image, transfer the data of the initial cropped image to achieve secondary cropping of the initial cropped image, overcome the hardware limitation on the cropping size, and achieve fast cropping across video output channels to ensure the output efficiency of image data and avoid display jams of image data.
[0095] Optionally, the transfer module 630 is specifically used for:
[0096] When the position data indicates that the adjacent area is on the left or upper side of the target area, the initial cropped image is transferred to a first memory to obtain transferred data, and the transferred data is transferred to a second memory to obtain the target cropped image, wherein the storage space size of the first memory is determined based on the sum of the sizes of the initial cropped image and the adjacent area, and the storage space size of the second memory is determined based on the sum of the sizes of the target area and the adjacent area;
[0097] When the position data indicates that the target area is on the left or above the adjacent area, the initial cropped image is transferred to a third memory to obtain the target cropped image, and the storage space size of the third memory is determined based on the size of the initial cropped image.
[0098] Optionally, the transfer module 630 is specifically used for:
[0099] Creating a first memory based on the sum of the size of the initial cropped image and the size of the adjacent region;
[0100] Writing invalid data into the first memory, wherein the amount of the invalid data is determined based on the size of the adjacent region;
[0101] The initial cropped image is transferred to the first memory to obtain transferred data, wherein the invalid data is adjacent to a target area in the initial cropped image.
[0102] Optionally, the transfer module 630 is specifically used for:
[0103] creating a second memory based on the sum of the sizes of the target area and the adjacent area;
[0104] The target data and the invalid data corresponding to the target area in the transferred data are written into the second memory to obtain the target cropped image.
[0105] Optionally, the image data cropping device further includes a clearing module, and the clearing module is specifically used to clear the transferred data in the first memory.
[0106] Optionally, the cutting module 620 is specifically used for:
[0107] Determining a cropping position based on an edge position of the adjacent area away from the target area;
[0108] The image to be processed is cropped based on the cropping position to obtain an initial cropped image.
[0109] Optionally, the image data cropping device further includes a sending module, and the sending module is specifically used for:
[0110] The initial cropped image is sent to an FPGA processor, and the FPGA processor is used to perform data processing on the initial cropped image and send the initial cropped image after data processing to a display device.
[0111] Figure 7 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the image data cropping method, which includes:
[0112] Acquire an image to be processed, wherein the image to be processed includes a target area and a non-target area;
[0113] When the size of the target area is smaller than a preset threshold, the image to be processed is cropped based on the non-target area to obtain an initial cropped image, wherein the initial cropped image includes the target area and an adjacent area corresponding to the target area, and the size of the initial cropped image is greater than or equal to the preset threshold, and the adjacent area is located within the non-target area;
[0114] Based on the position data of the adjacent area and the target area, data of the initial cropped image is transferred to obtain a target cropped image.
[0115] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0116] On the other hand, the present invention further provides a computer program product, the computer program product comprising a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the image data cropping method provided by the above methods, the method comprising:
[0117] Acquire an image to be processed, wherein the image to be processed includes a target area and a non-target area;
[0118] When the size of the target area is smaller than a preset threshold, the image to be processed is cropped based on the non-target area to obtain an initial cropped image, wherein the initial cropped image includes the target area and an adjacent area corresponding to the target area, and the size of the initial cropped image is greater than or equal to the preset threshold, and the adjacent area is located within the non-target area;
[0119] Based on the position data of the adjacent area and the target area, data of the initial cropped image is transferred to obtain a target cropped image.
[0120] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the image data cropping method provided by the above methods is implemented, and the method includes:
[0121] Acquire an image to be processed, wherein the image to be processed includes a target area and a non-target area;
[0122] When the size of the target area is smaller than a preset threshold, the image to be processed is cropped based on the non-target area to obtain an initial cropped image, wherein the initial cropped image includes the target area and an adjacent area corresponding to the target area, and the size of the initial cropped image is greater than or equal to the preset threshold, and the adjacent area is located within the non-target area;
[0123] Based on the position data of the adjacent area and the target area, data of the initial cropped image is transferred to obtain a target cropped image.
[0124] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0125] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0126] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for cropping image data, characterized in that: include: Acquire an image to be processed, wherein the image to be processed includes a target area and a non-target area; When the size of the target area is smaller than a preset threshold, the image to be processed is cropped based on the non-target area to obtain an initial cropped image, wherein the initial cropped image includes the target area and an adjacent area corresponding to the target area, and the size of the initial cropped image is greater than or equal to the preset threshold, and the adjacent area is located within the non-target area; Based on the position data of the adjacent area and the target area, data of the initial cropped image is transferred to obtain a target cropped image.
2. The image data cropping method according to claim 1, characterized in that: The step of transferring data of the initial cropped image based on the position data of the adjacent area and the target area to obtain a target cropped image includes: When the position data indicates that the adjacent area is on the left or upper side of the target area, the initial cropped image is transferred to a first memory to obtain transferred data, and the transferred data is transferred to a second memory to obtain the target cropped image, wherein the storage space size of the first memory is determined based on the sum of the sizes of the initial cropped image and the adjacent area, and the storage space size of the second memory is determined based on the sum of the sizes of the target area and the adjacent area; When the position data indicates that the target area is on the left or above the adjacent area, the initial cropped image is transferred to a third memory to obtain the target cropped image, and the storage space size of the third memory is determined based on the size of the initial cropped image.
3. The image data cropping method according to claim 2, characterized in that: The transferring the initial cropped image to the first memory to obtain the transferred data includes: Creating a first memory based on the sum of the size of the initial cropped image and the size of the adjacent region; Writing invalid data into the first memory, wherein the amount of the invalid data is determined based on the size of the adjacent region; The initial cropped image is transferred to the first memory to obtain transferred data, wherein the invalid data is adjacent to a target area in the initial cropped image.
4. The image data cropping method according to claim 3, characterized in that: The transferring the transferred data to the second memory to obtain the target cropped image includes: creating a second memory based on the sum of the sizes of the target area and the adjacent area; The target data and the invalid data corresponding to the target area in the transferred data are written into the second memory to obtain the target cropped image.
5. The image data cropping method according to any one of claims 2 to 4, characterized in that: After transferring the transferred data to the second memory, the method further includes: Clear the transferred data in the first memory.
6. The image data cropping method according to any one of claims 1 to 4, characterized in that: The step of cropping the image to be processed based on the non-target area to obtain an initial cropped image includes: Determining a cropping position based on an edge position of the adjacent area away from the target area; The image to be processed is cropped based on the cropping position to obtain an initial cropped image.
7. The image data cropping method according to any one of claims 1 to 4, characterized in that: The method further comprises: The target cropped image is sent to an FPGA processor, and the FPGA processor is used to perform data processing on the target cropped image, and send the target cropped image after data processing to a display device.
8. An image data cutting device, characterized in that: include: An acquisition module, used for acquiring an image to be processed, wherein the image to be processed includes a target area and a non-target area; A cropping module, configured to crop the image to be processed based on the non-target area to obtain an initial cropped image when the size of the target area is smaller than a preset threshold, wherein the initial cropped image includes the target area and an adjacent area corresponding to the target area, and the size of the initial cropped image is greater than or equal to the preset threshold, and the adjacent area is located within the non-target area; The transfer module is used to transfer the data of the initial cropped image based on the position data of the adjacent area and the target area to obtain a target cropped image.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the image data cropping method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image data cropping method according to any one of claims 1 to 7 is implemented.