Target tracking method and electronic device
By adjusting the target area to include more features in the target tracking method, and combining data augmentation and stability detection, the problem of insufficient target tracking accuracy and stability in the existing technology is solved, and the target tracking effect of electronic devices is improved. .
Patent Information
- Application Number
- CN202311130257.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-31
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-08-31
AI Technical Summary
Existing target tracking methods have poor accuracy in shooting preview and video recording scenes of electronic devices, affecting user experience.
By adjusting the position and size of the target area to include more features of the target, the accuracy and distinction of feature extraction are improved; at the same time, through data augmentation and stability detection, a suitable tracking area is determined to improve tracking stability. and persistence.
It improves the accuracy and stability of target tracking, reduces the possibility of tracking loss, and improves user experience.
Smart Images

Figure CN117714884B
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic technology, and in particular to a target tracking method and electronic equipment. Background Art
[0002] Visual object tracking, also known as target tracking, refers to locating a target in each frame of a video stream. Currently, target tracking is applied in various fields and scenarios, such as autonomous driving, sports event broadcasting, security monitoring, drone tracking and shooting, as well as shooting preview and recording scenes of electronic devices such as mobile phones.
[0003] Take target tracking in the shooting preview and video recording scenarios of an electronic device as an example: a frame image is displayed in the interface, the user clicks on the target in the image, the electronic device recognizes the user's click position, identifies the target to be tracked based on the user's click position, and searches and tracks the target in subsequent frame images.
[0004] However, the target tracking method in the related art has poor accuracy in target tracking, which affects the user experience. Summary of the invention
[0005] The present application provides a target tracking method and electronic device, which can improve the accuracy of target tracking and enhance user experience.
[0006] In a first aspect, the present application provides a target tracking method, including: displaying a first shooting interface, wherein a first area of the first shooting interface is used to display a video stream captured by a camera; when the first area displays the nth frame image of the video stream, receiving a first operation input by a user at a first position of the nth frame image, where n is a positive integer, and the nth frame image contains a target; in response to the first operation, determining a first target area in the nth frame image according to the first position, where the first target area contains a first part of the target; determining a second target area in the nth frame image according to the first target area, where the second target area contains a second part of the target, and the area of the second part is greater than that of the first part; based on the second target area, tracking the target in the n+xth frame image of the video stream, where x is a positive integer.
[0007] Optionally, the first operation may be, for example, a click operation, and the first position is also the click position.
[0008] Optionally, the first part and the second part of the target may both be parts of the target or the entire target. Optionally, the size and / or position of the first target area may be adjusted to obtain the second target area.
[0009] The target tracking method provided in the first aspect of the present application determines the second target area according to the first target area, so that the area of the second part of the target contained in the second target area is larger than the area of the first part contained in the first target area. If the area of the second part is larger than the area of the first part, the target features (i.e., the features of the target) contained in the second target area are more than the target features contained in the first target area, and thus when the target is tracked based on the second target area, more template features are extracted from the second target area, which can improve the accuracy of tracking. Moreover, if the second target area contains more target features, the probability that it contains significant features is greater, and thus the template features extracted from the second target area are more distinguishable, thereby further improving the accuracy of target tracking.
[0010] In one possible implementation, a second target area is determined in the nth frame image based on the first target area, including: determining a region of interest in the nth frame image based on the first target area, the region of interest including the first target area; performing image segmentation on the region of interest to obtain a plurality of sub-areas; respectively determining the minimum bounding rectangles of the plurality of sub-areas; respectively determining the overlap rates of a plurality of candidate areas with the first target area to obtain a plurality of overlap rates corresponding one-to-one to the plurality of candidate areas, the candidate area being the area defined by the minimum bounding rectangle in the nth frame image; and determining the candidate area corresponding to the maximum overlap rate among the plurality of overlap rates as the second target area.
[0011] Image segmentation obtains multiple sub-regions, each of which contains an object. The candidate region corresponding to the maximum overlap rate is the region containing the above-mentioned target object, so the region is determined as the second target region. Image segmentation can divide parts of the same object into a sub-region according to the characteristics of the object. Based on the overlap between the sub-region and the initial target region, the sub-region containing the target is determined, thereby determining the second target region. The method in this implementation can simply and accurately determine the second target region.
[0012] In one possible implementation, based on the second target area, the target in the n+xth frame image of the video stream is tracked, including: if the maximum overlap rate is greater than a preset overlap threshold, then based on the second target area, the target in the n+xth frame image of the video stream is tracked.
[0013] In a possible implementation, the method further includes: if the maximum overlap rate is less than or equal to a preset overlap threshold, tracking the target in the (n+x)th frame image of the video stream based on the first target area.
[0014] The maximum overlap rate is the overlap rate between the second target area and the first target area. In this implementation, the maximum overlap rate is compared with the preset overlap threshold. Only when the maximum overlap rate is greater than the preset overlap threshold, the second target area is used as the target area for final target tracking. In this way, it is possible to prevent the target area for target tracking from being too far away from the first target area, that is, too far away from the user's click position, thereby preventing the user's original choice from being affected and causing a bad experience for the user.
[0015] In a possible implementation, an image segmentation is performed on a region of interest to obtain multiple sub-regions, including: performing Gaussian blur processing on the region of interest to obtain a blurred image; performing color-based k-means clustering on the blurred image to obtain multiple clusters; using the multiple clusters as masks, respectively, performing binary mask processing on the blurred image to obtain multiple binary mask images corresponding to the multiple clusters; based on the multiple binary mask images, performing a connected domain extraction operation to obtain multiple sub-regions.
[0016] In this implementation, Gaussian blur processing can filter out non-key content in the area of interest and retain key content. The key content is then processed to reduce the amount of calculation, thereby improving the algorithm's operating efficiency.
[0017] In a possible implementation, a connected domain operation is performed based on multiple binary mask images, including: performing median filtering on the multiple binary mask images respectively to obtain multiple filtered images; and performing a connected domain operation based on the multiple filtered images to obtain multiple sub-regions.
[0018] In this implementation, the median filter process can filter out smaller discrete areas in the image, reduce image processing noise, improve image processing efficiency, and improve image processing accuracy.
[0019] In a possible implementation, based on multiple filtered images, a connected domain operation is performed to obtain multiple sub-regions: the connected domain operation is performed on the multiple filtered images respectively to obtain multiple connected domains; the areas of the multiple connected domains are calculated respectively; and the connected domains whose areas are smaller than an area threshold are filtered out from the multiple connected domains to obtain multiple sub-regions.
[0020] In this implementation, connected domains with smaller areas are filtered out to reduce the impact of these connected domains on image processing. On the one hand, this reduces the amount of algorithm computation and improves the algorithm's operating efficiency. On the other hand, it can reduce the interference of these connected domains on image processing results and improve the accuracy of processing results.
[0021] In a possible implementation, respectively determining the overlap ratios of the multiple candidate regions with the first target region to obtain multiple overlap ratios corresponding to the multiple candidate regions includes: respectively calculating intersection-over-union ratios of the multiple candidate regions with the first target region to obtain multiple overlap ratios.
[0022] In this implementation, the overlap ratio can be determined simply and quickly by calculating the intersection-over-union ratio.
[0023] In one possible implementation, based on the second target area, the target in the n+xth frame image of the video stream is tracked, including: extracting features of the second target area to obtain template features; and determining the position and corresponding confidence of the target in the n+xth frame image of the video stream based on the template features.
[0024] In a possible implementation, before tracking the target in the (n+x)th frame image of the video stream based on the second target area, the method further includes: determining whether the tracking stability of the second target area meets a preset condition.
[0025] In a possible implementation, determining whether the tracking stability of the second target area meets a preset condition includes: based on the nth frame image, performing data augmentation on the second target area to obtain multiple transformation areas; performing target search on the multiple transformation areas respectively to determine the position of the target in each transformation area and the corresponding confidence level; if it is determined that the number of first transformation areas among the multiple transformation areas is greater than a preset number, then determining that the tracking stability of the second target area meets the preset condition, and the confidence level corresponding to the first transformation area is greater than a confidence threshold.
[0026] This implementation method can improve tracking stability, and details can be found in the description of the second aspect.
[0027] In a second aspect, the present application provides a target tracking method, including: displaying a first shooting interface, wherein a first area of the first shooting interface is used to display a video stream captured by a camera; when the first area displays the nth frame image of the video stream, receiving a first operation input by a user at a first position in the nth frame image, where n is a positive integer; in response to the first operation, determining a third target area in the nth frame image according to the first position, wherein the third target area includes part or all of the target; if the tracking stability of the third target area meets a preset condition, then based on the third target area, tracking the target in the n+xth frame image of the video stream, where x is a positive integer.
[0028] The target tracking method provided in the second aspect of the present application detects the tracking stability of the initial target after acquiring the third target area. If the tracking stability meets the preset conditions, feature extraction is performed on the target area and target tracking is enabled; otherwise, target tracking is not enabled. In this way, after target tracking is enabled, the possibility of tracking loss is small, the stability and continuity of target tracking are improved, and the user experience is improved.
[0029] In a possible implementation, the method also includes: based on the nth frame image, performing data augmentation on the third target area to obtain multiple transformation areas; performing target search on the multiple transformation areas respectively to determine the position of the target in each transformation area and the corresponding confidence level; if the number of the first transformation areas in the multiple transformation areas is greater than a preset number, determining that the tracking stability of the third target area meets a preset condition; and the confidence level corresponding to the first transformation area is greater than a confidence threshold.
[0030] In this implementation, data augmentation is performed on the third target area to obtain multiple transformation areas, and target tracking is performed on the transformation areas. This is equivalent to using the transformation area to simulate the tracking area in the subsequent tracking frame in the video stream, and simulating the process of tracking the target in the third target area to judge the stability of the tracking. If it is stable, it means that the subsequent actual tracking success rate is high and it is not easy to lose the tracking, so the target tracking can be turned on. If it is unstable, it means that the subsequent actual tracking success rate is low and it is easy to lose the tracking, so the target tracking is not turned on. In this way, on the one hand, if tracking is turned on, the tracking stability is high, which improves the user experience. On the other hand, if tracking is not turned on, it can prevent waste of resources. This method can simply and accurately judge the tracking stability.
[0031] In a possible implementation, based on the nth frame image, data augmentation is performed on the third target area to obtain multiple transformation areas, including: in the nth frame image, at least one of a scale transformation and a translation transformation is performed on the border of the third target area to obtain multiple transformation frames; and the area defined by each transformation frame is determined as the transformation area.
[0032] In this implementation, data augmentation can be achieved simply and effectively through scale transformation and translation transformation.
[0033] In a possible implementation, the direction of the translation transformation includes at least one of vertically upward, vertically downward, horizontally leftward, horizontally rightward, diagonally upward to the left, and diagonally downward to the right.
[0034] In a possible implementation, determining the third target area in the nth frame image according to the first position includes: determining the third target area in the nth frame image according to the first position and a preset size.
[0035] That is, the third target area may be the first target area in the method provided in the first aspect. This implementation method can quickly determine the third target size according to the first position and the preset size, thereby improving the algorithm operation efficiency.
[0036] In one possible implementation, a third target area is determined in the nth frame image according to the first position, including: determining a first target area in the nth frame image according to the first position and a preset size, wherein the first target area includes a first part of the target; determining a third target area in the nth frame image according to the first target area, wherein the third target area includes a second part of the target, and an area of the second part is greater than an area of the first part.
[0037] In one possible implementation, a third target area is determined in the nth frame image based on the first target area, including: determining a region of interest in the nth frame image based on the first target area, the region of interest including the first target area; performing image segmentation on the region of interest to obtain a plurality of sub-areas; respectively determining the minimum bounding rectangles of the plurality of sub-areas; respectively determining the overlap rates of a plurality of candidate areas with the first target area to obtain a plurality of overlap rates corresponding one-to-one to the plurality of candidate areas, the candidate area being the area defined by the minimum bounding rectangle in the nth frame image; and determining the candidate area corresponding to the maximum overlap rate among the plurality of overlap rates as the third target area.
[0038] That is, the third target area may be the second target area in the method provided in the first aspect. This implementation can improve tracking accuracy, and for details, please refer to the description of the first aspect.
[0039] In a third aspect, the present application provides a device, which is included in an electronic device, and the device has the function of implementing the electronic device behavior in the above-mentioned first aspect and the possible implementation of the above-mentioned first aspect. The function can be implemented by hardware, or it can be implemented by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the above-mentioned functions. For example, a receiving module or unit, a processing module or unit, etc.
[0040] In a fourth aspect, the present application provides an electronic device, comprising: a processor, a memory, and an interface; the processor, the memory, and the interface cooperate with each other so that the electronic device executes any one of the methods in the technical solutions of the first aspect or the second aspect.
[0041] Optionally, the processor may be a central processing unit (CPU).
[0042] In a fifth aspect, the present application provides a chip, including a processor. The processor is used to read and execute a computer program stored in a memory to execute the method in the first aspect and any possible implementation thereof, or execute the method in the second aspect and any possible implementation thereof.
[0043] Optionally, the chip also includes a memory, and the memory is connected to the processor via a circuit or wire.
[0044] Further optionally, the chip also includes a communication interface.
[0045] In a sixth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the processor executes any one of the methods in the technical solutions of the first aspect or the second aspect.
[0046] In a seventh aspect, the present application provides a computer program product, which includes: a computer program code, and when the computer program code runs on an electronic device, the electronic device executes any one of the methods in the technical solutions of the first aspect or the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 This is a schematic diagram of interface changes for target tracking corresponding to a photo preview scene provided in an embodiment of the present application;
[0048] Figure 2 This is a schematic diagram of interface changes of target tracking corresponding to an example of a video recording scene provided in an embodiment of the present application;
[0049] Figure 3 is a schematic diagram of an example of a tracking target provided in an embodiment of the present application;
[0050] Figure 4 It is a schematic diagram of the target tracking process in the related art;
[0051] Figure 5 This is a schematic diagram of an application scenario of target tracking provided by an embodiment of the present application;
[0052] Figure 6 is a schematic diagram of another application scenario of target tracking provided by an embodiment of the present application;
[0053] Figure 7 is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application;
[0054] Figure 8 is a schematic diagram of a system architecture of an electronic device provided in an embodiment of the present application;
[0055] Fig. 9 is a flowchart of a target tracking method provided in an embodiment of the present application;
[0056] Fig.10 is a schematic diagram of the principle of a target tracking method provided in an embodiment of the present application;
[0057] Fig.11 is a flowchart of another target area adjustment process provided in an embodiment of the present application;
[0058] Fig.12 is another schematic diagram of the principle of target area adjustment provided in an embodiment of the present application;
[0059] Fig.13 This is a schematic diagram of a distance intersection-to-union ratio calculation principle provided in an embodiment of the present application;
[0060] Fig.14 is a schematic diagram of a system architecture of another electronic device provided in an embodiment of the present application;
[0061] Fig.15 is a flowchart of another target tracking method provided in an embodiment of the present application;
[0062] Fig.16 It is a schematic diagram of the principle of another target tracking method provided in an embodiment of the present application;
[0063] Fig.17 is a flowchart of a tracking stability detection process provided in an embodiment of the present application;
[0064] Fig.18 This is a schematic diagram of the principle of tracking stability detection provided by an embodiment of the present application;
[0065] Fig.19 This is a schematic diagram of different tracking stability test results corresponding to different scale factors provided in an embodiment of the present application:
[0066] Fig. 20 This is a schematic diagram of the system architecture of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0067] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0068] In the following, the terms "first", "second", and "third" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", and "third" may explicitly or implicitly include one or more of the features.
[0069] References to "one embodiment" or "some embodiments" etc. described in the specification of the present application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in the specification of the present application do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0070] First, the application scenarios of the target tracking method provided in the embodiments of the present application and the technical issues involved in the present application are explained.
[0071] Object tracking is widely used in various technical fields and application scenarios, such as autonomous driving, sports event broadcasting, security monitoring, drone tracking and shooting, as well as shooting preview scenes and recording (i.e. video shooting) scenes of electronic devices such as mobile phones.
[0072] Taking the shooting preview and video recording scenes of a mobile phone as an example, when using the mobile phone to preview photos or videos, or when using the mobile phone to record videos, the target can be tracked to facilitate preset processing such as focusing on the target and adjusting the brightness.
[0073] For example, Figure 1 This is a schematic diagram of the interface changes of a target tracking corresponding to a photo preview scene provided in an embodiment of the present application. Figure 1 As shown in Figure (a), when the user clicks the camera application (application, APP) icon on the mobile phone desktop, the mobile phone starts the camera APP and enters the photo preview interface, displaying a preview image of the surrounding environment, such as Figure 1 As shown in FIG. (b) in FIG. 1 , in the preview interface, if the user clicks on the position 101 of the preview image on the screen, the mobile phone responds to the user's click, determines the target area according to the position 101 clicked by the user, and displays a target frame 102. The target area includes a target 103 to be tracked.
[0074] After the mobile phone obtains the preview image frame by frame, it tracks the target 103 in each preview image frame and displays a tracking frame. Figure 1 As shown in (c) and (d) in FIG. 1 , the target 103 moves, or the user moves the mobile phone ( Figure 1When the target 103 moves, the position of the target 103 in the picture changes. Through target tracking, the target 103 can be identified in the current picture, and a tracking frame 104 is displayed in the interface to mark the position of the identified target 103. When the target 103 partially or completely moves out of the picture, the tracking is lost, and the tracking frame is no longer displayed in the interface. Figure 1 As shown in Figure (e).
[0075] In the video preview scene, the target tracking interface is similar to Figure 1 The interface in the photo preview scene shown is similar and will not be described again here.
[0076] For example, Figure 2 This is a schematic diagram of the interface changes of a target tracking corresponding to a video recording scene provided in an embodiment of the present application. Figure 2 As shown in Figure (a), in the photo preview interface, the user clicks the "record" control 201, and the camera APP switches the shooting mode to the video mode. The mobile phone displays Figure 2 The video preview interface shown in FIG. (b) in FIG. 1 shows a preview image of the surrounding environment. When the user clicks the start recording control 202 in the video preview interface, the mobile phone starts recording the video and enters Figure 2 The interface shown in Figure (c).
[0077] During the recording process, if the user clicks on a position 203 on the screen, the mobile phone responds to the user's click, determines a target area according to the position 203 clicked by the user, and displays a target frame 204. The target area includes a target 205 to be tracked.
[0078] After the mobile phone obtains the video image frame by frame, it tracks the target 205 in each frame of the video image and displays a tracking frame. Figure 2 As shown in (d) of FIG. , the target 205 moves, or the user moves the mobile phone ( Figure 2 The position of the target 205 in the picture changes, and the target 205 can be identified in the current picture through target tracking, and the position of the target 205 can be marked by the tracking frame 206.
[0079] It is understandable that, depending on the user's selection, the target to be tracked may be a person, an animal, a plant, a scene or an object, etc. Figure 3 This is a schematic diagram of an example of tracking a target provided in an embodiment of the present application. Figure 3 As shown in Figure (a), the interface includes a puppy. When the user clicks on the puppy, the phone will track the puppy. Figure 3 As shown in Figure (b) of the figure, the interface includes a pot of green plants. When the user clicks on the green plant, the mobile phone can track the green plant. Figure 3As shown in Figure (c), the interface includes a vehicle, and when the user clicks on the vehicle, the mobile phone can track the vehicle.
[0080] See also Figure 4 , the following combination Figure 4 The implementation process of the target tracking algorithm in the related technology is explained.
[0081] It is understood that, whether it is photo preview, video preview, or video recording, the electronic device is continuously acquiring and displaying a video stream, which includes multiple images. In the embodiment of the present application, each image in the video stream is referred to as a frame image, and the nth image in the video stream is referred to as the nth frame image.
[0082] like Figure 4 As shown, in the related art, when the nth frame image of the video stream is displayed in the mobile phone interface, in response to the user's click operation on the position 401 in the nth frame image, the mobile phone selects an area of a preset size centered on the position 401 as the target area 402. Then, the target area 402 is input into the template feature extraction network for feature extraction, the template feature is generated, and the tracker is initialized to start target tracking.
[0083] Taking the n+1th frame image in the video stream as an example, the mobile phone inputs the n+1th frame image into the tracking network, and the tracking network searches for a target on the n+1th frame image according to the template features, and obtains a target position 403 and a target confidence corresponding to the target position 403. Whether the tracking is successful is determined according to the target confidence, and if the tracking is successful, a tracking box 404 is displayed according to the target position 403. If the tracking is lost, the tracking is stopped.
[0084] However, in actual applications, it is found that Figure 4 When the method shown is used to track a target, in one case, when the user's click position deviates from the area where the salient features of the target to be tracked are located, the tracking accuracy is poor. Among them, the salient features refer to the features with distinguishing properties in the target, that is, the features that can distinguish the target from other objects. Different targets may have different salient features. For example, the salient features of a person in an image may include facial features, body features, etc.
[0085] See also Figure 5 ,same Figure 4 The nth frame image in the image includes a gorilla, and the gorilla's prominent feature is its facial features. The user wants to track the gorilla as a target. When the user clicks on the gorilla, he deviates from the gorilla's face and clicks on 501 parts of the gorilla's body. After the user clicks, the mobile phone determines the target area based on the user's click position. Figure 5As shown in 502 in FIG. 5 . The features extracted from the target area 502 do not include facial features, but mainly include features of black hair, which makes it easy to identify other similar objects (such as a black cat, a black carpet, etc.) as targets during tracking, that is, the tracking accuracy is poor, resulting in errors in the position of the tracking frame displayed subsequently, which brings a bad experience to the user.
[0086] In another case, when the location clicked by the user does not contain a significant target, tracking is easily lost and tracking continuity is poor. A significant target may be an object with clear boundaries, such as part or all of a person, animal, animal, building, etc. Figure 6 , the image includes the sea and the parachute 601. The user wants to track the parachute 601 as a target. However, after the user clicks on the position 602, due to the delay of the screen display, the target area determined by the mobile phone according to the position clicked by the user is as follows: Figure 6 As shown in 603 in the figure. Since the target area 603 does not contain a significant target, the features extracted from the target area are not significant enough, which results in the target being easily lost during tracking, poor tracking continuity, and affecting user experience.
[0087] Based on this, on the one hand, the present application provides a target tracking method, after determining the target area according to the preset size according to the user's click position, the position and / or size of the target area is adjusted so that the adjusted target area contains as many target features as possible, so that the template features obtained by feature extraction based on the adjusted target area are more, which can improve the accuracy of target tracking. Moreover, the more target features the adjusted target area contains, the greater the probability that it contains significant features, and the template features obtained by feature extraction based on the adjusted target area are more distinguishable, further improving the accuracy of target tracking. On the other hand, the embodiment of the present application also provides a target tracking method, by performing data augmentation on the target area, using multiple areas after data augmentation as tracking areas for simulated tracking, if the stability of the simulated tracking meets the preset requirements, then feature extraction is performed on the target area, and target tracking is turned on; otherwise, target tracking is not turned on. In other words, the method detects the tracking stability of the target area and decides whether to turn on target tracking based on the detection result. In this way, after turning on target tracking, the possibility of tracking loss is small, the stability and continuity of target tracking are improved, and the user experience is improved.
[0088] The target tracking methods of the two aspects are described below in conjunction with the embodiments.
[0089] Embodiment 1:
[0090] This embodiment mainly describes a target tracking method involving target area adjustment.
[0091] First, the device to which the method provided in this embodiment is applicable is described.
[0092] The target tracking method provided in this embodiment can be applied to electronic devices that can shoot videos, such as mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), drones, etc. The embodiment of the present application does not impose any restrictions on the specific type of electronic devices.
[0093] For example, Figure 7 1 is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0094] The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0095] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0096] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0097] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0098] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0099] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0100] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0101] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
[0102] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0103] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0104] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Figure 7 The structures of antenna 1 and antenna 2 in the electronic device 100 are only examples. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0105] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0106] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
[0107] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0108] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. GNSS may include the global positioning system (GPS), the global navigation satellite system (GLONASS), the Beidou navigation satellite system (BDS), the quasi-zenith satellite system (QZSS) and / or the satellite based augmentation system (SBAS).
[0109] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0110] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0111] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0112] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.
[0113] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0114] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0115] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0116] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0117] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0118] The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0119] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0120] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.
[0121] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0122] like Figure 8 As shown, the software system using the layered architecture is divided into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the system architecture (software system and hardware system) of the electronic device can be divided into five layers, from top to bottom, namely, application layer 210, application framework layer 220, hardware abstraction layer 230, driver layer 240 and hardware layer 250.
[0123] The application layer 210 may include a camera and a gallery application package. Of course, the application layer 210 may also include a calendar, a call, a map, a navigation, a WLAN, a Bluetooth, a music, a video, a short message, and other application packages. Figure 8 Not shown in FIG.
[0124] The application framework layer 220 provides an application access interface and a programming framework for the application programs of the application layer 210 .
[0125] For example, the application framework layer 220 includes a camera access interface, which is used to provide camera shooting services through camera management and camera devices.
[0126] The camera management in the application framework layer 220 is used to manage the camera. The camera management can obtain the parameters of the camera, such as determining the working status of the camera.
[0127] The camera device in the application framework layer 220 is used to provide a data access interface between different camera devices and camera management.
[0128] The hardware abstraction layer 230 is used to abstract the hardware. For example, the hardware abstraction layer 230 may include a camera hardware abstraction layer and other hardware device abstraction layers. The camera hardware abstraction layer may include camera device 1, camera device 2, tracking device, etc. It can be understood that camera device 1, camera device 2, tracking device, etc. can be functional modules implemented by software or a combination of software and hardware. When the electronic device is turned on or the electronic device is running, a corresponding process will be created or a corresponding process will be started to implement the corresponding functions of camera device 1, camera device 2, and tracking device. Among them, the tracking device is used to implement the function of target tracking.
[0129] The camera hardware abstraction layer can be connected to the camera algorithm library, and the camera hardware abstraction layer can call the algorithm in the camera algorithm library. In the embodiment of the present application, the camera algorithm library includes a tracker (i.e., a tracking algorithm). Optionally, the tracker can be implemented by the following modules: a region selection module, a region adjustment module, a template feature extraction network, a tracking network, etc.
[0130] The region selection module is used to determine an initial target region (also called a first target region) in the nth frame image of the video stream.
[0131] The region adjustment module is used to adjust the position and / or size of the initial target region to obtain an adjusted target region (hereinafter referred to as the adjusted target region, also referred to as the second target region).
[0132] The template feature extraction network is used to extract features from the adjustment target area to obtain template features.
[0133] The tracking network is used to track the target on the image input to the tracking network (referred to as the input image) according to the template features.
[0134] Of course, the camera algorithm library may also include other preset algorithms, such as a purple fringing removal algorithm, a saturation adjustment algorithm, etc., and the embodiments of the present application do not impose any limitation on this.
[0135] The driver layer 240 is used to provide drivers for different hardware devices. For example, the driver layer may include a camera driver, a digital signal processor driver, and a graphics processor driver.
[0136] The hardware layer 250 may include sensors, image signal processors, digital signal processors, graphics processors, and other hardware devices. The sensors may include sensor 1, sensor 2, etc., and may also include a depth sensor (time off light, TOF) and a multi-spectral sensor.
[0137] The following is an illustrative description of the workflow of the software system of the electronic device 100 in conjunction with the target tracking process in the photo preview scenario.
[0138] When the user clicks the icon of the camera APP on the touch sensor 180K, the camera APP is awakened by the click operation and enters the photo preview mode. The camera APP calls each camera device of the camera hardware abstraction layer through the camera access interface. Exemplarily, the camera hardware abstraction layer determines that the current zoom factor is less than 0.6 zoom factors, and thus, an instruction to call the wide-angle camera can be issued to the camera device driver. At the same time, the camera algorithm library starts to load the algorithm in the camera algorithm library.
[0139] When the sensor of the hardware layer is called, for example, after calling sensor 1 in the wide-angle camera to obtain the original image, the original image is sent to the image signal processing for preliminary processing such as alignment. After processing, it is returned to the camera hardware abstraction layer through the camera device driver, and then processed using other preset algorithms in the loaded camera algorithm library to obtain frame image 1.
[0140] The camera hardware abstraction layer sends the obtained frame image 1 back to the camera APP via the camera access interface for preview display.
[0141] When the user performs a click operation on position 1 of frame image 1 on touch sensor 180K, the camera APP responds to the click operation by calling the tracking device of the camera hardware abstraction layer through the camera access interface. The tracking device of the camera hardware abstraction layer calls the tracker in the camera algorithm library. The tracker obtains the initial target area from frame image 1, adjusts the initial target area to obtain the adjusted target area, and then extracts the template features from the adjusted target area.
[0142] The camera app continues to acquire the next frame image according to the above process to obtain frame image 2. After that, the tracking device calls the tracker in the camera algorithm library. The tracker tracks the target in frame image 2 based on the template features extracted from frame image 1 to obtain the position of the target in frame image 2. The tracking device of the camera hardware abstraction layer generates a tracking identifier corresponding to the position. The tracking identifier is used to identify the position of the target in frame image 2. Among them, the tracker and other preset algorithms in the camera algorithm library can call the digital signal processor through the digital signal processor driver and the graphics processor driver to call the graphics processor to realize the operation of the algorithm.
[0143] The camera hardware abstraction layer sends the obtained frame image 2 and tracking mark back to the camera APP via the camera access interface. The camera APP previews and displays the frame image 2 in the interface of the electronic device, and displays the tracking mark. In this way, the tracking mark can be presented around the periphery of the target in the interface, prompting the user that the current target is within the area defined by the tracking mark. In a specific embodiment, the tracking mark is used to define a square area. Optionally, the tracking mark defines the square area by a complete square graphic, that is, the tracking mark is a square tracking box. Optionally, the tracking mark can also define the square area only by four corners. Of course, the tracking mark can also be other shapes, and the embodiment of the present application does not impose any restrictions on the specific form of the tracking mark.
[0144] The generation process of the frame image 2 is repeated to achieve target tracking for each frame image.
[0145] For ease of understanding, the following embodiments of the present application will be described in detail with Figure 7 and Figure 8 Taking the electronic device with the structure shown as an example, the target tracking method provided in the embodiment of the present application is specifically described in combination with the accompanying drawings and application scenarios.
[0146] In this embodiment, the image processing process of the camera hardware abstraction layer and the camera algorithm library during the target tracking process is mainly described. The image generation process can be referred to the above embodiment and will not be repeated here.
[0147] For example, Fig. 9 is a flowchart of a target tracking method provided in an embodiment of the present application. Fig.10 This is a schematic diagram of the principle of a target tracking method provided in an embodiment of the present application. Please refer to Fig. 9 and Fig.10 , the method comprising:
[0148] S101. The nth frame image of the video stream is displayed in the interface of the electronic device. In response to a user clicking operation on position 1 in the nth frame image, a tracking device of the camera hardware abstraction layer calls a tracker in the camera algorithm library.
[0149] Optionally, the tracking device can carry the nth frame image and the information of position 1 when calling the tracker.
[0150] Optionally, position 1 may be, for example, Figure 1 (b) in the figure at position 101 or Figure 2 Position 203 in Figure (c).
[0151] S102 , the region selection module in the tracker determines the initial target region in the nth frame image according to position 1 in response to the call of the tracking device.
[0152] In this embodiment, the nth frame image is any frame image in the video stream. n is a positive integer. The nth frame image is the frame image that triggers the start of the target tracking process and is the basis for subsequent target tracking, so it is also called the initial frame. In the video stream, the frame image that needs to be based on the initial frame for target tracking after the initial frame can be called a tracking frame.
[0153] In a specific embodiment, the area selection module can select an area within a preset range 1 around position 1 as the target area. For example, a circular area is selected with a preset radius with position 1 as the center as the target area. Alternatively, a square area with a preset area is selected with position 1 as the center as the target area. In other words, the selection method and size of the initial target area are both preset, so when the user clicks the same position, the initial target area obtained is the same.
[0154] See also Fig.10 , position 1 is shown as 1001, and the initial target area determined according to position 1 can be as follows Fig.10 As shown in 1002.
[0155] Optionally, the coordinates of position 1 are expressed as c0={cx0, cy0}, and the size of the initial target area is expressed as {w0, h0}. w0 represents the width, and h0 represents the height. The border of the initial target area can be expressed as b0={cx0, cy0, w0, h0}.
[0156] Optionally, after determining the initial target area, the interface may also display a target frame in the interface according to the target area, such as Figure 1 The target frame 102 in (b) or Figure 2 (c) shows the target frame 204. It can be understood that the size, form, etc. of the target frame can be completely the same as the frame of the target area, or can be different.
[0157] S103: The region selection module sends the initial target region to the region adjustment module.
[0158] S104: The region adjustment module adjusts the position and / or size of the initial target region to obtain an adjusted target region.
[0159] It can be understood that in the embodiments of the present application, adjusting the position and / or size of the initial target area is essentially adjusting the position and size of the border of the initial target area to obtain a new border, and the area defined by the new border is called the adjusted target area; or, based on the position and size of the initial target area, a region with a different position and / or size from the initial target area is reselected in the nth frame image, and the reselected region is called the adjusted target area.
[0160] Optionally, if the initial target region includes the first part of the target and the adjusted target region includes the second part of the target, the area of the second part is greater than the area of the first part. In other words, the target features included in the adjusted target region may be more than the target features included in the initial target region, so that the probability of including the salient features of the target in the adjusted target region is greater. In a specific embodiment, the adjusted target region may include the entire target, so that the adjusted target region may cover the salient features of the target.
[0161] See also Fig.10 , adjust the target area as follows Fig.10 As shown in 1003.
[0162] S105, the region adjustment module inputs the adjusted target region into the template feature extraction network.
[0163] S106: The template feature extraction network extracts features from the adjusted target area, generates template features, and initializes the tracker.
[0164] Optionally, initializing the tracker may include setting the state of the tracker to a tracking state, etc. The tracking state is used to indicate that the target tracking process has been started. It is understood that each module in the tracker can perform related operations according to the state of the tracker. When receiving a call from a tracking device, if it is determined that the state of the tracker is a tracking state, the relevant modules in the tracker perform target tracking according to the template features.
[0165] Optionally, the template feature is also called the target feature and can be expressed as
[0166] It can be understood that while executing the above steps S101 to S106, the electronic device can obtain the next frame image of the video stream, that is, the n+1th frame image, according to the process described in the above embodiment. Since the time required to execute steps S101 to S106 is generally short, steps S101 to S106 can be executed before the electronic device obtains the n+1th frame image, or at the same time as the electronic device obtains the n+1th frame image. Therefore, the template feature can be obtained according to step S106, and the target can be tracked starting from the n+1th frame image. In this embodiment, the tracking of the target starting from the n+1th frame image after step S106 will be described as an example.
[0167] However, in other embodiments, after step S106, the target may be tracked from other frames. For example, the target may be tracked from the n+2th frame image, the n+5th frame image, etc. Optionally, when steps S101 to S106 require a long time, or in addition to steps S101 to S106, the method further includes other steps, which results in a long time required to generate template features, after the template features are generated, the target may be tracked from the frame image whose generation time is closest to the current moment. The embodiments of the present application do not impose any limitation on this.
[0168] S107 . After the tracking device in the camera hardware abstraction layer obtains the n+1th frame image (tracking frame), the tracker in the camera algorithm library is called.
[0169] Optionally, the tracking device can carry the n+1th frame image when calling the tracker.
[0170] S108. The tracking network in the tracker responds to the call of the tracking device, performs a target search on the n+1th frame image according to the template features, and determines the target position and the target confidence corresponding to the target position; the target position is used to characterize the position of the target in the n+1th frame image.
[0171] Optionally, the tracking network can select a partial area with a high probability of containing the target from the n+1th frame image as a tracking area (also called a search area) for target search, which can reduce the amount of calculation and improve the algorithm operation efficiency.
[0172] Specifically, the features of the tracking area can be extracted to obtain the search features And calculate the template features With search feature The correlation between the target and the target position is output, and the target confidence corresponding to the target position is output. The target position is actually the border position of the area containing the target identified by the tracking network. The target position can be expressed as b n ={cx n ,cy n , w n ,h n}. The target confidence can be expressed as ρ n .
[0173] See also Fig.10 , the target position in the n+1th frame image obtained by tracking network search is as follows Fig.10 As shown in 1004.
[0174] S109, the tracking network determines whether the target confidence is greater than the confidence threshold; if so, execute step S110; if not, execute step S113.
[0175] The confidence threshold can be expressed as ρ th That is, to judge ρ n Is it greater than ρ th .
[0176] S110, the tracking network generates tracking success information; the tracking success information is used to indicate that the target tracking is successful.
[0177] S111. The tracking network returns the target position and tracking success information to the tracking device of the camera hardware abstraction layer.
[0178] S112: After receiving the tracking success information, the tracking device generates a tracking identifier corresponding to the target location according to the target location.
[0179] Afterwards, the n+1th frame image and the tracking mark are displayed on the interface of the electronic device.
[0180] See also Fig.10 , the tracking mark in the n+1th frame image can be Fig.10 As shown in 1005. It can be seen that the tracking mark contains the salient features of the target.
[0181] S113, the tracking network generates tracking failure information; the tracking failure information is used to indicate target tracking failure, that is, tracking loss.
[0182] S114. The tracking network returns the target position and tracking failure information to the tracking device of the camera hardware abstraction layer.
[0183] Optionally, in this step, the tracking network may also send only the tracking failure information to the tracking device of the camera hardware abstraction layer without sending the target position, so as to simplify the algorithm and improve the algorithm operation efficiency.
[0184] S115. After receiving the tracking failure information, the tracking device stops tracking.
[0185] After receiving the tracking failure message, the tracking device does not generate a tracking mark, and the tracking mark is not displayed in the interface. In addition, the tracking device stops tracking the current target, and after the next frame of image is generated, the tracking device no longer calls the tracker in the camera calculation library.
[0186] It is understood that during the tracking process, if the preset exit tracking condition is met, the tracking device also stops tracking. The preset exit tracking condition may be, for example, switching to a camera mode.
[0187] In addition, if the target tracking is successful and the preset exit tracking condition is not met, the target tracking is performed for any subsequent frame image (n+xth frame image) in the video stream in the same manner as in steps S107 to S115. That is, after step S112, n=n+1 is set, and step S107 is returned to be executed.
[0188] The target tracking method provided by the embodiment of the present application, after determining the target area according to a fixed size based on the user's click position, adjusts the size and / or position of the initial target area so that the area of the second part of the target is larger than the area of the first part, so that the obtained adjusted target area can contain as many target features as possible. In this way, more template features are obtained by feature extraction based on the adjusted target area, thereby improving the accuracy of target tracking. Moreover, the adjusted target area contains more target features, and the probability of it containing significant features is greater. The template features obtained by feature extraction based on the adjusted target area are more distinguishable, so that when tracking is performed according to the template features, the target can be identified more accurately, that is, the accuracy of target tracking is improved.
[0189] The adjustment process of the target area is further explained below.
[0190] For example, Fig.11 A flowchart of a target area adjustment process provided in an embodiment of the present application is shown in FIG. Fig.12 This is a schematic diagram of the principle of adjusting the target area provided in the embodiment of this application. Please refer to Fig.11 and Fig.12 In the above step S104, “adjusting the position and / or size of the initial target area to obtain an adjusted target area” includes:
[0191] S201 . Selecting a region of interest in the nth frame image according to the initial target region, wherein the region of interest includes the initial target region and is larger than the target region.
[0192] As mentioned above, the coordinates of position 1 are expressed as c0={cx0, cy0}, and the size of the initial target area is expressed as {w0, h0}. Optionally, the center of the region of interest can coincide with the center of the initial target area, that is, the center of the region of interest is also c0={cx0, cy0}. Then the range of the region of interest (i.e., the border) can be expressed as ROI={cx0, cy0, αw0, ah0}. Among them, α is greater than 1. It can be understood that the region of interest is actually a part of the initial image of the nth frame, which is also an image, so the region of interest can also be called an image of interest. The region of interest can be expressed as I roi .
[0193] Optionally, in the nth frame image, the frame of the initial target area may be stretched outward to obtain the region of interest. The embodiment of the present application does not limit the method for selecting the region of interest.
[0194] like Fig.12 As shown, the initial target area is shown as 1201 , the position 1 is shown as 1202 , and the area of interest is shown as 1203 .
[0195] S202, performing Gaussian blur processing on the region of interest to obtain a blurred image.
[0196] The process of Gaussian blurring the region of interest can be expressed as: gauss =GaussianBlur(I roi ). Among them, I qauss Indicates a blurred image.
[0197] Specifically, I gauss =I roi *w k .
[0198] where w k represents a Gaussian kernel of size k, and * represents a convolution operation.
[0199] Through Gaussian blur processing, non-key content in the area of interest can be filtered out and the key content can be retained. The key content will be processed later to reduce the amount of calculation, thereby improving the efficiency of the algorithm.
[0200] Fig.12 , the blurred image is shown as 1204 .
[0201] S203: Perform color-based k-means clustering on the blurred image to obtain k clusters, where k is an integer greater than 1.
[0202] Specifically, for all samples X = {x1, ..., x n}, randomly initialize k cluster centers: Set the maximum number of iterations to N, and then iteratively update the cluster center through the following steps a and b:
[0203] Step a: Assignment:
[0204] For 0≤i<n, calculate each sample x separately i To the kth cluster center The Euclidean distance of: x i The class marked as the cluster center with the smallest distance is:
[0205]
[0206] Step b: Update:
[0207] For 0≤j<k, update each cluster center:
[0208]
[0209] If all cluster centers are not updated, the iteration is stopped and the clustering results (k clusters) are output; otherwise, the iteration is continued until the maximum number of iterations N is reached, and the clustering results (k clusters) are output.
[0210] See also Fig.12 , the k-means clustering result is shown as 1205. Fig.12 In the example, taking k as 4, the blurred image is clustered based on color using k-means, and 4 clusters are obtained, each cluster corresponding to a color. Fig.12 The cluster centers shown in the k-means clustering result 1205 correspond to four colors respectively.
[0211] S204, using the k clusters as masks respectively, performing binary mask processing on the blurred image, and obtaining k binary mask images (also called binary mask images) corresponding to the k clusters one by one.
[0212] That is to say, after step S204, k binary mask images can be obtained. Fig.12 As shown in FIG. 1 , when k is 4, the four binary mask images obtained by performing binary mask processing on the k-means clustering result 1205 are respectively Fig.12 Figure a1, figure a2, figure a3 and figure a4 in the figure. Among them, Fig.12 The a1 figure in is the binary mask corresponding to the color 1 cluster. Fig.12 The a2 figure in is the binary mask image corresponding to the color 2 cluster. Fig.12 The a3 figure in the figure is the binary mask corresponding to the color 3 cluster. Fig.12 Figure a4 in the figure is the binary mask image corresponding to the color 4 cluster center.
[0213] S205 , performing median filtering on the k binary mask images respectively to obtain k filtered images.
[0214] Median filtering can filter out smaller discrete areas in an image, reduce image processing noise, improve image processing efficiency, and improve image processing accuracy.
[0215] S206 , respectively taking connected domains in k filtered images to obtain m connected domains.
[0216] A connected domain refers to a connected area in a binary image that is composed of adjacent pixels with the same pixel value. Adjacent pixels refer to pixels that are adjacent in the up, down, left, right, or diagonal directions in the image.
[0217] Optionally, for the binary mask map B corresponding to the k-th cluster, a two-pass scanning method can be used to obtain the connected domain:
[0218] First scan: Initialize label label(x, y) = 0, traverse the pixels in B, if B(x, y) == 1, then:
[0219] a. If the pixel values in the neighborhood of B(x, y) are all 0, update the label value label and the value of the pixel B(x, y):
[0220] label=+1, B(x,y)=label.
[0221] b. If there is a pixel value greater than 1 in the neighborhood of B(x, y), then B(x, y) is assigned the minimum value in the neighborhood, and the labels in the same neighborhood are saved in a set L. k middle.
[0222] Second scan: traverse all pixels, if B(x, y)>0, find the label set L to which B(x, y) belongs k , and assign B(x, y) to L k The minimum value of .
[0223] After two scans are completed, pixels with the same value form a connected domain. It can be understood that after each filtered image is processed by taking the connected domain, one connected domain or multiple connected domains may be obtained. Assume that k filtered images are calculated to obtain a total of m connected domains.
[0224] S207, respectively calculating the areas of the m connected domains, filtering out the connected domains whose areas are smaller than the area threshold among the m connected domains, and obtaining n connected domains, where n is smaller than or equal to m.
[0225] Filtering out connected domains with smaller areas can reduce the impact of these connected domains on image processing. On the one hand, it can reduce the amount of algorithm calculations and improve the efficiency of the algorithm. On the other hand, it can reduce the interference of these connected domains on the image processing results and improve the accuracy of the processing results.
[0226] S208, respectively calculating the minimum circumscribed rectangles corresponding to the n connected domains.
[0227] The minimum bounding rectangle of the i-th connected domain among n connected domains is represented by b i , then the set of n minimum enclosing rectangles can be expressed as: B c = {b i, i∈n}, b i ={cx i ,cy i , w i ,h i}.
[0228] like Fig.12 As shown in Figures a1, a2, a3 and a4 in the figure, the minimum circumscribed rectangle corresponding to each connected domain is shown in the white solid line box.
[0229] S209 , mapping each minimum bounding rectangle to the nth frame image respectively, and calculating the overlap rate between the area defined by each minimum bounding rectangle (hereinafter referred to as the candidate area) and the initial target area.
[0230] The overlap rate represents the ratio of the overlapping area of the candidate region and the initial target region to the total coverage area of the two.
[0231] Optionally, the overlap ratio between the candidate region and the initial target region can be calculated by using the intersection over union ratio. For example, the distance intersection over union ratio (DIoU) can be used:
[0232]
[0233] Among them, DIoU i represents the intersection-and-union ratio of the distance between the i-th candidate region and the initial target region. i represents the border of the ith candidate region, i.e., the ith minimum enclosing rectangle. b0 represents the border of the initial target region. d represents the Euclidean distance between the center point of the ith candidate region and the initial target region, and c represents the diagonal distance between the ith candidate region and the minimum closure of the initial target region. Fig.13 , the i-th candidate region is shown as 1301, the initial target region is shown as 1302, and the minimum closure of the candidate region 1301 and the initial target region 1302 is shown as 1303. Then, d and c are shown in the figure.
[0234] Optionally, the overlap rate between the candidate region and the initial target region may be calculated or characterized by other methods, and the embodiments of the present application do not impose any limitation on this.
[0235] S210 : Determine a candidate region corresponding to the maximum overlap rate among all (n) overlap rates as an adjustment target region.
[0236] It can be understood that the candidate region corresponding to the maximum overlap rate is also the candidate region containing the most target features among the n candidate regions.
[0237] See also Fig.12 , the target area may be adjusted as shown in 1206 in the figure.
[0238] It can be understood that the above steps S202, S205 and S207 may be optional steps and may not be performed in actual applications to reduce the amount of calculation and improve the algorithm operation efficiency.
[0239] In addition, the above steps S202 to S207 are essentially for image segmentation of the region of interest, separating the regions containing different objects in the region of interest to obtain multiple sub-regions. In practical applications, image segmentation can also be performed by other methods, such as threshold segmentation method, edge extraction method, image segmentation method based on neural network, etc., and the embodiments of the present application do not impose any limitation on this.
[0240] Continue to see Fig.12 In one embodiment, after step S104 and before step S105, the following may also be included:
[0241] Determine whether the overlap rate (i.e., the maximum overlap rate) corresponding to the adjusted target area is greater than a preset overlap threshold; if so, execute step S105; if not, input the initial target area into the template feature extraction network, extract features from the initial target area, generate template features, and initialize the tracker.
[0242] That is, determine whether DIoU max >τ, if yes, target tracking is performed based on the adjusted target area; if no, target tracking is performed based on the initial target area. DIoU max represents the maximum overlap rate among the n overlap rates, that is, the overlap rate corresponding to the adjusted target area, and τ represents the preset overlap threshold. τ is a value greater than 0 and less than 1.
[0243] Maximum overlap rate DIoU max If it is greater than the preset overlap threshold τ, it means that the adjusted target area is closer to the initial target area and / or has a larger overlap with the initial target area, that is, the adjusted target area will not deviate too far from the initial target area or the overlap with the initial target area is smaller, and the area can be used as the target area for target tracking.
[0244] Maximum overlap rate DIoU max If the value is greater than or equal to the preset overlap threshold τ, it means that the adjusted target area is far from the initial target area, or the overlap with the initial target area is small. If the adjusted target area is used as the target area for target tracking, it will deviate from the user's click position, violate the user's intention, and affect the user experience. Therefore, the initial target is still used as the target area for target tracking.
[0245] The method provided in this embodiment compares the overlap rate between the adjusted target area and the initial target area with a preset overlap threshold, and only when the maximum overlap rate is greater than the preset overlap threshold, the adjusted target area is used as the target area for final target tracking. In this way, it is possible to prevent the target area for target tracking from being too far away from the initial target area, that is, too far away from the user's click position, thereby preventing the user's original selection from being affected and bringing a bad experience to the user.
[0246] Below Fig. 9 The implementation process of step S108 in the illustrated embodiment is described.
[0247] In one embodiment, the tracking network may include a local shallow network, a local deep network, a global deep network, etc. The local shallow network, the local deep network, and the global deep network are all used to search for a target in an input image according to template features, and output the position of the target and the confidence corresponding to the position. Optionally, the local shallow network, the local deep network, and the global deep network can be convolutional neural networks. The local shallow network and the local deep network are used to search for local areas. The global deep network is used to search for global areas. The network depth or network width of the local deep network and the global deep network is greater than that of the local shallow network.
[0248] Specifically, in step S108, "in response to the call of the tracking device, according to the template features, performing target search on the n+1th frame image, and determining the target position and the target confidence corresponding to the target position", and in step S109, "determining whether the target confidence is greater than the confidence threshold", may include:
[0249] 1) According to the position of the target in the nth frame image, a partial area of the (n+1)th frame image is selected to obtain a first tracking area.
[0250] Optionally, the first tracking area can be selected according to the position of the center point of the target in the nth frame image. Specifically, in the n+1th frame image, the position of the center point of the target in the nth frame image can be taken as the center, and the area of the preset range 2 can be selected to obtain the first tracking area. The area of the first tracking area is smaller than the area of the n+1th frame image, that is, the first tracking area is a local area in the n+1th frame image.
[0251] Optionally, preset range 2 may be larger than preset range 1, so that the area of the first tracking area is larger than the area of the target area, that is, the resolution of the first tracking area may be higher than that of the target area. The resolution of the first tracking area is larger than that of the target area, and the probability of a successful search is higher when a subsequent search is performed based on the first tracking area, thereby increasing the success rate of target tracking.
[0252] 2) Inputting the first tracking area into the local shallow network, the local shallow network performs target search on the first tracking area according to the template features, and outputs a first position and a first confidence level corresponding to the first position; the first position is used to characterize the position of the target in the (n+1)th frame image.
[0253] 4) Determine whether the first confidence is greater than the confidence threshold; if so, take the first position as the target position and execute step S110; if not, execute the following step 5).
[0254] If the first confidence is greater than the confidence threshold, it means that the local shallow network has successfully searched for the target, that is, the tracking is successful, and step S110 is executed to output the first position as the target position. If the first confidence is less than or equal to the confidence threshold, it means that the local shallow network has failed to search for the target, and step 5) is executed to enter the local deep search stage.
[0255] 5) Inputting the first tracking area into the local deep network, the local deep network performs target search on the first tracking area according to the template features, and outputs a second position and a second confidence level corresponding to the second position; the second position is used to characterize the position of the target in the (n+1)th frame image.
[0256] 6) Determine whether the second confidence is greater than the confidence threshold; if so, take the second position as the target position and execute step S110; if not, execute step 7).
[0257] If the second confidence is greater than the confidence threshold, it means that the local deep network has successfully searched the target, that is, the tracking is successful, and step S110 is executed to output the second position as the target position. If the second confidence is less than or equal to the confidence threshold, it means that the local deep network has failed to search the target, and step 7) is executed to enter the global deep search stage.
[0258] 7) Divide the (n+1)th frame image to obtain a plurality of second tracking areas.
[0259] Optionally, the n+1th frame image may be divided according to a preset division method, for example, the n+1th frame image may be divided into a plurality of second tracking regions according to a grid division method, a pixel clustering-based method, a region proposal network (RPN) method, and the like.
[0260] Optionally, the area of the second tracking area may be larger than the first tracking area, that is, the resolution of the second tracking area is greater than that of the first tracking area. Thus, when a global deep search is performed based on the second tracking area, the probability of a successful search is greater, thereby increasing the success rate of target tracking.
[0261] 8) Inputting each second tracking area into the global deep network respectively, the global deep network performs target search for each second tracking area according to the template features, and outputs multiple third positions and third confidences corresponding to each third position respectively; the third position is used to characterize the position of the target in the (n+1)th frame image.
[0262] 9) Determine whether there is a third confidence level greater than the confidence threshold; if so, take the third position corresponding to the third confidence level greater than the confidence threshold as the target position and execute step S110; if not, execute step S113.
[0263] If there is a third target confidence, it means that the global deep network has successfully searched for the target, that is, the tracking is successful, and step S109 is executed to output the third position corresponding to the third confidence greater than the confidence threshold as the target position. If there is no third confidence greater than the confidence threshold, that is, all third confidences are less than or equal to the confidence threshold, it means that the global deep network has failed to search for the target, that is, the tracking has failed, and step S113 is executed to stop tracking.
[0264] The target tracking method provided in this embodiment searches for the target based on a local shallow network, a local deep network, and a global deep network. The three networks are in a progressive relationship in terms of network depth or network width, the resolution of the input image, and the search range. In this way, in the target tracking process, a low-resolution shallow search is first performed on a local part of the image through a local shallow network. If the search fails, a low-resolution deep search is performed on a local part of the image through a local deep network, that is, the network depth and / or width of the search is deepened to improve the search accuracy. If the local deep network still fails to search, a high-resolution deep search is performed on the global part of the image through a global deep network, that is, the resolution of the input image is further increased, and the search range is expanded to further improve the search accuracy. In this way, target search for difficult scenes can improve tracking accuracy and reduce the possibility of target tracking loss. At the same time, during the search process, the search depth is gradually deepened according to the search results, or the input image resolution is increased, or the search range is expanded. Compared with tracking only through a global deep network, this method can prevent unnecessary deep searches, high-resolution searches, or global searches in non-difficult scenarios, thereby reducing the complexity of the algorithm operation, improving the real-time performance of target tracking, and reducing device power consumption.
[0265] Of course, the above tracking network structure and the method of tracking the target by the tracking network are only used as an example. In practical applications, the tracking network may include more or less networks such as the above structure, or any other method capable of achieving target tracking may be adopted, and this application does not make any limitation on this.
[0266] Embodiment 2:
[0267] This embodiment mainly describes a target tracking method involving stability detection.
[0268] The hardware structure of the electronic device to which the target tracking method provided in this embodiment is applicable may be the same as that in the first embodiment and will not be described in detail.
[0269] For example, Fig.14 This is a schematic diagram of the system architecture of another electronic device provided in an embodiment of the present application. Fig.14 As shown, the software architecture of the electronic device to which the target tracking method provided in this embodiment is applicable is similar to that of the first embodiment, except that the tracker does not include a region adjustment module, but includes a stability detection module. The stability detection module is used to perform tracking stability detection on the initial target region selected by the region selection module. The functions of other modules refer to the first embodiment and will not be described in detail.
[0270] For example, Fig.15 is a flowchart of another target tracking method provided in an embodiment of the present application. Fig.16 This is another schematic diagram of the principle of the target tracking method provided in the embodiment of the present application. Please refer to Fig.15 and Fig.16 , the method comprising:
[0271] S301, the nth frame image of the video stream is displayed in the interface of the electronic device, and in response to the user clicking operation on position 1 in the nth frame image, the tracking device of the camera hardware abstraction layer calls the tracker in the camera algorithm library.
[0272] S302: The region selection module in the tracker determines the initial target region in the nth frame image according to position 1 in response to the call of the tracking device.
[0273] This process is similar to that in Example 1. Fig. 9 and Fig.10 The processes shown are the same and will not be described again.
[0274] S303: The region selection module sends the initial target region to the stability detection module.
[0275] S304, the stability detection module detects whether the tracking stability of the initial target area meets the requirements; if it meets the requirements, step S305 is executed; if it does not meet the requirements, the target tracking is not started and the process ends.
[0276] If the tracking stability of the initial target area meets the requirements, it means that when the target is tracked based on the initial target area, the stability is high and it is not easy to lose the tracking, so step S304 is executed to start the target tracking. If the tracking stability of the initial target area does not meet the requirements, it means that when the target is tracked based on the initial target area, the stability is low and it is easy to lose the tracking, so the target tracking is not started, and the current process is directly terminated. After the next user click operation is received, step S301 is executed again to start the next tracking process.
[0277] S305. The stability detection module inputs the initial target area into the template feature extraction network.
[0278] S306: The template feature extraction network extracts features from the initial target area, generates template features, and initializes the tracker.
[0279] S307 , after the tracking device in the camera hardware abstraction layer obtains the n+1th frame image (tracking frame), it calls the tracker in the camera algorithm library.
[0280] S308. The tracking network in the tracker responds to the call of the tracking device, performs a target search on the n+1th frame image according to the template features, and determines the target position and the target confidence corresponding to the target position; the target position is used to characterize the position of the target in the n+1th frame image.
[0281] S309, the tracking network determines whether the target confidence is greater than the confidence threshold; if so, execute step S310; if not, execute step S313.
[0282] S310, the tracking network generates tracking success information; the tracking success information is used to indicate that the target tracking is successful.
[0283] S311. The tracking network returns the target position and tracking success information to the tracking device of the camera hardware abstraction layer.
[0284] S312: After receiving the tracking success information, the tracking device generates a first tracking identifier corresponding to the target location according to the target location.
[0285] Afterwards, the n+1th frame image and the tracking mark are displayed on the interface of the electronic device.
[0286] S313, the tracking network generates tracking failure information; the tracking failure information is used to indicate target tracking failure, that is, tracking loss.
[0287] S314: The tracking network returns the target position and tracking failure information to the tracking device of the camera hardware abstraction layer.
[0288] S315: After receiving the tracking failure information, the tracking device stops tracking.
[0289] The above steps S306 to S315 are consistent with steps S106 to S115 in the first embodiment and are not described in detail.
[0290] The target tracking method provided in the embodiment of the present application detects the tracking stability of the initial target after obtaining the initial target area. If the tracking stability meets the requirements, feature extraction is performed on the target area and target tracking is enabled; otherwise, target tracking is not enabled. In this way, after target tracking is enabled, the possibility of tracking loss is small, the stability and continuity of target tracking are improved, and the user experience is improved.
[0291] The following is a further explanation of the tracking stability detection process.
[0292] For example, Fig.17 A schematic diagram of a flow chart of a tracking stability detection process provided in an embodiment of the present application, Fig.18 This is a schematic diagram of the principle of tracking stability detection provided in the embodiment of this application. Please refer to Fig.17 and Fig.18 In the above step S304, "detecting whether the tracking stability of the initial target area meets the requirements" includes the following steps. The execution body of the following steps can be a stability detection module, which will not be repeated.
[0293] S401, extracting features from the initial target area to generate template features.
[0294] Optionally, the stability detection module can perform feature extraction, or the stability detection module can input the initial target area into the template feature extraction network, and the template feature extraction network extracts the generated template features and returns them to the stability detection module. This embodiment of the application does not impose any limitation on this.
[0295] The feature extraction process is similar to the above step S306, except that this step only performs template feature extraction and does not initialize the tracker, that is, does not start target tracking.
[0296] S402: In the nth frame image, scale transformation and / or translation transformation are performed on the border of the initial target area to obtain Z transformation frames, where Z is an integer greater than or equal to 1.
[0297] Optionally, the scale transformation refers to changing the size of the border of the initial target area. The scale transformation may include compression, expansion, etc., that is, reducing or expanding the border of the initial target area. Optionally, the translation transformation refers to translating the border of the initial target area to change its position in the image. The direction of the translation transformation may be vertically upward, vertically downward, horizontally to the left, horizontally to the right, diagonally to the upper left, or diagonally to the lower right, etc. The scale transformation and / or translation transformation of the border of the initial target area includes: scaling the border of the initial target area, translation transformation of the border of the initial target area, or both scaling and translation transformation of the border of the initial target area. The frame after the transformation of the border of the initial target area is called a transformation frame.
[0298] The bounding box of the initial target area can be expressed as b0 = {cx0, cy0, w0, h0}, and the transformation box can be expressed as: b n (s, t) = g(t, f(s, b0)). f(s, b0) means that the border b0 of the initial target area is scaled by a scale factor of s, and g(t, f(s, b0)) means that the scaled frame is translated by a scale factor of x. The scale factor s and the translation factor x can be set as required. For example, the scale factor s can be 0.8, which means that the border of the initial target area is reduced to 80% of the original; the translation factor x can be 0.3, which means that the border of the initial target area is translated by 30% in a certain direction.
[0299] See also Fig.18 In the nth frame image, after the user clicks position 1, the border 1801 of the initial target area is determined. The border 1801 of the initial target area is compressed and then translated upward, downward, leftward, and rightward to obtain four transformation frames, as shown in image 1802 in the figure. The transformation frame in image 1802 can be represented as b s ={cx i ,cy i , w i ,h i}, i∈[0,4).
[0300] The border 1801 of the initial target area is dilated, and then translated upward, downward, leftward, and rightward to obtain four transformed frames, as shown in the image 1803 in the figure. The transformed frame in the image 1803 can be represented as b l ={cx j , cx j , w j ,h j}, j∈[0,4).
[0301] It can be understood that step S402 is essentially used to implement data augmentation of the initial target area to obtain the area defined by the transformation frame (hereinafter referred to as the transformation area). In some other embodiments, other methods can also be used to perform data augmentation on the initial target area to obtain multiple transformation areas, such as rotation, flipping, adjusting grayscale, contrast, etc., and the embodiments of the present application do not impose any limitation on this.
[0302] S403. According to the template features, target searches are performed on the areas defined by each transformation frame (i.e., transformation areas) respectively to determine the target position in each transformation area and the target confidence corresponding to the target position (a total of Z target positions and corresponding Z target confidences are obtained).
[0303] Specifically, for any transformation region a, feature extraction is performed on the transformation region to obtain search feature a. The search feature is matched with the template feature, that is, the correlation between the two is calculated to obtain the target position a in the transformation region and the target confidence a corresponding to the target position a.
[0304] In other words, in this step, each transformed area is used as a tracking area, and the target search is performed respectively with reference to the implementation process of the above step S308.
[0305] In this step, the zth of the Z target positions obtained can be expressed as The target confidence corresponding to the z-th target position can be expressed as ρ z , z∈Z.
[0306] S404: Determine the number T of the Z target confidences that are greater than the confidence threshold. T is greater than or equal to 0 and less than or equal to Z.
[0307] That is, determine the target confidence ρ z Whether it satisfies ρ z >ρ th , z∈Z.
[0308] If the target confidence corresponding to a certain transformation area is greater than the confidence threshold, it means that there is a target in the transformation area, that is, the tracking result of the target tracking in the transformation area is successful.
[0309] S405. Determine whether the number T greater than the confidence threshold is greater than a preset number Y; if so, determine that the stability requirement is met; if not, determine that the stability requirement is not met.
[0310] That is, determine whether ∑(p z >P th)>Y. The number T greater than the confidence threshold is greater than the preset number Y, indicating that there are targets in more of the Z transformation areas, that is, when performing target tracking on the Z transformation areas, more transformation areas can be successfully tracked, indicating that the target in the initial target area can be tracked more stably and the target is not easily lost. Therefore, it is indicated that there is a significant target in the initial target area, and it is determined that the tracking stability of the initial target area meets the requirements. Therefore, step S406 is executed to start target tracking. Otherwise, it means that there are no targets in more of the Z transformation areas, that is, when performing target tracking on the Z transformation areas, more transformation areas fail to track, indicating that the target in the initial target area cannot be tracked more stably and the target is easily lost. Therefore, it is indicated that there is no significant target in the initial target area, and it is determined that the tracking stability of the initial target area does not meet the requirements.
[0311] The value of the preset number Y can be determined according to the number of transform frames Z. For example, when Z is 8, the preset number Y can be 6, 7, 8, etc. The larger the preset number Y is, the higher the tracking stability requirement is, the more difficult it is for the initial target area to meet the tracking stability requirement, and the less likely it is to start target tracking. And vice versa.
[0312] In a specific embodiment, the preset number Y=ceil(Z*0.7), where Z represents the number of transformation frames, that is, the number of transformation areas. Ceil(x) represents a ceiling function, which means rounding a real number upward. Determining the preset number according to this formula can make the value of the preset number Y related to the number of transformation frames Z, and the size is appropriate, so that the tracking stability requirement is neither too high nor too low, and starting target tracking is neither too difficult nor too easy, thereby improving the user experience.
[0313] In addition, when setting the scale factor s and the translation factor x, the larger the scale factor s and / or the translation factor x, the larger the transformation scale, the more difficult it is to meet the tracking stability requirements, and the smaller the possibility of starting target tracking. And vice versa.
[0314] For example, Fig.19 The following table shows the different tracking stability test results corresponding to different scale factors. Fig.19 Figure (a) in FIG. 1 is a schematic diagram of the initial target area. When the scale factor s is 0.8 and the translation factor x is 0.3, the tracking stability test is performed according to the above steps S401 to S405. If the tracking stability requirements are not met, the target tracking is not enabled, and only the target frame is displayed in the interface, such as Fig.19 When the scale factor s is 1.0 and the translation factor x is 0.3, the tracking stability test is performed according to the above steps S401 to S405. If the tracking stability requirements are met, target tracking is started and the tracking mark is displayed in the interface, as shown in FIG. Fig.19 When the scale factor s is 1.0 and the translation factor x is 0.1, the tracking stability test is performed according to the above steps S401 to S405. If the tracking stability requirements are met, target tracking is started and the tracking mark is displayed in the interface, as shown in FIG. Fig.19 As shown in Figure (d).
[0315] It can be understood that the above process is equivalent to using Z transformation areas to simulate the tracking area in the subsequent tracking frame in the video stream, and simulating the process of tracking the target in the initial target area to judge the stability of the tracking. If it is stable, it means that the subsequent actual tracking success rate is high and it is not easy to lose the tracking, so the target tracking can be turned on. If it is unstable, it means that the subsequent actual tracking success rate is low and it is easy to lose the tracking, so the target tracking is not turned on. In this way, on the one hand, if the tracking is turned on, the tracking stability is high, which improves the user experience. On the other hand, if the tracking is not turned on, it can prevent the waste of resources. This method can simply and accurately judge the tracking stability.
[0316] Optionally, in one embodiment, when it is determined that the tracking stability of the initial target area meets the requirements, after starting the target tracking, the template feature extraction of the initial target area may no longer be performed, and the template feature generated in the above step S401 may be directly used to perform target tracking. In this way, the calculation process can be simplified and the algorithm operation efficiency can be improved.
[0317] Embodiment three:
[0318] This embodiment mainly describes a target tracking method involving both target area adjustment and tracking stability detection.
[0319] The hardware structure of the electronic device to which the target tracking method provided in this embodiment is applicable may be the same as that of Embodiments 1 and 2, and will not be described in detail.
[0320] For example, Fig. 20 This is a schematic diagram of the system architecture of another electronic device provided in an embodiment of the present application. Fig. 20 As shown, the software architecture of the electronic device to which the target tracking method provided in this embodiment is applicable is similar to that of the first and second embodiments, except that, in this embodiment, the tracker includes both a region adjustment module and a stability detection module.
[0321] In this embodiment, the stability detection module is used to perform tracking stability detection on the adjustment target area adjusted by the area adjustment module. The functions of other modules refer to the first and second embodiments and will not be described in detail.
[0322] In short, the target tracking method provided in this embodiment can combine the solutions of the above-mentioned embodiment 1 and the above-mentioned embodiment 2. First, the initial target area is adjusted by the method provided in the above-mentioned embodiment 1 to obtain the adjusted target area. After that, the tracking stability of the adjusted target area is detected, and the tracking is started after it is determined that the tracking stability of the adjusted target area meets the requirements, otherwise the tracking is not started. The specific implementation process and beneficial effects of the target tracking method provided in this embodiment can be referred to the above-mentioned embodiment 1 and embodiment 2, and will not be repeated here.
[0323] The above describes in detail an example of a target tracking method provided by an embodiment of the present application. It is understandable that, in order to implement the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to exceed the scope of the present application.
[0324] The embodiment of the present application can divide the functional modules of the electronic device according to the above method example. For example, each function can be divided into various functional modules, such as a detection unit, a processing unit, a display unit, etc., or two or more functions can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0325] It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.
[0326] The electronic device provided in this embodiment is used to execute the above-mentioned target tracking method, and thus can achieve the same effect as the above-mentioned implementation method.
[0327] In the case of an integrated unit, the electronic device may further include a processing module, a storage module and a communication module. The processing module may be used to control and manage the actions of the electronic device. The storage module may be used to support the electronic device to execute stored program codes and data, etc. The communication module may be used to support the electronic device to communicate with other devices.
[0328] Among them, the processing module can be a processor or a controller. It can implement or execute various exemplary logic boxes, modules and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a device that interacts with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, etc.
[0329] In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device involved in this embodiment may be a Figure 7 Device of the structure shown.
[0330] An embodiment of the present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the processor executes the target tracking method of any of the above embodiments.
[0331] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement the target tracking method in the above-mentioned embodiment.
[0332] In addition, an embodiment of the present application also provides a device, which may specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor may execute the computer-executable instructions stored in the memory so that the chip executes the target tracking method in the above-mentioned method embodiments.
[0333] Among them, the electronic device, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here.
[0334] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0335] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, 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.
[0336] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0337] 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.
[0338] 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 readable storage medium. Based on this understanding, the technical solution of the embodiment 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, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0339] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A target tracking method, characterized in that: include: Display a first shooting interface, where a first area of the first shooting interface is used to display a video stream captured by a camera; When the first area displays an nth frame image of the video stream, receiving a first operation input by a user at a first position of the nth frame image, where n is a positive integer and the nth frame image contains a target; In response to the first operation, determining a first target area in the nth frame image according to the first position, wherein the first target area includes a first part of the target; According to the first target area, determining a second target area in the nth frame image, wherein the second target area includes a second part of the target, and an area of the second part is larger than an area of the first part; Based on the nth frame image, data augmentation is performed on the second target area to obtain a plurality of transformed areas; Performing target search on the multiple transformation areas respectively, and determining the position of the target in each of the transformation areas and the corresponding confidence level; If it is determined that the number of first transformation areas among the multiple transformation areas is greater than a preset number, the target in the n+xth frame image of the video stream is tracked based on the second target area, x is a positive integer, and the confidence corresponding to the first transformation area is greater than a confidence threshold.
2. The method according to claim 1, characterized in that The step of determining a second target area in the nth frame image according to the first target area includes: Determine a region of interest in the nth frame image according to the first target region, wherein the region of interest includes the first target region; Performing image segmentation on the region of interest to obtain multiple sub-regions; Determine the minimum bounding rectangles of the multiple sub-areas respectively; Determine overlap rates of multiple candidate regions and the first target region respectively, and obtain multiple overlap rates corresponding to the multiple candidate regions one by one, wherein the candidate regions are regions defined by the minimum circumscribed rectangle in the nth frame image; A candidate area corresponding to a maximum overlap rate among the multiple overlap rates is determined as the second target area.
3. The method according to claim 2, characterized in that Tracking the target in the n+xth frame image of the video stream based on the second target area includes: If the maximum overlap rate is greater than a preset overlap threshold, the target in the (n+x)th frame image of the video stream is tracked based on the second target area.
4. The method according to claim 3, characterized in that The method further comprises: If the maximum overlap rate is less than or equal to the preset overlap threshold, the target in the (n+x)th frame image of the video stream is tracked based on the first target area.
5. The method according to claim 2, characterized in that: The image segmentation of the region of interest is performed to obtain a plurality of sub-regions, including: Performing Gaussian blur processing on the region of interest to obtain a blurred image; Performing color-based k-means clustering on the blurred image to obtain multiple clusters; Using the multiple clusters as masks respectively, performing binary mask processing on the blurred image to obtain multiple binary mask images corresponding to the multiple clusters one by one; Based on the multiple binary mask images, a connected region extraction operation is performed to obtain the multiple sub-regions.
6. The method according to claim 5, characterized in that The performing of a connected domain operation based on the plurality of binary mask images comprises: Performing median filtering on the multiple binary mask images respectively to obtain multiple filtered images; Based on the multiple filtered images, a connected domain operation is performed to obtain the multiple sub-regions.
7. The method according to claim 6, characterized in that Based on the multiple filtered images, a connected domain operation is performed to obtain the multiple sub-regions: Performing a connected domain extraction operation on the plurality of filtered images respectively to obtain a plurality of connected domains; Calculating the areas of the multiple connected domains respectively; Connected domains whose areas are smaller than an area threshold are filtered out from the multiple connected domains to obtain the multiple sub-regions.
8. The method according to claim 2, characterized in that: The respectively determining the overlap ratios of the plurality of candidate regions with the first target region to obtain a plurality of overlap ratios corresponding to the plurality of candidate regions one by one includes: The intersection-and-union ratios of the multiple candidate regions and the first target region are respectively calculated to obtain the multiple overlap rates.
9. The method according to any one of claims 1 to 8, characterized in that Tracking the target in the n+xth frame image of the video stream based on the second target area includes: Extracting features from the second target area to obtain template features; According to the template features, the position of the target in the (n+x)th frame image of the video stream and the corresponding confidence level are determined.
10. A target tracking method, characterized in that: include: Display a first shooting interface, where a first area of the first shooting interface is used to display a video stream captured by a camera; When the first area displays an nth frame image of the video stream, receiving a first operation input by a user at a first position in the nth frame image, where n is a positive integer; In response to the first operation, determining a third target area in the nth frame image according to the first position, wherein the third target area includes part or all of the target; Based on the n-th frame image, data augmentation is performed on the third target region to obtain a plurality of transformed regions; Performing target search on the multiple transformation areas respectively, and determining the position of the target in each of the transformation areas and the corresponding confidence level; If the number of first transformation areas among the multiple transformation areas is greater than a preset number, the target in the n+xth frame image of the video stream is tracked based on the third target area, x is a positive integer, and the confidence corresponding to the first transformation area is greater than a confidence threshold.
11. The method according to claim 10, characterized in that The method further comprises performing data augmentation on the third target region based on the n-th frame image to obtain a plurality of transformed regions, including: In the n-th frame image, performing at least one of a scale transformation and a translation transformation on the frame of the third target area to obtain a plurality of transformation frames; The area defined by each transformation frame is determined as the transformation area.
12. The method according to claim 11, characterized in that The direction of the translation transformation includes at least one of vertically upward, vertically downward, horizontally leftward, horizontally rightward, diagonally upward to the left, and diagonally downward to the right.
13. The method according to claim 10, characterized in that Determining a third target area in the nth frame image according to the first position includes: According to the first position and in accordance with a preset size, the third target area is determined in the nth frame image.
14. The method according to any one of claims 10 to 13, characterized in that Determining a third target area in the nth frame image according to the first position includes: Determine a first target area in the nth frame image according to the first position and a preset size, wherein the first target area includes a first part of the target; The third target region is determined in the nth frame image according to the first target region, and the second part of the target contained in the third target region has an area greater than that of the first part.
15. The method according to claim 14, characterized in that The step of determining the third target area in the nth frame image according to the first target area includes: Determine a region of interest in the nth frame image according to the first target region, wherein the region of interest includes the first target region; Performing image segmentation on the region of interest to obtain multiple sub-regions; Determine the minimum bounding rectangles of the multiple sub-areas respectively; Determine overlap rates of multiple candidate regions and the first target region respectively, and obtain multiple overlap rates corresponding to the multiple candidate regions one by one, wherein the candidate regions are regions defined by the minimum circumscribed rectangle in the nth frame image; A candidate region corresponding to a maximum overlap rate among the multiple overlap rates is determined as the third target region.
16. An electronic device, characterized in that: include: Processors, memory, and interfaces; The processor, the memory and the interface cooperate with each other so that the electronic device executes the method as claimed in any one of claims 1 to 15.
17. A chip system, characterized in that: The method comprises a processor; the processor is used to read and execute a computer program stored in a memory to perform the method according to any one of claims 1 to 15.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 15.
