Target boundary determination method, computer device and storage medium
By using macroblock code stream information to select boundary macroblocks in the image, the boundary of the target object is directly determined, which solves the problems of high complexity, long time consumption and inaccuracy in boundary extraction in the existing technology, and achieves efficient and accurate boundary extraction. and real-time detection.
Patent Information
- Application Number
- CN202010674498.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-14
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2040-07-14
AI Technical Summary
When extracting the boundary of a target object in an image, the existing technology requires direct processing of the original data, which results in a large amount of calculation, long time consumption, poor real-time performance, and inaccurate obtained boundaries.
By obtaining the macroblock code stream information of the target image frame, select the boundary macroblock that meets the boundary code stream requirements, determine the boundary of the target object, and directly use the encoded macroblock code stream information to perform boundary extraction, reducing complexity and time-consuming.
It improves the extraction efficiency and accuracy of the target object boundary, realizes real-time detection and extraction, and reduces the problem of boundary desynchronization.
Smart Images

Figure CN112004090B
Abstract
Description
Technical Field
[0001] The present application relates to the field of coding and decoding technology, and in particular to a method for determining a target boundary, a computer device, and a computer-readable storage medium. Background Art
[0002] Boundary extraction of target objects refers to separating the target object from the background in the image to determine the location of the target object or track the target object. Target boundary extraction is increasingly used in more application scenarios such as security and transportation. At present, the target boundary extraction method needs to directly process the original data of the image, such as using various boundary extraction algorithms to detect the target boundary in the original data of the image. The calculation is large, time-consuming, and has poor real-time performance, and the target boundary obtained is inaccurate. Summary of the invention
[0003] The present application provides a target boundary determination method, a computer device and a storage medium, which can improve the accuracy of obtaining the boundary of a target object with low complexity and less time consumption.
[0004] In order to solve the above technical problems, a technical solution adopted by the present application is to provide a method for determining a target boundary. The method includes: obtaining code stream information of each macroblock in a target image frame; selecting a boundary macroblock whose code stream information meets the boundary code stream requirements from the target image frame; and determining the boundary of the target object in the target image frame based on the selected boundary macroblock.
[0005] To solve the above technical problem, another technical solution adopted by the present application is to provide a computer device, which includes a processor and a memory, wherein the memory is used to store a computer program, and the computer program is executed by the processor to implement the above target boundary determination method.
[0006] To solve the above technical problem, another technical solution adopted by the present application is to provide a computer-readable storage medium. The computer-readable storage medium stores a computer program, which is executed by a processor to implement the above target boundary determination method.
[0007] The beneficial effects of the present application are as follows: the present application obtains the code stream information of the macroblocks after encoding the target image frame, and selects the boundary macroblocks whose code stream information meets the boundary code stream requirements according to the characteristics of the code stream information of the boundary macroblocks to determine the boundary of the target object in the target image frame. Compared with determining the target boundary by analyzing the original data of the image, the present application directly uses the code stream information of the macroblocks of the target image frame to determine the boundary of the target object. The process has low complexity and low time consumption, thereby improving the efficiency of extracting the boundary of the target object, and has good real-time performance for real-time detection and extraction of the target boundary. At the same time, compared with obtaining the boundary of the target object by segmenting the image in the image, the present application selects the boundary macroblocks according to the characteristics of the macroblock code stream information, thereby improving the accuracy of obtaining the boundary of the target object. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0009] Figure 1 is a flowchart of a first embodiment of a method for determining a target boundary provided by the present application;
[0010] Figure 2 This application provides Figure 1 Schematic diagram of the process of step S120;
[0011] Figure 3 This application provides Figure 1 Schematic diagram of the process of step S130;
[0012] Figure 4 is a flow chart of a second embodiment of the target boundary determination method provided by the present application;
[0013] Figure 5 is a flowchart of a third embodiment of the target boundary determination method provided by the present application;
[0014] Figure 6 is a schematic diagram of the structure of the target boundary determination device provided by the present application;
[0015] Figure 7 It is a structural schematic diagram of a computer device provided by this application;
[0016] Figure 8 It is a schematic diagram of the structure of the computer-readable storage medium provided in this application. DETAILED DESCRIPTION
[0017] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0018] The terms "first", "second", and "third" in this application are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first", "second", and "third" can expressly or implicitly include at least one of the features. In the description of this application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In the embodiments of this application, all directional indications (such as up, down, left, right, front, back...) are only used to explain the relative position relationship, movement, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication also changes accordingly. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products, or devices.
[0019] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments without conflict.
[0020] After long-term research by the applicant of this application, it was found that in the prior art, when determining the boundary of a target object in an image, or determining the boundary of a moving target object in a video, the original data of the image frame of the image or video is generally directly analyzed, and a certain boundary algorithm is used to find the boundary of the target object. If the precise boundary of the target object needs to be found, it takes a lot of time and it is generally difficult to meet real-time requirements.
[0021] In order to solve the above problems, the present application provides the following embodiments, and each embodiment of the present application is described below.
[0022] See also Figure 1 , Figure 1 : is a flow chart of a first embodiment of a method for determining a target boundary provided by the present application, the method comprising the following steps:
[0023] S110: Obtaining code stream information of each macroblock in the target image frame.
[0024] The target image or target image frame of the video can be encoded to obtain the code stream information of the encoded image of the target image frame, wherein the encoded code stream type may include standard encoding or non-standard encoding, for example, the standard encoding code stream type may be H.264 / H.265 / H.266, SVAC1 / SVAC2, AVS1 / AVS2 / AVS3, VP8 / VP9 / AV1, etc., and this application does not impose any restrictions on this.
[0025] The coded image of the target image frame is divided into a number of macroblocks (MB) to obtain the code stream information of each macroblock in the target image frame. The basic size of the macroblock can be consistent with the basic coding macroblock size of the corresponding coding code stream type. For example, for the H.264 coding standard, the coding macroblock size can be 16*16, and for the H.265 coding standard, the coding macroblock size can be 64*64. This application does not limit this.
[0026] The bitstream information of the macroblock includes one or a combination of a quantization parameter value, a residual value, a number of bits after encoding, temporal texture complexity, spatial texture complexity, a maximum partition depth, and a number of sub-blocks included. Of course, it can be understood that the bitstream information of the macroblock of the present application can also be other available bitstream information, and the present application does not limit it here.
[0027] Specifically, the quantization parameter (QP) of a macroblock reflects the compression of spatial details of the target image frame. If the QP value is small, most of the details of the target image frame will be retained; if the QP value increases, some details of the target image frame will be lost, the bit rate will be reduced, and image distortion and quality degradation will occur. In addition, due to the correlation between adjacent pixels in the same target image frame, intra-frame prediction and inter-frame prediction are used to compress the encoded data, and the difference between the predicted value and the actual sampled value is used as the residual value. In addition, the temporal texture complexity and spatial texture complexity of the macroblock can be the complexity of the texture information, texture features, etc. of the target image frame in the temporal and spatial domains.
[0028] The coded image is divided into several macroblocks, and the macroblocks of the target image frame can be further divided. For example, a macroblock can be a coding tree unit (CTU), and a coding tree unit consists of a luminance coding tree block (CTB) and two additional chrominance pixel blocks. The depth of the coding tree unit can be used as the maximum division depth of the macroblock, and the number of sub-blocks contained in the coding tree unit can be used as the number of sub-blocks contained in the macroblock.
[0029] S120: Selecting, from the target image frame, a boundary macroblock whose bitstream information meets the boundary bitstream requirement.
[0030] The code stream information includes at least one code stream information that can reflect the difference between the boundary and the non-boundary of the target object in the target image frame. Due to the difference in code stream characteristics between the code stream information of the target object at the boundary and the code stream information of the non-boundary in the target image frame, the boundary and the non-boundary of the target object can be distinguished according to the code stream information.
[0031] In some embodiments, due to the consistency of the code stream characteristics of the boundary of the target object, the code stream information of the macroblocks at the boundary position of the target object in the target image frame is similar. The code stream information of the macroblocks in the boundary area will be relatively small, and the code stream information of the macroblocks in the non-border area will be relatively large. The non-border area can be a flat area of the target object in the image frame. Therefore, the code stream information of the boundary macroblocks can be divided to determine the boundary macroblocks of the target object at the boundary according to the code stream information. For example, when the code stream information is a quantization parameter, the quantization parameter value of the macroblocks in the boundary area is relatively small relative to the non-border area. The boundary macroblocks of the target object at the boundary can be determined based on the difference between the code stream information of the macroblocks in the boundary area and the code stream information of the macroblocks in the non-border area.
[0032] In some embodiments, the bitstream information of the macroblock in the boundary area is larger than the bitstream information in the non-boundary area. For example, when the bitstream information is any one of the residual value, the number of bits after encoding, the temporal texture complexity, the spatial texture complexity, the maximum division depth or the number of sub-blocks included, the boundary of the target object in the target image frame can be distinguished due to the difference between the bitstream information of the boundary area and the bitstream information of the non-boundary area.
[0033] In some embodiments, the boundary code stream requirement is that at least one code stream information of the boundary macroblock satisfies: the code stream information is located in the target numerical region of the corresponding code stream information distribution in the target image frame, wherein the target numerical region is: the code stream information distribution is divided into two numerical regions according to the numerical value, wherein any numerical region may be the target numerical region. For example, the code stream information distribution is divided into two numerical regions according to the numerical value, wherein the numerical region with a larger value is the upper value region, wherein the numerical region with a smaller value is the lower value region, thereby distinguishing the macroblocks of the code stream information in the boundary region, if the target numerical region is the upper value region, then the macroblocks in the upper value region are determined to be boundary macroblocks, and if the target numerical region is the lower value region, then the macroblocks in the lower value region are determined to be boundary macroblocks.
[0034] In some embodiments, for the above step S120, please refer to Figure 2 , the step S120 includes the following steps:
[0035] S121: Taking at least two types of code stream information as target code stream information.
[0036] The bitstream information of the macroblock including any at least two of the quantization parameter value, the residual value, the number of bits after encoding, the temporal texture complexity, the spatial texture complexity, the maximum division depth, and the number of sub-blocks included can be used as the target bitstream information. For example, the quantization parameter value and the number of bits after encoding can be used as the target bitstream information, or all the bitstream information can be used as the target code information, and the present application does not impose any restrictions on this.
[0037] S122: traverse each macroblock in the target image frame to detect whether each target code stream information of the macroblock meets a preset condition.
[0038] The preset condition is that the difference between the maximum value of each target code stream information in the target image frame and the target code stream information of the macroblock is greater than or less than the reference threshold corresponding to the target code stream information. Since the code stream information of the macroblocks in the boundary area is greatly different from the maximum value of the code stream information in the target image frame, while the code stream information of the macroblocks in the flat area is less different from the maximum value of the code stream information in the target image frame, by traversing each macroblock in the target image frame, the macroblocks whose difference between the maximum value of the target code stream information in the target image frame and each target code stream information of the macroblock is greater than or less than the reference threshold corresponding to the target code stream information are detected, so that the macroblocks that meet the preset condition are determined as boundary macroblocks.
[0039] When the target code stream information includes a quantization parameter, since the quantization parameter value of the macroblock in the boundary area is smaller than that of the non-boundary area, the lower value area of the smaller value is the target value area, and the macroblock in the lower value area is determined to be the boundary macroblock. The preset condition may be that the difference between the maximum value of the target code stream information in the target image frame and the target code stream information of the macroblock is greater than the reference threshold corresponding to the target code stream information.
[0040] When the target code stream information includes any one of the residual value, the number of bits after coding, the temporal texture complexity, the spatial texture complexity, the maximum partition depth or the number of sub-blocks included, since the code stream information of the macroblock in the boundary area is larger than the code stream information in the non-boundary area, the upper value area of the larger value is the target value area, and the macroblock in the upper value area is determined to be the boundary macroblock. The preset condition may be that the difference between the maximum value of the target code stream information in the target image frame and the target code stream information of the macroblock is less than the reference threshold corresponding to the target code stream information.
[0041] In some embodiments, the reference threshold corresponding to the target code stream information is: the average value or the middle value between the maximum value and the minimum value of the target code stream information in the target image frame. Specifically, the average value between the maximum value and the minimum value of the target code stream information in the target image frame can be used as the reference threshold corresponding to the target code stream information. In addition, the middle value of the target code stream information in the target image frame can also be used as the reference threshold corresponding to the target code stream information. Of course, corresponding appropriate reference thresholds can also be obtained for application scenarios of different target image frames, and the present application does not limit the reference thresholds here.
[0042] Taking the reference threshold corresponding to the target code stream information as the average value between the maximum value and the minimum value of the target code stream information in the target image frame as an example, step S122 is described below.
[0043] The target code stream information in the target image frame is obtained. For example, when the target code stream information includes the quantization parameter value of the macroblock, the current macroblock in the target image frame is traversed to detect whether the quantization parameter value of the macroblock satisfies the first preset condition, wherein the first preset condition is:
[0044] |QPmax-Mqp(w,h)|>TH(qp);
[0045] Among them, TH(qp)=(QPmax+QPmin) / 2.
[0046] In the above formula, TH(qp) is the first reference threshold, QPmax and QPmin are the maximum and minimum values of the quantization parameter values actually encoded in the target image frame, respectively, and Mqp(w, h) is the quantization parameter value of the current macroblock, where w represents the macroblock number in the horizontal direction and h represents the macroblock number in the vertical direction.
[0047] For example, when the target code stream information includes the residual value of the macroblock, the current macroblock in the target image frame is traversed to detect whether the residual value of the macroblock satisfies the second preset condition, and the second preset condition is:
[0048] |RESmax-Mres(w,h)|<TH(res);
[0049] Among them, TH(res)=(RESmax+RESmin) / 2.
[0050] In the above formula, TH(res) is the second reference threshold, RESmax and RESmin are the maximum and minimum residual values of the macroblock encoding in the target image frame, Mres(w, h) is the residual value of the current macroblock, where w represents the macroblock number in the horizontal direction and h represents the macroblock number in the vertical direction.
[0051] For example, when the target code stream information includes the number of bits after macroblock encoding, the current macroblock in the target image frame is traversed to detect whether the number of bits after macroblock encoding satisfies the third preset condition, and the third preset condition is:
[0052] |BITmax-Mbit(w,h)|<TH(bit);
[0053] Among them, TH(bit)=(BITmax+BITmin) / 2.
[0054] In the above formula, TH (bit) is the third reference threshold, BITmax and BITmin are the maximum and minimum number of bits after macroblock encoding in the target image frame, respectively, and Mbit (w, h) is the number of bits after encoding of the current macroblock, where w represents the macroblock number in the horizontal direction and h represents the macroblock number in the vertical direction.
[0055] For example, when the target code stream information includes the temporal texture complexity or spatial texture complexity of the macroblock, the current macroblock in the target image frame is traversed to detect whether the macroblock texture complexity satisfies the fourth preset condition, and the fourth preset condition is:
[0056] |TEXmax-Mtex(w,h)|<TH(tex);
[0057] Among them, TH(tex)=(TEXmax+TEXmin) / 2.
[0058] In the above formula, TH(tex) is the fourth reference threshold, TEXmax and TEXmin are the maximum and minimum values of the macroblock texture complexity in the target image frame, respectively, and Mtex(w, h) is the texture complexity of the current macroblock, where w represents the macroblock number in the horizontal direction and h represents the macroblock number in the vertical direction.
[0059] For example, when the target code stream information includes the number of sub-blocks contained in the macroblock, the current macroblock in the target image frame is traversed to detect whether the number of sub-blocks contained in the macroblock meets the fifth preset condition, and the fifth preset condition is:
[0060] |SUBmax-Msub(w,h)|<TH(sub);
[0061] Among them, TH(sub)=(SUBmax+SUbmin) / 2.
[0062] In the above formula, TH(sub) is the fifth reference threshold, SUBmax and SUBmin are respectively the maximum and minimum values of the number of sub-blocks contained in the macroblock in the target image frame, Msub(w, h) is the number of sub-blocks contained in the current macroblock, where w represents the macroblock number in the horizontal direction, and h represents the macroblock number in the vertical direction.
[0063] If the quantization parameter value of the macroblock and the number of bits after encoding are used as the target code stream information, each macroblock in the target image frame is traversed to detect whether the quantization parameter value of the macroblock and the number of bits after encoding simultaneously meet the above-mentioned first preset condition and the third preset condition. If the quantization parameter value, residual value, number of bits after encoding, texture complexity, and number of sub-blocks contained in the macroblock are used as the target code stream information, each macroblock in the target image frame is traversed to detect whether the target code stream information of the macroblock simultaneously meets the above-mentioned first preset condition, second preset condition, third preset condition, fourth preset condition, and fifth preset condition. In some embodiments, different preset conditions and reference thresholds can be set according to different code stream information, and this application does not limit this.
[0064] By using at least two types of code stream information as target code stream information, more accurate boundary code stream information can be obtained. In some application scenarios, code stream information of more types of macroblocks can be used as target code stream information to improve the accuracy of the code stream information in determining the boundary of the target object in the target image frame. This application does not limit the above target code stream information and preset conditions.
[0065] If each target bitstream information of the macroblock satisfies the preset condition in step S122, step S123 is executed.
[0066] S123: The macroblock is regarded as a boundary macroblock whose code stream information satisfies the boundary code stream condition.
[0067] If the target code stream information of the traversed current macroblocks all meet the preset conditions, the current macroblock can be used as a boundary macroblock whose code stream information meets the boundary code stream conditions, and each macroblock in the target image frame is traversed to detect all macroblocks whose target code stream information meets the preset conditions, and determine the boundary macroblocks that meet the boundary code stream conditions.
[0068] S130: Determine the boundary of the target object in the target image frame based on the selected boundary macroblock.
[0069] After determining the boundary macroblocks that meet the boundary code stream conditions, the boundary of the target object in the target image frame can be determined based on the selected boundary macroblocks. For example, the selected boundary macroblocks can be connected to generate the boundary of the target object in the target image frame.
[0070] In some embodiments, for step S130, see Figure 3 , the step S130 includes the following steps:
[0071] S131: Find out whether there is a boundary macroblock of other boundary macroblocks within a preset range.
[0072] Boundary macroblocks that meet preset conditions are detected, among which there may be boundary macroblocks that are not at the boundary position. The boundary macroblocks can be finely selected, and it can be found whether there are boundary macroblocks of other boundary macroblocks within the preset range. For example, if the current macroblock is determined to be a boundary macroblock, it can be found whether there are other boundary macroblocks within the preset range of the current macroblock, and the boundary macroblocks can be finely selected to obtain a more accurate boundary of the target object.
[0073] In some embodiments, the preset range includes the upper left, directly above, upper right, left, right, lower left and lower right of the boundary macroblock, and the interval with the boundary macroblock is less than the preset number of macroblocks. The preset number can be set according to specific needs. This application takes the preset number of zero as an example for explanation. When the preset number is zero, the current macroblock is adjacent to the boundary macroblock in the preset range. When the current macroblock is determined to be a boundary macroblock, the upper left, directly above, upper right, left, right, lower left and lower right macroblocks adjacent to the current macroblock are detected to see if they are boundary macroblocks. If at least one of the upper left, directly above, upper right, left, right, lower left and lower right macroblocks is a boundary macroblock, then the current macroblock can be determined to be a refined boundary macroblock.
[0074] For example, the current macroblock meets the preset conditions of the above-mentioned boundary code stream and is determined to be a boundary macroblock. The macroblocks at the upper left, directly above, upper right, left, right, lower left and lower right of the current boundary macroblock are detected to see whether they are boundary macroblocks. If there is a boundary macroblock at the upper left, it can be determined that the current boundary macroblock is a refined boundary macroblock, that is, a boundary macroblock where other boundary macroblocks exist within a preset range.
[0075] When the current macroblock is determined as a boundary macroblock, at least another boundary macroblock is searched around the current boundary macroblock, and the boundary macroblock is finely selected to more accurately determine that the current macroblock is a boundary macroblock and obtain a more accurate boundary of the target object.
[0076] If it is found in step S131 that there are other boundary macroblocks within the preset range, step S132 is executed.
[0077] S132: Connect the found boundary macroblocks to generate the boundary of the target object in the target image frame.
[0078] The found boundary macroblocks are connected. The central subblock of the boundary macroblock can be connected to generate the boundary of the target object in the target image frame. Of course, the upper left subblock, upper right subblock, etc. of the boundary macroblock can also be connected to generate the boundary of the target object in the target image frame.
[0079] In the prior art, the boundary of the target object is obtained by using a boundary extraction algorithm for the original uncoded data of the video or image frame or the reconstructed image data restored by decoding the coded data. If the boundary of the target object obtained by the algorithm is synchronized to the corresponding position in the corresponding video or original image frame, the boundary of the obtained target object may deviate from the boundary of the target object in the video or original image frame due to reasons such as the time consumption of the boundary extraction algorithm, resulting in the problem of the target object boundary being out of synchronization and poor real-time performance.
[0080] In this embodiment, the code stream information of the macroblock of the target image frame is used, and according to the characteristics of the code stream information of the boundary code stream of the boundary, the boundary macroblock whose code stream information meets the boundary code stream requirements is selected to determine the boundary of the target object in the target image frame. When selecting the boundary macroblock, the numerical difference relationship between the code stream information of the macroblocks is used for judgment. When selecting the boundary macroblock, the surrounding macroblocks of the boundary macroblock are also judged. When there is at least one boundary macroblock around the boundary macroblock, the current macroblock is determined to be a boundary macroblock, thereby improving the accuracy of obtaining the boundary of the target object. Compared with determining the target boundary by analyzing the original data of the image, the present application directly uses the code stream information of the macroblock of the target image frame to determine the boundary of the target object. The process has low complexity and less time consumption, thereby improving the extraction efficiency of the boundary of the target object, and has good real-time performance for real-time detection and extraction of the target boundary. When the acquired boundary of the target object is synchronized to the target image frame, the problem of asynchronous boundary of the target object is reduced. In addition, in actual business, the boundary of the target object is generally superimposed on the reconstructed image data, and the target boundary is extracted after decoding. Relatively speaking, since the boundary of the target object is extracted before or while decoding, that is to say, before the target image frame is decoded and displayed, the boundary of the target object in the target image frame has been acquired. Therefore, when the acquired boundary of the target object is synchronized to the target image frame, there is no problem of asynchrony of the boundary of the target object.
[0081] For the above embodiments, the target object of the present application may be in a moving state. The target object is a moving target. Figure 4 , Figure 4 : is a flow chart of a second embodiment of a method for determining a target boundary provided by the present application, the method comprising the following steps:
[0082] S210: Acquire bitstream data of a target video, wherein the target video includes a plurality of image frames, and the bitstream data is obtained by encoding the denoised image frames.
[0083] When it is necessary to determine the target boundary of the moving target object, the target video where the moving target object is located is obtained, and the code stream data of the target video is obtained after encoding several image frames of the target video. Before obtaining the code stream data of the target video, the target video or the image frame of the target video can be denoised to reduce the interference of noise on the code stream information of the image frame of the actual moving target object. For example, the target video or the target image frame taken at night has a lot of noise, and the image is not clear. The obtained target video or target image frame can be denoised. The denoising algorithm for the target video or the image frame of the target video can be determined according to the specific application scenario, and the present application does not limit this. In some embodiments, the code stream data of the target video can be read to parse the code stream data to obtain the code stream information of each macroblock of the target image frame.
[0084] S220: Parse the code stream data to obtain code stream information of each macroblock of the target image frame.
[0085] The acquired bitstream data of the target video is parsed. In some application scenarios, the bitstream data can be decoded by a decoder to obtain the bitstream information of each macroblock of the target image frame. This application does not limit the decoding method of the bitstream data.
[0086] S230: Using at least two types of code stream information as target code stream information.
[0087] S240: traverse each macroblock in the target image frame to detect whether each target code stream information of the macroblock meets a preset condition.
[0088] If each target bitstream information of the macroblock satisfies the preset condition in step S240, step S250 is executed.
[0089] S250: The macroblock is regarded as a boundary macroblock whose code stream information satisfies the boundary code stream condition.
[0090] The specific implementation of steps S230-S250 in this embodiment can refer to the implementation process of steps S121-S123 in the above embodiment, which will not be repeated here.
[0091] S260: Find out whether there is a boundary macroblock of other boundary macroblocks within a preset range.
[0092] In step S260, if a boundary macroblock having other boundary macroblocks within the preset range is found, step S270 is executed.
[0093] S270: Connect the found boundary macroblocks to generate the boundary of the target object in the target image frame.
[0094] The specific implementation of steps S260 and S270 in this embodiment can refer to the implementation process of steps S131 and S132 in the above embodiment, which will not be repeated here.
[0095] Different from the above-mentioned embodiments, the present embodiment can determine the boundary of the moving target object by acquiring the bitstream data of the target video. Since the acquired bitstream data is obtained by encoding the denoised image frame, the influence of external noise on the bitstream information of the macroblock parsed is reduced, and the target video in various application environments can be applied to determine the boundary of the target object. At the same time, the acquired boundary is more accurate. The present application directly uses the bitstream information of the macroblock of the target image frame to determine the boundary of the target object. The process has low complexity and low time consumption, thereby improving the extraction efficiency of the boundary of the target object, and has good real-time performance for real-time detection and extraction of the target boundary. In addition, compared with the prior art, since the present application extracts the boundary of the moving target object before or while decoding, the boundary of the moving target object in the target image frame of the target video has been acquired before the target video is decoded and displayed. Therefore, when synchronizing the acquired boundary of the moving target object to the target image frame of the target video, there is no problem of the boundary of the target object being out of sync.
[0096] In addition, the target object of the present embodiment is a moving target. Since the bitstream data of the target video is obtained by encoding several image frames of the target video, the encoding of the image frames involves the use of intra-frame prediction and inter-frame prediction methods, so that the image frames have a strong correlation, and the bitstreams of the macroblocks of each image frame obtained are continuous. Compared with a stationary target object, the boundary of a target object in motion is obtained more accurately.
[0097] For the above embodiment, this embodiment takes the target bit stream information as the quantization parameter value and the number of bits after encoding as an example for explanation, and the target bit stream information of this application is not limited to this. Figure 5 , Figure 5 : is a flow chart of a third embodiment of a method for determining a target boundary provided by the present application, the method comprising the following steps:
[0098] S310: Obtain code stream data of a target video, wherein the target video includes a plurality of image frames, and the code stream data is obtained by encoding the denoised image frames.
[0099] The code stream data of the target video is read to parse the code stream data to obtain the code stream information of each macroblock of the target image frame.
[0100] S320: Parse the code stream data to obtain code stream information of each macroblock of the target image frame.
[0101] The acquired bitstream data of the target video is parsed. In some application scenarios, the bitstream data can be decoded by a decoder to obtain the bitstream information of each macroblock of the target image frame. This application does not limit the decoding method of the bitstream data.
[0102] S330: Using the quantization parameter value and the number of bits after encoding as target bitstream information.
[0103] S340: traverse each macroblock in the target image frame to detect whether the quantization parameter value and the number of bits after encoding of the macroblock meet preset conditions.
[0104] The preset conditions are:
[0105] |QPmax-Mqp(w,h)|>TH(qp);
[0106] Moreover, |BITmax-Mbit(w,h)|<TH(bit);
[0107] in,
[0108] In the above formula, QPmax and QPmin are the maximum and minimum values of the quantization parameter values actually encoded in the target image frame, respectively, Mqp(w, h) is the quantization parameter value of the current macroblock, BITmax and BITmin are the maximum and minimum values of the number of bits after macroblock encoding in the target image frame, respectively, Mbit(w, h) is the number of bits after encoding of the current macroblock, TH(qp) is the reference threshold of the quantization parameter, TH(bit) is the reference threshold of the number of bits after encoding, wherein w represents the macroblock number in the horizontal direction, and h represents the macroblock number in the vertical direction.
[0109] In some embodiments, the reference threshold TH(qp) of the above-mentioned quantization parameter can also be the middle value of the quantization parameter of the macroblock of the current frame, and the reference threshold TH(bit) of the encoded bit number is the middle value of the encoded bit number of the macroblock of the current frame. This application does not impose any restrictions on this.
[0110] In this embodiment, other code stream information may also be used as target code stream information, and this application does not impose any limitation on this.
[0111] If each target bitstream information of the macroblock satisfies the preset condition in step S340, step S350 is executed.
[0112] S350: The macroblock is regarded as a boundary macroblock whose code stream information satisfies the boundary code stream condition.
[0113] If, in the process of traversing the macroblocks of the current frame, the quantization parameter value and the number of bits after encoding of the current macroblock meet the above preset conditions, then the current macroblock can be used as a boundary macroblock whose bitstream information meets the boundary bitstream conditions, and the current macroblock can be used as a boundary macroblock of the boundary, so as to find all boundary macroblocks that meet the boundary.
[0114] The specific implementation of steps S330-S350 in this embodiment can refer to the implementation process of steps S121-S123 in the above embodiment, which will not be repeated here.
[0115] S360: Find out whether there is a boundary macroblock of other boundary macroblocks within the preset range.
[0116] In step S360, if a boundary macroblock having other boundary macroblocks within the preset range is found, step S370 is executed.
[0117] S370: Connect the found boundary macroblocks to generate the boundary of the target object in the target image frame.
[0118] The specific implementation of steps S360 and S370 in this embodiment can refer to the implementation process of steps S131 and S132 in the above embodiment, which will not be repeated here.
[0119] In this embodiment, by acquiring the code stream data of the target video, since the acquired code stream data is obtained by encoding the denoised image frame, the influence of external noise on the code stream information of the macroblock parsed is reduced, so that the acquired boundary is more accurate. In addition, the present application directly uses the quantization parameter value after encoding the target video and the number of bits after encoding to determine the boundary, thereby improving the accuracy of acquiring the boundary of the target object, and the process has low complexity and low time consumption, thereby improving the efficiency of extracting the boundary of the target object, and has good real-time performance for real-time detection and extraction of the target boundary. In addition, since the present application extracts the boundary of the target object before or while decoding, that is, before the target image frame is decoded and displayed, the boundary of the target object in the target image frame has been acquired, therefore, when synchronizing the acquired boundary of the target object to the target image frame, there is no problem of the boundary of the target object being out of sync.
[0120] For the above embodiment, the present application provides a target boundary determination device, see Figure 6 , Figure 6 is a schematic diagram of the structure of a target boundary determination device provided in the present application. The target boundary determination device 600 includes an acquisition module 610 , an analysis module 620 and a generation module 630 .
[0121] The acquisition module 610 is used to acquire the bitstream information of each macroblock in the target image frame. The bitstream information includes at least one bitstream information that can reflect the difference between the boundary and the non-boundary of the target object in the target image frame. For example, the bitstream information of the macroblock includes one or a combination of quantization parameter value, residual value, number of bits after encoding, temporal texture complexity, spatial texture complexity, maximum partition depth, and number of sub-blocks included.
[0122] In some embodiments, the target object is in motion, and the acquisition module 610 is used to obtain the bitstream information of each macroblock in the target image frame, including: obtaining the bitstream data of the target video, wherein the target video includes a plurality of image frames, and the bitstream data is obtained by encoding the denoised image frames; parsing the bitstream data to obtain the bitstream information of each macroblock of the target image frame.
[0123] The analysis module 620 is used to select, from the target image frame, a boundary macroblock whose bitstream information meets the boundary bitstream requirement.
[0124] In some embodiments, the boundary code stream requirement is that at least one code stream information of the boundary macroblock satisfies: the code stream information is located in the target value area of the corresponding code stream information distribution in the target image frame, and the target value area is: the code stream information distribution is divided into two value areas according to the value size, and one of the value areas is the target value area. For example, the code stream information distribution is divided into two value areas according to the value size, wherein the value area with a larger value is the upper value area, wherein the value area with a smaller value is the lower value area, and one of the value areas is the target value area.
[0125] In some embodiments, the analysis module 620 is used to select a boundary macroblock whose code stream information meets the boundary code stream condition from the target image frame, including: taking at least two code stream information as the target code stream information; traversing each macroblock in the target image frame to detect whether each target code stream information of the macroblock meets the preset condition; wherein the preset condition is that the difference between the maximum value of the target code stream information in the target image frame and the target code stream information of the macroblock is greater than or less than the reference threshold corresponding to the target code stream information; the reference threshold corresponding to the target code stream information is: the average value or the middle value between the maximum value and the minimum value of the target code stream information in the target image frame. If each target code stream information of the macroblock meets the preset condition, the macroblock is taken as the boundary macroblock whose code stream information meets the boundary code stream condition.
[0126] The generation module 630 is used to determine the boundary of the target object in the target image frame based on the selected boundary macroblock.
[0127] In some embodiments, the generation module 630 is used to determine the boundary of the target object in the target image frame based on the selected boundary macroblock, including: finding out whether there is a boundary macroblock of other boundary macroblocks within a preset range; connecting the found boundary macroblocks to generate the boundary of the target object in the target image frame. The preset range includes the upper left, directly above, upper right, left, right, lower left and lower right of the boundary macroblock, and the interval with the boundary macroblock is less than a preset number of macroblocks. It can be understood that if the boundary macroblock and the searched boundary macroblock are adjacent macroblocks, the preset number is zero. Of course, the preset number can be determined according to specific needs, and the present application does not limit this.
[0128] The specific implementation of this embodiment can refer to the implementation process of the above embodiment, which will not be repeated here.
[0129] For the above embodiment, the present application provides a computer device, see Figure 7 The computer device 700 includes: a processor 710 and a memory 720, wherein the processor 710 is connected to the memory 720, and the memory 720 is used to store a computer program, and the computer program is executed by the processor 710 to implement the above-mentioned target boundary determination method.
[0130] In this embodiment, the processor 710 may also be referred to as a CPU (Central Processing Unit). The processor 710 may be an integrated circuit chip having signal processing capabilities. The processor 710 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. A general-purpose processor may be a microprocessor or the processor 710 may also be any conventional processor, etc.
[0131] The method of the above embodiment may exist in the form of a computer program, so the present application proposes a computer readable storage medium, see Figure 8 , Figure 8 The computer-readable storage medium 800 of this embodiment stores a computer program 810, which can be executed by a processor to implement the method in the above embodiment.
[0132] The computer-readable storage medium 800 of this embodiment can be a medium that can store program instructions, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or it can also be a server that stores the program instructions. The server can send the stored program instructions to other devices for execution, or it can also execute the stored program instructions by itself.
[0133] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0134] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0135] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0136] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or 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 to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. 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 code.
[0137] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the present application is not limited to any specific combination of hardware and software.
[0138] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for determining a target boundary, characterized in that: The method comprises: Obtaining code stream information of each macroblock in the target image frame; Selecting, from the target image frame, a boundary macroblock whose bitstream information meets the boundary bitstream requirement; Determining the boundary of the target object in the target image frame based on the selected boundary macroblock; The step of selecting, from the target image frame, a boundary macroblock whose bitstream information meets the boundary bitstream requirement includes: Using at least two types of code stream information as target code stream information; Traversing each macroblock in the target image frame to detect whether each target code stream information of the macroblock meets a preset condition; If each of the target bitstream information of the macroblock satisfies the preset condition, the macroblock is regarded as a boundary macroblock whose bitstream information satisfies the boundary bitstream condition; Among them, when the target code stream information includes a quantization parameter, the preset condition is that the difference between the maximum value of the target code stream information in the target image frame and the target code stream information of the macroblock is greater than the reference threshold corresponding to the target code stream information; when the target code stream information includes any one of a residual value, a number of bits after encoding, a temporal texture complexity, a spatial texture complexity, a maximum division depth or the number of sub-blocks included, the preset condition is that the difference between the maximum value of the target code stream information in the target image frame and the target code stream information of the macroblock is less than the reference threshold corresponding to the target code stream information.
2. The method according to claim 1, characterized in that The code stream information includes at least one type of code stream information that can reflect the difference between the boundary and the non-boundary of the target object in the target image frame.
3. The method according to claim 1, characterized in that The boundary code stream requirement is that at least one code stream information of the boundary macroblock satisfies: the code stream information is located in a target numerical area of the corresponding code stream information distribution in the target image frame, and the target numerical area is: the code stream information distribution is divided into two numerical areas according to the numerical size, and one of the numerical areas is the target numerical area.
4. The method according to claim 1, characterized in that The reference threshold corresponding to the target code stream information is: an average value or a middle value between a maximum value and a minimum value of the target code stream information in the target image frame.
5. The method according to claim 1, characterized in that The step of determining the boundary of the target object in the target image frame based on the selected boundary macroblock includes: Find out whether there is a boundary macroblock of other boundary macroblocks within a preset range; The found boundary macroblocks are connected to generate the boundary of the target object in the target image frame.
6. The method according to claim 5, characterized in that The preset range includes areas located at the upper left, directly above, upper right, left, right, lower left and lower right of the boundary macroblock, and the interval between the boundary macroblock and the boundary macroblock is less than a preset number of macroblocks.
7. The method according to claim 1, characterized in that The target object is in motion; and / or, The step of obtaining the code stream information of each macroblock in the target image frame includes: Acquire bitstream data of a target video, wherein the target video includes a plurality of image frames, and the bitstream data is obtained by encoding the denoised image frames; The code stream data is parsed to obtain code stream information of each macroblock of the target image frame.
8. A computer device, characterized in that: The computer device comprises: a processor and a memory, wherein the memory is used to store a computer program, and the computer program is executed by the processor to implement the method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 7.
