Attention detection-based region selection method and terminal
Through the area selection method based on attention detection, the image is first scaled and the target object is judged, the coordinates and detection frame size are recorded, and the image is then cropped and scaled again, which solves the problem of information loss caused by image reduction and improves the accuracy of image processing and efficiency.
Patent Information
- Application Number
- CN202411046671.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-22
AI Technical Summary
During image processing, image reduction will lead to loss of key information, affecting the correct detection of target objects.
Using the area selection method based on attention detection, first zoom the image to a preset size to determine whether the target object is included. If included, record the target coordinates and detection frame size, and then crop and scale the image again based on this information to ensure that the image is in Keep key information during the shrinking process.
In the case of image reduction, as much information as possible can be retained to avoid excessive reduction of key information, thereby improving the accuracy and efficiency of subsequent recognition.
Smart Images

Figure CN119006783A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a region selection method and terminal based on attention detection. Background Art
[0002] In the image processing process, neural networks are often used in the prior art to identify objects in images or classify images. In this process, the smaller the input image is, the smaller the amount of calculation of the neural network will be, and the faster the neural network can process the image. However, directly reducing the image will lead to the loss of key information. For example, the target object will be too small in the image after being reduced, resulting in the target object not being able to be correctly detected. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a region selection method and terminal based on attention detection, so as to achieve the goal of not losing key information when the image is reduced.
[0004] In order to solve the above technical problems, a technical solution adopted by the present invention is:
[0005] A region selection method based on attention detection comprises the steps of:
[0006] Acquire an image to be tested, and scale the image to be tested to a first preset size to obtain a scaled image;
[0007] Determine whether the zoomed image includes a target object, and if so, output the target coordinates of the target object on the zoomed image and the size of the target detection frame;
[0008] A new image to be tested is acquired, and after the new image to be tested is cropped according to the target coordinates and the target detection frame size to obtain a cropped image, the cropped image is returned as the image to be tested to execute the step of scaling the image to be tested to a first preset size to obtain a scaled image.
[0009] In order to solve the above technical problems, another technical solution adopted by the present invention is:
[0010] A region selection terminal based on attention detection includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0011] Acquire an image to be tested, and scale the image to be tested to a first preset size to obtain a scaled image;
[0012] Determine whether the zoomed image includes a target object, and if so, output the target coordinates of the target object on the zoomed image and the size of the target detection frame;
[0013] A new image to be tested is acquired, and after the new image to be tested is cropped according to the target coordinates and the target detection frame size to obtain a cropped image, the cropped image is returned as the image to be tested to execute the step of scaling the image to be tested to a first preset size to obtain a scaled image.
[0014] The beneficial effects of the present invention are as follows: after acquiring the image to be tested, it is first scaled to a first preset size to obtain a scaled image and then an attempt is made to acquire the target object therein; if the target object can be identified at this time, the target coordinates and the corresponding target detection frame size are recorded; after acquiring a new image to be tested, the new image to be tested is cropped according to the target coordinates and the target detection frame size and then scaled and the target object is identified; thereby, in scenarios where images are continuously acquired such as video detection, the recognition result of the previous image can be learned to crop and scale the corresponding area of the target object in the subsequent image, i.e., the area of interest; while reducing the image size, as much required information as possible can be retained to avoid over-reduction of key information during the reduction process, thereby affecting subsequent recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 A flowchart of the steps of a method for selecting a region based on attention detection according to an embodiment of the present invention;
[0016] Figure 2 Another step flow chart of a method for selecting an area based on attention detection according to an embodiment of the present invention;
[0017] Figure 3 A schematic diagram of the structure of a terminal for selecting an area based on attention detection according to an embodiment of the present invention;
[0018] Description of labels:
[0019] 1. A region selection terminal based on attention detection; 2. A processor; 3. A memory. DETAILED DESCRIPTION
[0020] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0021] Please refer to Figure 1 , a region selection method based on attention detection, comprising the steps of:
[0022] Acquire an image to be tested, and scale the image to be tested to a first preset size to obtain a scaled image;
[0023] Determine whether the zoomed image includes a target object, and if so, output the target coordinates of the target object on the zoomed image and the size of the target detection frame;
[0024] A new image to be tested is acquired, and after the new image to be tested is cropped according to the target coordinates and the target detection frame size to obtain a cropped image, the cropped image is returned as the image to be tested to execute the step of scaling the image to be tested to a first preset size to obtain a scaled image.
[0025] From the above description, it can be seen that the beneficial effects of the present invention are: after obtaining the image to be tested, it is first scaled to a first preset size to obtain a scaled image and then an attempt is made to obtain the target object therein. If the target object can be identified at this time, the target coordinates and the corresponding target detection frame size are recorded. After obtaining a new image to be tested, the new image to be tested is cropped according to the target coordinates and the target detection frame size and then scaled and the target object is identified. Therefore, in scenarios where images are continuously acquired such as video detection, the recognition result of the previous image can be learned to crop and scale the corresponding area of the target object in the subsequent image, that is, the area of interest. While reducing the image size, the required information can be retained as much as possible to avoid excessive reduction of key information during the reduction process, thereby affecting subsequent recognition.
[0026] Furthermore, the determining whether the zoomed image includes the target object further includes:
[0027] If the target object is not included in the scaled image, the image to be tested is cropped and divided into a preset number of partial images, the partial images are traversed, and the traversed target partial images are scaled to a first preset size to obtain a target scaled image; it is determined whether the target scaled image includes the target object, and if so, the step of outputting the target coordinates of the target object on the scaled image and the size of the target detection frame is performed with the target scaled image as the scaled image; otherwise, the traversal is continued;
[0028] If after the traversal is finished, each target zoomed image does not include the target object, it is determined whether an end instruction is received, and if so, the loop is ended, otherwise, the step of obtaining the image to be tested is continued.
[0029] It can be seen from the above description that if the target object is not included in the scaled image after scaling, it means that the target object may have been reduced to an unrecognizable degree during scaling. Therefore, the image to be tested before scaling is reacquired at this time, and a preset number of partial images are cropped out. The partial images are cropped and scaled one by one and then judged. By cropping and then scaling, it is avoided that the target object is over-reduced and cannot be clearly acquired during the process of scaling the image to be tested to the first preset size; and if the target object is not found in the partial images after scaling, it is considered that the corresponding target object does not exist in the image to be tested, and a new image to be tested is obtained for detection in a cycle; if the target object is found in the partial image after scaling, the coordinates of the target object and the size of the detection frame are also obtained, and subsequent pictures can be directly cropped based on the target coordinates and the size of the target detection frame, eliminating the process of obtaining partial images.
[0030] Furthermore, all the partial images are spliced together to obtain the image to be tested.
[0031] From the above description, it can be known that the image to be tested can be obtained by splicing all partial images, that is, in the process of segmenting and then reducing the image to be tested, it is ensured that each part of the image to be tested can be processed, avoiding omission of information.
[0032] Furthermore, after outputting the target coordinates of the target object on the zoomed image and the size of the target detection frame, the method further includes:
[0033] Determine whether the end instruction is received, if so, end the loop;
[0034] Otherwise, the step of acquiring a new image to be tested is executed.
[0035] From the above description, it can be seen that if an end instruction is received, the image processing is terminated, otherwise a new image to be tested is continuously acquired. During the processing of each image to be tested, the calibration result of the previous image to be tested is referred to, thereby reducing the amount of data processing.
[0036] Furthermore, the outputting of the target coordinates of the target object on the zoomed image and the size of the target detection frame includes:
[0037] The target coordinates of the target object on the zoomed image are converted into target coordinates on the image to be measured and then output.
[0038] From the above description, it can be seen that the unified target coordinates are the coordinates on the original image to be tested. Since the video frame images in the video or the continuously shot images are usually obtained by the same machine, after obtaining the new image to be tested, it can be directly cropped according to the target coordinates and the target detection frame size without converting the coordinates.
[0039] Please refer to Figure 3 , a region selection terminal based on attention detection, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0040] Acquire an image to be tested, and scale the image to be tested to a first preset size to obtain a scaled image;
[0041] Determine whether the zoomed image includes a target object, and if so, output the target coordinates of the target object on the zoomed image and the size of the target detection frame;
[0042] A new image to be tested is acquired, and after the new image to be tested is cropped according to the target coordinates and the target detection frame size to obtain a cropped image, the cropped image is returned as the image to be tested to execute the step of scaling the image to be tested to a first preset size to obtain a scaled image.
[0043] From the above description, it can be seen that the beneficial effects of the present invention are: after obtaining the image to be tested, it is first scaled to a first preset size to obtain a scaled image and then an attempt is made to obtain the target object therein. If the target object can be identified at this time, the target coordinates and the corresponding target detection frame size are recorded. After obtaining a new image to be tested, the new image to be tested is cropped according to the target coordinates and the target detection frame size and then scaled and the target object is identified. Therefore, in scenarios where images are continuously acquired such as video detection, the recognition result of the previous image can be learned to crop and scale the corresponding area of the target object in the subsequent image, that is, the area of interest. While reducing the image size, the required information can be retained as much as possible to avoid excessive reduction of key information during the reduction process, thereby affecting subsequent recognition.
[0044] Furthermore, the determining whether the zoomed image includes the target object further includes:
[0045] If the target object is not included in the scaled image, the image to be tested is cropped and divided into a preset number of partial images, the partial images are traversed, and the traversed target partial images are scaled to a first preset size to obtain a target scaled image; it is determined whether the target scaled image includes the target object, and if so, the step of outputting the target coordinates of the target object on the scaled image and the size of the target detection frame is performed with the target scaled image as the scaled image; otherwise, the traversal is continued;
[0046] If after the traversal is finished, each target zoomed image does not include the target object, it is determined whether an end instruction is received, and if so, the loop is ended, otherwise, the step of obtaining the image to be tested is continued.
[0047] It can be seen from the above description that if the target object is not included in the scaled image after scaling, it means that the target object may have been reduced to an unrecognizable degree during scaling. Therefore, the image to be tested before scaling is reacquired at this time, and a preset number of partial images are cropped out. The partial images are cropped and scaled one by one and then judged. By cropping and then scaling, it is avoided that the target object is over-reduced and cannot be clearly acquired during the process of scaling the image to be tested to the first preset size; and if the target object is not found in the partial images after scaling, it is considered that the corresponding target object does not exist in the image to be tested, and a new image to be tested is obtained for detection in a cycle; if the target object is found in the partial image after scaling, the coordinates of the target object and the size of the detection frame are also obtained, and subsequent pictures can be directly cropped based on the target coordinates and the size of the target detection frame, eliminating the process of obtaining partial images.
[0048] Furthermore, all the partial images are spliced together to obtain the image to be tested.
[0049] From the above description, it can be known that the image to be tested can be obtained by splicing all partial images, that is, in the process of segmenting and then reducing the image to be tested, it is ensured that each part of the image to be tested can be processed, avoiding omission of information.
[0050] Furthermore, after outputting the target coordinates of the target object on the zoomed image and the size of the target detection frame, the method further includes:
[0051] Determine whether the end instruction is received, if so, end the loop;
[0052] Otherwise, the step of acquiring a new image to be tested is executed.
[0053] From the above description, it can be seen that if an end instruction is received, the image processing is terminated, otherwise a new image to be tested is continuously acquired. During the processing of each image to be tested, the calibration result of the previous image to be tested is referred to, thereby reducing the amount of data processing.
[0054] Furthermore, the outputting of the target coordinates of the target object on the zoomed image and the size of the target detection frame includes:
[0055] The target coordinates of the target object on the zoomed image are converted into target coordinates on the image to be measured and then output.
[0056] From the above description, it can be seen that the unified target coordinates are the coordinates on the original image to be tested. Since the video frame images in the video or the continuously shot images are usually obtained by the same machine, after obtaining the new image to be tested, it can be directly cropped according to the target coordinates and the target detection frame size without converting the coordinates.
[0057] The above-mentioned area selection method based on attention detection and terminal of the present invention can be applied to image preprocessing, especially preprocessing of videos or continuously shot images. The preprocessed images are then passed through a classification network or a recognition network, etc., to improve the efficiency of subsequent network image processing while ensuring accuracy. The following is an explanation through specific implementation methods.
[0058] Please refer to Figure 1-2 , Embodiment 1 of the present invention is:
[0059] A region selection method based on attention detection comprises the steps of:
[0060] S1, obtaining the image to be tested;
[0061] Divide the video into video frames as the images to be tested, or directly obtain continuously shot photos as the images to be tested;
[0062] S2, scaling the image to be tested to a first preset size to obtain a scaled image;
[0063] In an optional embodiment, the first preset size is 60% to 70% of the original size of the image to be tested; it can be set according to different scaling effects, for example, 60%, 65% or 70%; it can also be set according to the input size required by the specific image recognition model, for example, 600×600 pixels;
[0064] S3, determining whether the zoomed image includes the target object, if so, executing S4; otherwise, executing S5;
[0065] In an optional implementation, it can be determined whether the target object is included by an existing image recognition network; for example, YOLO series, SSD (Single Shot MultiBox Detector, a target detection algorithm) algorithm, etc.
[0066] S4, outputting the target coordinates of the target object on the zoomed image and the size of the target detection frame and executing S6;
[0067] In an optional implementation, the target coordinates of the target object on the zoomed image are converted into target coordinates on the image to be measured and then output;
[0068] In an optional implementation, the size of the initial image to be measured is used as a reference to record the scaling ratio, and the target coordinates are converted according to the scaling ratio;
[0069] S5, cutting the image to be tested into a preset number of partial images, traversing the partial images, scaling the traversed target partial image to a first preset size to obtain a target scaled image; determining whether the target scaled image includes the target object, if so, executing S4 with the target scaled image as the scaled image; otherwise, continuing the traversal;
[0070] In an optional implementation, if there are multiple types of target objects, then when one of the target objects is detected, it is considered that the image includes the target object; in this way, the efficiency of image processing is improved;
[0071] If after the traversal is finished, each target zoomed image does not include the target object, it is determined whether an end instruction is received, if so, the loop is ended, otherwise, S1 is continued to be executed;
[0072] In an optional implementation, all partial images are spliced together to obtain an image to be tested;
[0073] In an optional embodiment, the image to be tested is divided into a preset number of partial images after being cropped, including: the image to be tested is divided according to the preset number to obtain a plurality of preset areas; when the preset area is traversed, the preset area is cropped into partial images; in this way, the preset area is cropped only when the preset area is traversed, and if the target object is detected in the middle, there is no need to continue cropping, and there is no need to store the entire image to be tested in the form of partial images again, thereby saving storage space;
[0074] Taking cropping the image to be tested into the first preset image and the second preset image as an example: after acquiring the image to be tested, cropping the first partial image of the image to be tested, and scaling the first partial image to a first preset size to obtain a first scaled image; judging whether the first scaled image includes a target object, if so, executing S4 with the first scaled image as the scaled image; otherwise, cropping the second partial image of the image to be tested after acquiring the image to be tested, and scaling the second partial image to the first preset size to obtain a second scaled image;
[0075] Determine whether the second zoomed image includes the target object. If so, execute S4 with the second zoomed image as the zoomed image; otherwise, determine whether an end instruction is received. If so, end the loop, otherwise continue to execute S1;
[0076] In an optional implementation, the first partial image and the second partial image are spliced to obtain the image to be tested; for example, a left half image and a right half image or an upper half image and a lower half image;
[0077] It can be seen that after the image to be tested is reduced, some image features will be lost, so the target object may not be found. Therefore, if the target object cannot be obtained in the reduced image, the image is cut and the target object is detected on the cut image. When the detection network remains unchanged, the image details can be better found to avoid missing the target object. The image cutting can be confirmed according to the size of the target object and set as large as possible than the target object to avoid the target object being cut. Alternatively, a detection network that can match local features is used to detect the target object, so that the accuracy of target object detection can be guaranteed even when the target object is cut. The balance between efficiency and detection accuracy is achieved through the combination of image reduction and cropping.
[0078] In an optional implementation, a judgment step is further included between S4 or S5 and S6: S01, judging whether an end instruction is received, and if so, ending the loop;
[0079] Otherwise, execute S6;
[0080] In an optional implementation manner, the end instruction in this embodiment includes: determining whether it is the last image to be tested, and if so, receiving the end instruction; or determining whether the end instruction input by the user is received;
[0081] S6, obtaining a new image to be tested, cropping the new image to be tested according to the target coordinates and the target detection frame size to obtain a cropped image, and returning the cropped image as the image to be tested to execute S2;
[0082] In an optional embodiment, the cropping position of the new image to be tested is determined according to the target coordinates, and a cropping size that is the same as the size of the target detection frame or larger than a preset value is determined; the new image to be tested is cropped according to the cropping position and the cropping size to obtain a cropped image; the preset value can be set as a fixed value based on experience or according to the length and width of the target object, and the length and width increased by the preset value correspond to the length and width of the target object or a multiple of the length and width, thereby avoiding the situation where the target object is cropped due to excessive moving speed during movement.
[0083] Please refer to Figure 2 , Embodiment 2 of the present invention is:
[0084] A region selection terminal 1 based on attention detection includes a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, each step in the first embodiment is implemented.
[0085] In summary, the present invention provides a region selection method and terminal based on attention detection, which firstly scales the acquired image to be tested to a first preset size, performs a large frame search after scaling, and if the target is not detected, crops the image to be tested to obtain a partial image, and searches in the partial image, thereby avoiding blurring of important information during the reduction process, and can control the data processing amount of each image to improve the image processing efficiency; if the target object can be detected, the target coordinates and the target detection frame size of the target object are obtained, and when preprocessing the next image to be tested, it is cropped according to the target coordinates and the target detection frame obtained from the previous image to be tested, thereby reducing the processing data while ensuring to the greatest extent that key information is not missed.
[0086] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A region selection method based on attention detection, It is characterized in that Includes steps: Acquire an image to be tested, and scale the image to be tested to a first preset size to obtain a scaled image; Determine whether the zoomed image includes a target object, and if so, output the target coordinates of the target object on the zoomed image and the size of the target detection frame; A new image to be tested is acquired, and after the new image to be tested is cropped according to the target coordinates and the target detection frame size to obtain a cropped image, the cropped image is returned as the image to be tested to execute the step of scaling the image to be tested to a first preset size to obtain a scaled image.
2. According to the method for selecting a region based on attention detection in claim 1, It is characterized in that The determining whether the zoomed image includes the target object further includes: If the target object is not included in the scaled image, the image to be tested is cropped and divided into a preset number of partial images, the partial images are traversed, and the traversed target partial images are scaled to a first preset size to obtain a target scaled image; it is determined whether the target scaled image includes the target object, and if so, the step of outputting the target coordinates of the target object on the scaled image and the size of the target detection frame is performed with the target scaled image as the scaled image; otherwise, the traversal is continued; If after the traversal is finished, each target zoomed image does not include the target object, it is determined whether an end instruction is received, and if so, the loop is ended, otherwise, the step of obtaining the image to be tested is continued.
3. The method for selecting a region based on attention detection according to claim 2, It is characterized in that All the partial images are spliced together to obtain the image to be tested.
4. The method for selecting a region based on attention detection according to claim 1, It is characterized in that After outputting the target coordinates of the target object on the zoomed image and the size of the target detection frame, the following further comprises: Determine whether the end instruction is received, if so, end the loop; Otherwise, the step of acquiring a new image to be tested is executed.
5. The method for selecting a region based on attention detection according to claim 1, It is characterized in that Outputting the target coordinates of the target object on the zoomed image and the size of the target detection frame includes: The target coordinates of the target object on the zoomed image are converted into target coordinates on the image to be measured and then output.
6. A region selection terminal based on attention detection, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the following steps are implemented: Acquire an image to be tested, and scale the image to be tested to a first preset size to obtain a scaled image; Determine whether the zoomed image includes a target object, and if so, output the target coordinates of the target object on the zoomed image and the size of the target detection frame; A new image to be tested is acquired, and after the new image to be tested is cropped according to the target coordinates and the target detection frame size to obtain a cropped image, the cropped image is returned as the image to be tested to execute the step of scaling the image to be tested to a first preset size to obtain a scaled image.
7. The area selection terminal based on attention detection according to claim 6, It is characterized in that The determining whether the zoomed image includes the target object further includes: If the target object is not included in the scaled image, the image to be tested is cropped and divided into a preset number of partial images, the partial images are traversed, and the traversed target partial images are scaled to a first preset size to obtain a target scaled image; it is determined whether the target scaled image includes the target object, and if so, the step of outputting the target coordinates of the target object on the scaled image and the size of the target detection frame is performed with the target scaled image as the scaled image; otherwise, the traversal is continued; If after the traversal is finished, each target zoomed image does not include the target object, it is determined whether an end instruction is received, and if so, the loop is ended, otherwise, the step of obtaining the image to be tested is continued.
8. The area selection terminal based on attention detection according to claim 7, It is characterized in that All the partial images are spliced together to obtain the image to be tested.
9. The area selection terminal based on attention detection according to claim 6, It is characterized in that After outputting the target coordinates of the target object on the zoomed image and the size of the target detection frame, the following further comprises: Determine whether the end instruction is received, if so, end the loop; Otherwise, the step of acquiring a new image to be tested is executed.
10. The area selection terminal based on attention detection according to claim 6, It is characterized in that Outputting the target coordinates of the target object on the zoomed image and the size of the target detection frame includes: The target coordinates of the target object on the zoomed image are converted into target coordinates on the image to be measured and then output.
