Method and device for determining object position

By using the gradient main direction consistency intensity in the image set to determine the candidate box and the target positioning box, the problem of low accuracy of R code positioning in the prior art is solved, and more efficient R code recognition is achieved.

CN114462440BActive Publication Date: 2025-02-14ZHEJIANG HUARAY TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210135545.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-14
Publication Date
2025-02-14
Estimated Expiration
2042-02-14

AI Technical Summary

Technical Problem

In the prior art, the positioning accuracy of R codes is low and it is impossible to effectively identify R codes in complex scenarios.

Method used

By acquiring the image set, the candidate box set is determined using the gradient main direction consistency intensity within the preset window, and the target positioning box is determined therein to determine the position of the target object on the original image.

Benefits of technology

It improves the accuracy of positioning of R codes and can more effectively identify R codes in complex scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114462440B_ABST
    Figure CN114462440B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a method and device for determining the position of an object, comprising: obtaining an image set, wherein the image set includes an original image, and the original image includes a target object; obtaining a candidate frame set according to the gradient of each image in the image set in a preset window; determining a target positioning frame in the candidate frame set, and determining the target positioning frame as the position of the target object on the original image. Through the present invention, the problem of low positioning accuracy of the dimensional code is solved, thereby achieving the effect of improving the positioning accuracy of the dimensional code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of image recognition, and in particular, to a method and device for determining the position of an object. Background Art

[0002] Through the use of dimensional codes (for example, one-dimensional codes, two-dimensional codes, etc.), it is applied in various fields of life, such as commodity sales and postal logistics. Dimensional codes are usually barcode coding graphics composed of a group of regularly arranged "bars" and "spaces". They have a small area, record a large amount of information, are easy to promote and attach, and improve industry efficiency. In the process of dimensional code recognition, the positioning of the dimensional code is crucial.

[0003] Existing dimensional code recognition technologies all involve a large number of morphological operations. However, algorithms that use morphological operations to recognize dimensional codes are difficult to implement and time-consuming. They are unable to cope with dimensional codes in complex scenarios and cannot accurately recognize dimensional codes.

[0004] There is currently no effective solution to the problem of low positioning accuracy of QR codes in the prior art. Summary of the invention

[0005] The embodiments of the present invention provide a method and device for determining the position of an object, so as to at least solve the problem of low positioning accuracy of a 2D code in the related art.

[0006] According to one embodiment of the present invention, a method for determining an object position is provided, comprising: acquiring an image set, wherein the image set includes an original image, and the original image includes a target object; obtaining a candidate frame set based on the gradient of each image in the image set in a preset window; determining a target positioning frame in the candidate frame set, and determining the target positioning frame as the position of the target object on the original image.

[0007] In an exemplary embodiment, a candidate frame set is obtained based on the gradient of each image in an image set in a preset window, including: performing the following operations on each image in the image set, where each image during the following operations is a current image: traversing the current image through a preset window, obtaining the main direction consistency strength of the gradient of the current image on the preset window, and obtaining a set of main direction consistency strengths of the gradient of the current image; obtaining a candidate frame of the current image based on a set of main direction consistency strengths of the gradient of the current image, wherein the candidate frame set includes the candidate frame of the current image.

[0008] In an exemplary embodiment, obtaining the main direction consistency strength of the gradient of the current image on a preset window includes: obtaining the gradient direction of each pixel in the preset window, and the gradient strength corresponding to the gradient direction, to obtain a set of gradient directions and a set of gradient strengths of the preset window; and determining the main direction consistency strength of the gradient of the current image on the preset window according to the set of gradient directions and a set of gradient strengths of the preset window.

[0009] In an exemplary embodiment, the main direction consistency strength of the gradient of the current image on the preset window is determined based on a set of gradient directions and a set of gradient strengths of the preset window, including: mapping a set of gradient directions and corresponding gradient strengths to multiple preset direction areas, and determining a preset direction area with the largest sum of corresponding gradient strengths in the multiple preset direction areas as a target preset direction area; determining the ratio of the sum of the gradient strengths in the target preset direction area to the target sum as the main direction consistency strength of the gradient of the current image on the preset window, wherein the target sum is the sum of a set of gradient strengths.

[0010] In an exemplary embodiment, a candidate frame of the current image is obtained based on a set of gradient main direction consistency strengths of the current image, including: binarizing a set of gradient main direction consistency strengths to obtain a binarized image of the current image; and obtaining a candidate frame of the current image by performing connected domain analysis on the binarized image.

[0011] In an exemplary embodiment, determining a target positioning frame in a candidate frame set includes: determining a candidate frame in the candidate frame set whose aspect ratio meets a preset condition as the target positioning frame; or determining a candidate frame in the candidate frame set whose foreground ratio meets a preset condition as the target positioning frame; or determining a candidate frame in which pixels meet a preset condition as the target positioning frame.

[0012] In an exemplary embodiment, multiple candidate frames are obtained based on the gradients of images in an image set on a preset window: when the image set only includes original images, a candidate frame set is obtained based on the gradients of the original images on the preset window; when the image set also includes thumbnail images, a candidate frame set is obtained based on the gradients of the original images and thumbnail images in the image set on the preset window, wherein the thumbnail image is an image obtained by reducing the original image.

[0013] According to another embodiment of the present invention, a device for determining an object position is provided, comprising: an acquisition module, used to acquire an image set, wherein the image set includes an original image, and the original image includes a target object; an analysis module, used to obtain a candidate frame set according to the gradient of each image in the image set in a preset window; and a determination module, used to determine a target positioning frame in the candidate frame set, and determine the target positioning frame as the position of the target object on the original image.

[0014] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when run.

[0015] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0016] Through the present invention, since the gradient direction in the one-dimensional code area is very consistent, the candidate frame with the same gradient direction in the image can be found through the gradient in the preset window in the image, so that the position of the one-dimensional code in the image can be determined. Therefore, the problem of low positioning accuracy of the two-dimensional code can be solved, and the positioning accuracy of the two-dimensional code is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is a hardware structure block diagram of a mobile terminal according to a method for determining an object position according to an embodiment of the present invention;

[0018] Figure 2 is a flow chart of a method for determining a position of an object according to an embodiment of the present invention;

[0019] Figure 3 is a schematic diagram of a preset window traversing a current image according to an embodiment of the present invention;

[0020] Figure 4 is a schematic diagram of performing connected domain analysis on a binary graph according to an embodiment of the present invention;

[0021] Figure 5 is a schematic diagram of target positioning frames determined on images of different sizes after being restored to the original image according to an embodiment of the present invention;

[0022] Figure 6 is a schematic diagram of a preferred method for determining the position of an object according to an embodiment of the present invention;

[0023] Figure 74 is a structural block diagram of a device for determining a position of an object according to an embodiment of the present invention. DETAILED DESCRIPTION

[0024] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0026] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 is a hardware structure block diagram of a mobile terminal according to a method for determining an object position according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0027] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for determining the position of an object in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0028] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0029] In this embodiment, a method for determining the position of an object is provided. Figure 2 is a flow chart of a method for determining an object position according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:

[0030] Step S202, obtaining an image set, wherein the image set includes an original image, and the original image includes a target object;

[0031] The target object is a dimensional code, including but not limited to a one-dimensional code, a two-dimensional code, a three-dimensional code, etc. The original image is an image obtained by photographing an object containing a dimensional code through an image acquisition device.

[0032] Step S204, obtaining a candidate frame set according to the gradient of each image in the image set in a preset window;

[0033] The size of the preset window may be set according to actual conditions, such as 0.5 cm*0.5 cm, 1.5*1.5 cm, 1 cm*1 cm, etc.

[0034] Step S206 , determining a target positioning frame in the candidate frame set, and determining the target positioning frame as the position of the target object on the original image.

[0035] Through the above steps, the problem of low positioning accuracy of the dimensional code is solved, and the positioning accuracy of the dimensional code is improved.

[0036] The execution subject of the above steps may be a terminal or an image processing device, and the execution subject of the above steps may also be other processing devices or processing units with similar processing capabilities, but is not limited thereto. The following takes the image processing device executing the above operations as an example (only an exemplary description, in actual operation, other devices or modules may also be used to execute the above operations) for description.

[0037] In this embodiment, taking the above target object as a one-dimensional code as an example, to identify the position of the one-dimensional code in a picture, first, an image set is obtained, which includes the original image and a thumbnail image obtained by extracting some pixels from the original image according to certain rules. In each image in the image set, some candidate frames are obtained according to the gradient features in the preset window to form a candidate frame collection, and the target positioning frame is determined in the candidate frames in the candidate frame collection. The position of the target frame in the image is the position of the one-dimensional code in the picture to be identified.

[0038] In an exemplary embodiment, a candidate frame set is obtained based on the gradient of each image in an image set in a preset window, including: performing the following operations on each image in the image set, where each image during the following operations is a current image: traversing the current image through a preset window, obtaining the main direction consistency strength of the gradient of the current image on the preset window, and obtaining a set of main direction consistency strengths of the gradient of the current image; obtaining a candidate frame of the current image based on a set of main direction consistency strengths of the gradient of the current image, wherein the candidate frame set includes the candidate frame of the current image.

[0039] In this embodiment, a preset window of a preset size is selected in the current image, and the preset window traverses the current image. When the preset window is at different positions on the current image, the main direction consistency strength of the gradient in the preset window is different. After the preset window traverses the entire current image, a set of main direction consistency strengths of the gradient of the current image can be obtained. According to the set of main direction consistency strengths of the gradient in the current image, multiple candidate boxes are obtained in the current image.

[0040] Figure 3 This is a schematic diagram of a preset window traversing a current image according to an embodiment of the present invention. Assume that the current image contains 9×13 pixels, where each small box represents a pixel, and the size of the preset window is selected to be 3×3. The traversal of the preset window on the current image is completed by moving the position of the preset window.

[0041] It should be noted that when moving the position of the preset window, the preset window after moving may have overlapping parts with the preset window before moving. Whether there is overlapping part depends on the distance the preset window is moved each time. However, the pixels at the same relative position in different windows must be different pixels. For example, the center pixel points in preset windows at different positions must be different.

[0042] In an exemplary embodiment, obtaining the main direction consistency strength of the gradient of the current image on a preset window includes: obtaining the gradient direction of each pixel in the preset window, and the gradient strength corresponding to the gradient direction, to obtain a set of gradient directions and a set of gradient strengths of the preset window; and determining the main direction consistency strength of the gradient of the current image on the preset window according to the set of gradient directions and a set of gradient strengths of the preset window.

[0043] In this embodiment, there are multiple pixel points in the preset window, each pixel point in the preset window corresponds to a gradient strength and a gradient direction, a set of gradient directions of the preset window includes the gradient directions corresponding to all pixel points in the preset window, and a set of gradient strengths of the preset window includes the gradient strengths corresponding to all pixel points in the preset window; a set of gradient directions and a set of gradient strengths corresponding to a preset window can determine the consistency strength of the main gradient direction on the current preset window.

[0044] In an exemplary embodiment, the main direction consistency strength of the gradient of the current image on the preset window is determined based on a set of gradient directions and a set of gradient strengths of the preset window, including: mapping a set of gradient directions and corresponding gradient strengths to multiple preset direction areas, and determining a preset direction area with the largest sum of corresponding gradient strengths in the multiple preset direction areas as a target preset direction area; determining the ratio of the sum of the gradient strengths in the target preset direction area to the target sum as the main direction consistency strength of the gradient of the current image on the preset window, wherein the target sum is the sum of a set of gradient strengths.

[0045] In this embodiment, each pixel point in the preset window corresponds to a gradient direction and a gradient strength. If there are multiple pixel points, there may be multiple strength directions. All possible strength directions are divided into multiple preset direction areas, and the sum of the gradient strengths in each preset direction area is calculated. The sum of a group of gradient strengths in the preset window is calculated, and the preset area with the largest sum of gradient strengths in the preset direction area is the target preset direction area, that is, the strongest direction area. The ratio of the sum of the gradient strengths in the target preset direction area to the sum of a group of gradient strengths in the preset window is calculated, and the above ratio is the gradient main direction consistency strength of the preset window.

[0046] For example, the possible direction range of all gradient directions is 0 to 180 degrees (180 to 360 degrees can be converted to the direction of 0 to 180 degrees), and the direction of 0 to 180 degrees is evenly divided into 18 preset direction areas, that is, 0 to 10 degrees is the first preset direction area, 10 to 20 degrees is the second preset direction area, ... 170 to 180 degrees is the eighteenth preset direction area, and the gradient intensities corresponding to a set of gradient directions in the preset window are mapped to the 18 direction areas. For example, if the gradient intensity on a pixel point is 50 and the gradient direction is 15 degrees, then the gradient direction of this pixel point is mapped to the second preset direction area, and the gradient intensity of the second preset direction area is added by 50.

[0047] The sum of the gradient intensities in the 18 preset direction areas is compared, and the preset direction area with the largest sum of gradient intensities is taken as the maximum direction area. For example, the maximum sum of the gradient intensities in the 18 preset direction areas is 800, and the corresponding preset direction area is the third preset direction area (20-30 degrees). The sum of a group of gradient intensities in the preset window is 1000, and the consistency strength of the main gradient direction of the preset window is 800÷1000=0.8, and the main gradient direction of the preset window is the third preset direction area.

[0048] It should be noted that after the preset window traverses the current image, a set of gradient main direction consistency strengths of the current image is obtained, and the gradient main direction consistency strength calculated in each preset window is used as the gradient main direction consistency strength of the target pixel point in the corresponding preset window to obtain the gradient main direction consistency strength map of the current image, where the target pixel point can be the center pixel point of the current preset window. The gradient main direction consistency strength map of the current image obtained in this way is smaller than the current image because only some pixels are extracted, but it can avoid overlapping parts when the window moves, which is inconvenient for binarization.

[0049] It should be noted that before calculating the gradient main direction consistency strength corresponding to the preset window, the sum of a set of gradient strengths in the preset window is compared with the size of the first threshold. When the sum of a set of gradient strengths in the preset window is greater than or equal to the first threshold, the gradient main direction consistency strength corresponding to the preset window is calculated according to the above method. When the sum of a set of gradient strengths in the preset window is less than the first threshold, the gradient main direction consistency strength corresponding to the current preset window is directly set to zero.

[0050] In an exemplary embodiment, a candidate frame of the current image is obtained based on a set of gradient main direction consistency strengths of the current image, including: binarizing a set of gradient main direction consistency strengths to obtain a binarized image of the current image; and obtaining a candidate frame of the current image by performing connected domain analysis on the binarized image.

[0051] In this embodiment, a group of gradient main direction consistency strengths in the current image are binarized, the grayscale values ​​of pixels whose gradient main direction consistency strength is less than a second threshold are set to 0, and the grayscale values ​​of pixels whose gradient main direction consistency strength is greater than or equal to the second threshold are set to 255, to obtain a binary image of the current image, and a connected domain analysis is performed on the above binary image. Adjacent pixels whose grayscale values ​​are 255 are found on the binary image to obtain multiple connected domains. For each connected domain, a minimum bounding box is set, and the obtained minimum bounding box is determined as a candidate box of the current image, indicating the possible position of the one-dimensional code in the current image.

[0052] Figure 4 is a schematic diagram of performing connected domain analysis on a binary graph according to an embodiment of the present invention, such as Figure 4 As shown, adjacent pixels with a gray value of 255 are found on the binary image to obtain multiple connected domains, and the smallest outer bounding box is set on the connected domains. In the figure, 401, 402, and 403 are candidate boxes determined on the current image.

[0053] In an exemplary embodiment, determining a target positioning frame in a candidate frame set includes: determining a candidate frame in the candidate frame set whose aspect ratio meets a preset condition as the target positioning frame; or determining a candidate frame in the candidate frame set whose foreground ratio meets a preset condition as the target positioning frame; or determining a candidate frame in which pixels meet a preset condition as the target positioning frame.

[0054] In this embodiment, for the candidate frames in the candidate frame set, the frame has the characteristic of consistent main gradient direction, but the candidate frame with this characteristic is not necessarily the position of the QR code. For example, if there is a black and white striped dress in the target image, then the dress will also be determined as a candidate frame when determining the candidate frame above. That is to say, there may be a target frame that is not a one-dimensional code in the candidate frame. Through the above steps, the target positioning frame corresponding to the one-dimensional code can be found in the candidate frame.

[0055] It should be noted that the aspect ratio of the one-dimensional code is relatively fixed, and the candidate boxes that meet the preset conditions can be screened out by the preset aspect ratio to determine as the target positioning box; for example Figure 4 The aspect ratio of the candidate box 402 is 1, which is obviously not the location of the one-dimensional code; or,

[0056] If the gradient direction at the location of the one-dimensional code is very consistent, then the foreground ratio in the candidate frame where the one-dimensional code is located should also be high, where the pixel with a grayscale value of 255 in the candidate frame is the foreground in the candidate frame, and the ratio of the number of pixels with a grayscale value of 255 in the candidate frame to the number of all pixels in the candidate frame is called the foreground ratio. When the foreground ratio in the candidate frame is less than the third threshold, it is considered that the corresponding candidate frame is not the location of the one-dimensional code. When the foreground ratio in the candidate frame is greater than or equal to the third threshold, it is considered that the corresponding candidate frame is the location of the one-dimensional code and is determined as the target positioning frame, for example Figure 4 The foreground of candidate box 403 in the image is very small, and it is obviously not the location of the one-dimensional code; or,

[0057] Since the pixels corresponding to the one-dimensional code in the image have other features, candidate frames that do not meet the requirements can be screened out through other features, and candidate frames that meet the preset conditions can be used as target positioning frames. For example, the one-dimensional code is alternating between black and white bars, so the pixels of different pixels are also different. The pixels corresponding to the black bars are darker, and the pixels corresponding to the daytime are brighter. The target positioning frame can also be confirmed based on this feature.

[0058] In an exemplary embodiment, multiple candidate frames are obtained based on the gradients of images in an image set on a preset window: when the image set only includes original images, a candidate frame set is obtained based on the gradients of the original images on the preset window; when the image set also includes thumbnail images, a candidate frame set is obtained based on the gradients of the original images and thumbnail images in the image set on the preset window, wherein the thumbnail image is an image obtained by reducing the original image.

[0059] In this embodiment, the original image is first obtained, and by jumping points on the original image, a thumbnail image of a different size from the original image can be obtained based on the original image. By jumping points multiple times, multiple thumbnail images of different sizes can be obtained, and the target positioning frame is determined in the above original image and all thumbnail images respectively. The jumping points are to select pixels on the original image according to a certain rule, for example, starting from the first pixel, a pixel is selected every other pixel, and the selected pixels form the thumbnail images. Figure 1 Or, select one pixel every two pixels, and the selected pixels form a thumbnail Figure 2 .

[0060] In addition, the target positioning frames determined on different images can be restored to the original image. At this time, the target positioning frames determined at different sizes can be seen on the original image. These target positioning frames can be compared, sorted and screened on the original image. If the overlapping area of ​​at least two target positioning frames among all the target positioning frames is greater than the fourth threshold, the corresponding target positioning frames are scored according to the features of the pixels in the target positioning frames, the target positioning frame with the highest score is retained, and other target positioning frames overlapping with it are removed.

[0061] Figure 5 is a schematic diagram of the target positioning frames determined on images of different sizes according to an embodiment of the present invention after being restored to the original image, such as Figure 5 As shown in the figure, after being restored to the original image, the original image shows three target positioning frames, including: target positioning frame 501, target positioning frame 502, and target positioning frame 503, wherein target positioning frame 501 includes pixel points A1-A10, target positioning frame 502 includes pixel points A3-A12, and target positioning frame 503 includes pixel points B1-B10. Target positioning frame 501 is determined on the original image, and target positioning frame 502 is determined on thumbnail image 1. Frame 504 is the overlapping part of target positioning frame 501 and target positioning frame 502, frame 504 includes pixel points A3-A10, and target positioning frame 503 is determined on thumbnail image 2. Target positioning frame 501 and target positioning frame 502 overlap in a large area, and the target positioning frame 501 and target positioning frame 502 are corresponding according to the characteristics of the pixel points in the target positioning frame, and the target positioning frame with a high score is retained.

[0062] Obviously, the above-described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0063] The present invention will be specifically described below in conjunction with embodiments:

[0064] Figure 6 is a schematic diagram of a preferred method for determining the position of an object according to an embodiment of the present invention. Figure 6 As shown, the following steps are included:

[0065] Step 602, find the gradient strength and direction of the single-channel image. On the basis of the original image, find the gradient strength and direction of each pixel. The gradient strength and direction can be found by using the Sobel operator to find the gradient strength and direction in the horizontal and vertical directions, and then calculate the gradient strength and direction of the whole image, or by using the Canny operator or a self-designed gradient operator to find the gradient strength and direction of the whole image.

[0066] Step 604, determining a positioning frame corresponding to the one-dimensional code on the first-layer pyramid image, wherein the first-layer pyramid image is consistent in size with the original image;

[0067] Step 606, determining a positioning frame corresponding to the one-dimensional code on the second-layer pyramid image, wherein the second-layer pyramid image is obtained by jumping points in the first-layer pyramid image, for example, selecting a pixel point every other pixel point in the first-layer pyramid image to obtain the second-layer pyramid image;

[0068] Step 608, determining a positioning frame corresponding to the one-dimensional code on the third-layer pyramid image; the third-layer pyramid image is obtained by jumping points in the second-layer pyramid image;

[0069] Step 610, the positioning frames are summarized and sorted; the three-layer pyramid image is restored to the original image, and compared, merged and sorted.

[0070] The following steps are performed on the images of step 604, step 606 and step 608 to determine the positioning frame corresponding to the one-dimensional code on the current image:

[0071] Step 61, count the main direction of the gradient in the window, combine the gradient strength, and obtain the main direction consistency strength map of the gradient. The main direction consistency strength map of the gradient includes: dividing all possible gradient directions into 36 areas (0-180 degrees), selecting an appropriate window size, superimposing the gradient strength in the window to each direction area, setting a threshold, calculating the ratio of the sum of the strengths in the neighborhood of the strongest direction to the sum of the strengths in the window, and using this as the main direction consistency strength of the gradient at the current point, to obtain a main direction consistency strength map of the gradient for the entire image, or calculating the main direction consistency strength of the gradient by other methods such as weighted superposition.

[0072] Step 62, binarize the gradient main direction consistency intensity map, segment the foreground, set the minimum threshold, and binarize the consistency intensity map in combination with the local threshold. The local threshold can be calculated by using mean filtering, median filtering, maximum filtering, etc.;

[0073] Step 63, performing connected domain analysis on the binary image to obtain a candidate minimum enclosing rectangular frame;

[0074] Step 64, filter out the outer frames that do not meet the requirements, adjust the one-dimensional code positioning frame, check all the minimum outer frames, filter out non-code frames using width and height configuration, aspect ratio, foreground proportion, and space characteristics within the frame, and rotate, expand, and shrink the candidate one-dimensional code positioning frame using characteristics such as the main direction within the frame.

[0075] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0076] In this embodiment, a device for determining the position of an object is also provided. Figure 7 is a structural block diagram of an apparatus for determining an object position according to an embodiment of the present invention, such as Figure 7 As shown, the device comprises:

[0077] An acquisition module 72, configured to acquire an image set, wherein the image set includes an original image, and the original image includes a target object;

[0078] An analysis module 74, configured to obtain a candidate frame set according to the gradient of each image in the image set in a preset window;

[0079] The determination module 76 is used to determine a target positioning frame in the candidate frame set, and determine the target positioning frame as the position of the target object on the original image.

[0080] In an exemplary embodiment, the above-mentioned analysis module is also used to perform the following operations on each image in the image set, and each image during the following operations is the current image: traversing the current image through a preset window, obtaining the gradient main direction consistency strength of the current image on the preset window, and obtaining a set of gradient main direction consistency strengths of the current image; based on a set of gradient main direction consistency strengths of the current image, obtaining a candidate box of the current image, wherein the candidate box set includes the candidate box of the current image.

[0081] In an exemplary embodiment, the above-mentioned analysis module is also used to obtain the gradient direction of each pixel in a preset window, and the gradient strength corresponding to the gradient direction, to obtain a set of gradient directions and a set of gradient strengths of the preset window; based on the set of gradient directions and a set of gradient strengths of the preset window, determine the main gradient direction consistency strength of the current image on the preset window.

[0082] In an exemplary embodiment, the above-mentioned analysis module is also used to map a set of gradient directions and corresponding gradient strengths to multiple preset direction areas, and determine the preset direction area with the largest sum of corresponding gradient strengths in the multiple preset direction areas as the target preset direction area; and determine the ratio of the sum of gradient strengths in the target preset direction area to the target sum as the gradient main direction consistency strength of the current image in the preset window, wherein the target sum is the sum of a set of gradient strengths.

[0083] In an exemplary embodiment, the above-mentioned analysis module is also used to binarize a set of gradient main direction consistency strengths to obtain a binary image of the current image; and obtain a candidate frame of the current image by performing connected domain analysis on the binary image.

[0084] In an exemplary embodiment, the above-mentioned determination module is also used to determine the target positioning frame from the candidate frame set whose aspect ratio meets the preset conditions; or, determine the candidate frame from the candidate frame set whose foreground ratio meets the preset conditions as the target positioning frame; or, determine the candidate frame from the candidate frame whose pixels meet the preset conditions as the target positioning frame.

[0085] In an exemplary embodiment, the above-mentioned analysis module is also used to: when the image set only includes the original image, obtain a candidate frame set according to the gradient of the original image on the preset window; when the image set also includes thumbnail images, obtain a candidate frame set according to the gradient of the original image and the thumbnail image in the image set on the preset window, wherein the thumbnail image is an image obtained by reducing the original image.

[0086] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0087] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0088] In this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:

[0089] S1, obtaining an image set, wherein the image set includes an original image, and the original image includes a target object;

[0090] S2, obtaining a set of candidate boxes based on the gradient of each image in the preset window in the image set;

[0091] S3, determining a target positioning frame in the candidate frame set, and determining the target positioning frame as the position of the target object on the original image.

[0092] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0093] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

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

[0095] In an exemplary embodiment, the processor may be configured to perform the following steps via a computer program:

[0096] S1, obtaining an image set, wherein the image set includes an original image, and the original image includes a target object;

[0097] S2, obtaining a set of candidate boxes based on the gradient of each image in the preset window in the image set;

[0098] S3, determining a target positioning frame in the candidate frame set, and determining the target positioning frame as the position of the target object on the original image.

[0099] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0100] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0101] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for determining the position of an object, characterized in that: include: Acquire an image set, wherein the image set includes an original image, and the original image includes a target object; Obtaining a candidate frame set according to the gradient of each image in the image set in a preset window; Determine a target positioning frame in the candidate frame set, and determine the target positioning frame as the position of the target object on the original image; Wherein, the method further comprises: Obtaining a gradient direction of each pixel in the preset window and a gradient strength corresponding to the gradient direction, to obtain a set of gradient directions and a set of gradient strengths of the preset window; Calculating the sum of the set of gradient intensities to obtain a target sum; When the target sum is greater than or equal to the first threshold, mapping a set of gradient directions and corresponding gradient intensities to a plurality of preset direction regions, and determining a preset direction region having the largest sum of corresponding gradient intensities among the plurality of preset direction regions as a target preset direction region; Determine the ratio of the sum of the gradient strengths in the target preset direction area to the target sum as the main direction consistency strength of the gradient in the preset window; When the target sum is less than the first threshold, the main direction consistency strength of the gradient on the preset window is set to zero.

2. The method according to claim 1, characterized in that According to the gradient of each image in the image set in the preset window, a candidate frame set is obtained, including: Perform the following operations on each image in the image set, where each image in the following operations is a current image: Traversing the current image through a preset window, obtaining the main direction consistency strength of the gradient of the current image on the preset window, and obtaining a set of main direction consistency strengths of the gradient of the current image; A candidate box of the current image is obtained according to the set of gradient main direction consistency strengths of the current image, wherein the candidate box set includes the candidate box of the current image.

3. The method according to claim 2, characterized in that The obtaining, according to the set of main direction consistency strengths of the gradients of the current image, a candidate frame of the current image comprises: Binarizing the set of gradient main direction consistency strengths to obtain a binary image of the current image; By performing connected domain analysis on the binary image, a candidate frame of the current image is obtained.

4. The method according to claim 1, characterized in that: Determining a target positioning frame from the candidate frame set includes: Determine the target positioning frame by taking the candidate frames whose aspect ratios meet the preset conditions in the candidate frame set; or, Determine the candidate frame whose foreground ratio in the candidate frame set meets the preset condition as the target positioning frame; or The candidate frame whose pixels in the candidate frame meet the preset conditions is determined as the target positioning frame.

5. The method according to any one of claims 1 to 4, characterized in that According to the gradient of the images in the image set on the preset window, multiple candidate boxes are obtained: In a case where the image set includes only the original image, obtaining the candidate frame set according to a gradient of the original image on a preset window; In the case where the image set also includes thumbnail images, the candidate frame set is obtained according to the gradient of the original image and the thumbnail image in the image set on the preset window, wherein the thumbnail image is an image obtained by reducing the original image.

6. A device for determining the position of an object, characterized in that: include: An acquisition module, used for acquiring an image set, wherein the image set includes an original image, and the original image includes a target object; An analysis module, used to obtain a candidate frame set according to the gradient of each image in the image set in a preset window; A determination module, configured to determine a target positioning frame from the candidate frame set, and determine the target positioning frame as the position of the target object on the original image; The device is also used to obtain the gradient direction of each pixel in the preset window, and the gradient strength corresponding to the gradient direction, to obtain a group of gradient directions and a group of gradient strengths of the preset window; calculate the sum of the group of gradient strengths to obtain a target sum; when the target sum is greater than or equal to a first threshold, map a group of gradient directions and corresponding gradient strengths to multiple preset direction areas, and determine the preset direction area with the largest sum of corresponding gradient strengths in the multiple preset direction areas as the target preset direction area; determine the ratio of the sum of gradient strengths in the target preset direction area to the target sum as the gradient main direction consistency strength in the preset window; when the target sum is less than the first threshold, set the gradient main direction consistency strength in the preset window to zero.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 5 when executed by a processor.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Complex background bar code segmentation and reading method based on machine vision

    CN107633192A

  • Bar code area positioning method and device

    CN111027343A

  • Barcode identification method and device

    CN112950540A

  • Target identification method and related equipment

    CN113705660A