Detection reference area determination method and device, equipment and medium
By determining the method of detecting the benchmark area in the image processing, the target vector point, vector edge and scanning line technology are used to remove redundant points, improve the swimming coding conversion efficiency, and solve the problem of low image processing efficiency in existing technologies.
Patent Information
- Application Number
- CN202411471590.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-01-24
AI Technical Summary
When the prior art is used to detect the reference area in image processing, the presence of redundant points leads to low conversion efficiency of image coordinates to run encoding, limiting the implementation efficiency of object detection and tracking.
By obtaining multiple target vector points based on target image input, connect to form multiple vector edges, and use horizontal scanning lines to scan each vector side side to determine the intersection array. Convert the array of the intersection to the travel coding to generate the benchmark area.
Effectively remove redundant points, improve the conversion efficiency of image coordinates to run-length coding, improve the generation efficiency of detection reference areas, and accelerate the image target detection and tracking process.
Smart Images

Figure CN119359679A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method for determining a detection reference area, a device for determining a detection reference area, a detection device, and a computer-readable storage medium. Background Art
[0002] Currently, when the inspection equipment uses the camera module to shoot and detect the size, dirt and other qualities of the workpiece installed on the fixture, it is necessary to perform target detection and target tracking on the captured image. During this processing, it is usually necessary to determine the region of interest for the target. Generally, the image coordinates of the region of interest can be converted to run-length encoding using technologies such as polygonal scan line conversion algorithms, but most of the image coordinates determined by these algorithms are redundant, resulting in slow conversion efficiency and limiting the efficiency of image target detection and tracking. Summary of the invention
[0003] In view of this, the purpose of the present application is to provide a detection reference area determination method, a detection reference area determination device, a detection equipment and a computer-readable storage medium, which can remove redundant points and improve the conversion efficiency of image coordinates to run-length coding.
[0004] In order to solve the above technical problems, the present application provides a method for determining a detection reference area, comprising:
[0005] Acquire a plurality of target vector points based on the target image input, wherein the plurality of target vector points are input one by one in sequence;
[0006] Connecting the target vector points adjacent to each other based on the input sequence of the plurality of target vector points to form a plurality of vector edges;
[0007] Scan each of the vector edges using a horizontal scan line to determine an array of intersection points of the scan line on each of the vector edges;
[0008] Determining redundant intersection points between two adjacent vector edges based on directions of the two adjacent vector edges;
[0009] Deleting the redundant intersection points to update the intersection point array corresponding to the vector edge;
[0010] The updated intersection array on each of the vector edges is converted into run-length encoding to generate a detection reference area in the target image.
[0011] Optionally, the acquiring a plurality of target vector points based on the target image input includes:
[0012] Acquire multiple original points input one by one by the user based on the target image;
[0013] Forming a plurality of initial vector points based on the plurality of original points and the order in which the original points are input one by one in sequence;
[0014] A deduplication operation is performed on the multiple initial vector points to obtain the multiple target vector points.
[0015] Optionally, the performing a deduplication operation on the plurality of initial vector points includes:
[0016] The original point having the same coordinates is retained.
[0017] Optionally, scanning each of the vector edges using a horizontal scan line to determine an array of intersection points of the scan line on each of the vector edges includes:
[0018] Allowing the horizontal scan line to scan the plurality of vector edges with a fixed step length to determine an intersection point between the horizontal scan line and each of the vector edges;
[0019] Based on the intersection points of the horizontal scan line and each of the vector edges, the intersection point array on each of the vector edges is determined.
[0020] Optionally, the determining the redundant intersection points between two adjacent vector edges based on the directions of the two adjacent vector edges comprises:
[0021] If the directions of the two adjacent vector edges are: the first vector edge is upward and the second vector edge is downward, it is determined that the redundant intersection does not exist in the intersection array on the second vector edge; otherwise, the first intersection in the intersection array on the second vector edge is determined as the redundant intersection.
[0022] Optionally, converting the updated intersection array on each of the vector edges into run-length encoding to generate a detection reference area in the target image includes:
[0023] Traversing the intersection array on each of the vector edges to extract a row array, a start column array and an end column array for representing the run-length coding; wherein the row array records the start row coordinates and the end row coordinates of each intersection in each intersection array; the start column array records the start column coordinates of each intersection in each intersection array; and the end column array records the end column coordinates of each intersection in each intersection array;
[0024] The detection reference area enclosed by a plurality of the target vector points in the target image is determined according to the row array, the start column array and the end column array.
[0025] Optionally, before scanning each of the vector edges using a horizontal scan line, the method further includes:
[0026] The slope of the vector edge is determined based on the target vector point, and two adjacent vector edges with equal slopes are merged.
[0027] A detection reference area determination device, comprising:
[0028] An acquisition module, used for acquiring a plurality of target vector points based on a target image input, wherein the plurality of target vector points are input one by one in sequence;
[0029] An edge processing module, configured to connect the target vector points adjacent to each other based on the input sequence of the plurality of target vector points to form a plurality of vector edges;
[0030] A scanning module, used for scanning each of the vector edges using a horizontal scanning line to determine an array of intersection points of the scanning line on each of the vector edges;
[0031] A point processing module, used for determining redundant intersection points between two adjacent vector edges based on the directions of the two adjacent vector edges;
[0032] A deletion module, used for deleting the redundant intersection points to update the intersection point array on the corresponding vector edge;
[0033] A generating module is used to convert the updated intersection array on each of the vector edges into run-length encoding to generate a detection reference area in the target image.
[0034] The present application also provides a detection device, comprising: a memory for storing a computer program;
[0035] A processor, electrically connected to the memory, and configured to execute the computer program to implement the above-mentioned method for determining the detection reference area;
[0036] The photographing device is electrically connected to the memory and the processor, and is used to pre-process, detect, track or identify the target object based on the detection reference area, so as to obtain an image of the target object.
[0037] The present application also provides a computer-readable storage medium for storing a computer program, wherein the computer program implements the above-mentioned detection reference area determination method when executed by a processor.
[0038] The detection reference area determination method provided by the present application is based on multiple target vector points input one by one in sequence. First, the target vector points with adjacent positions are connected based on the input order of the multiple target vector points to form multiple vector edges, and then each vector edge is scanned using a horizontal scan line to determine the intersection array of the scan line on each vector edge. Then, based on the directions of the two adjacent vector edges, the redundant intersections in the two adjacent vector edges are determined, and the redundant intersections are deleted to update and reduce the number of points in the intersection array on the corresponding vector edge; finally, the intersection array on each vector edge after the update is converted into run-length encoding to generate a detection reference area in the target image.
[0039] It can be seen that this method can use multiple target vector points input by the user as the basis for processing the detection reference area of the workpiece, thereby improving the accuracy of the detection reference area, and determine the redundant intersection points in two adjacent vector edges through the direction information of the adjacent vector edges, and remove the redundant intersection points, thereby achieving the reduction of the number of points in the intersection array on each vector edge. Based on this, the run-length encoding conversion efficiency and the generation efficiency of the detection reference area can be improved, and the target detection and tracking process of the image can also be accelerated.
[0040] In addition, the present application also provides a detection reference area determination device, a detection equipment and a computer-readable storage medium, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0042] Figure 1 A schematic diagram of the structure of a detection device provided in an embodiment of the present application;
[0043] Figure 2 A flow chart of a method for determining a detection reference area provided in an embodiment of the present application;
[0044] Figure 3 A schematic diagram of connecting a vector edge and corresponding points provided in an embodiment of the present application;
[0045] Figure 4 A schematic diagram of a scanning process provided in an embodiment of the present application;
[0046] Figure 5 A schematic diagram of an array record of a run-length encoding provided in an embodiment of the present application;
[0047] Figure 6A schematic diagram of the structure of a detection reference area determination device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0049] Each step in this application can be performed by a designated detection device, the form of which is not limited, for example, it can be a general computing device such as a computer or a server. Figure 1 , Figure 1 A structural diagram of a detection device provided in an embodiment of the present application, wherein the detection device 100 may include a processor 101 and a memory 102 , and may further include one or more of a multimedia component 103 , an information input / information output (I / O) interface 104 , and a communication component 105 .
[0050] The processor 101 is used to control the overall operation of the detection device 100 to complete all or part of the steps in the detection reference area determination method (to be described below); the memory 102 is used to store various types of data to support the operation of the detection device 100, and these data may include, for example, instructions for any application or method used to operate on the detection device 100, and data related to the application. The memory 102 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), programmable read-only memory (Programmable Read-Only Memory, PROM), read-only memory (Read-Only Memory, ROM), magnetic memory, flash memory, magnetic disk or optical disk. In one example, the memory is used to store a computer program; the processor is electrically connected to the memory and is used to execute the computer program to implement the detection reference area determination method.
[0051] The multimedia component 103 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone, which is used to receive external audio signals. The received audio signal may be further stored in the memory 102 or sent through the communication component 105. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 104 provides an interface between the processor 101 and other interface modules, and the above-mentioned other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 105 is used to detect wired or wireless communication between the device 100 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G or 4G, or a combination of one or more of them, so the corresponding communication component 105 may include: Wi-Fi component, Bluetooth component, NFC component.
[0052] The detection device 100 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the detection reference area determination method proposed in this application.
[0053] In a specific embodiment, the detection device may include a photographing device and a fixture, the fixture is used to clamp the target object, and the target object may be a workpiece, a part in the workpiece, or a region in the workpiece. The photographing device is electrically connected to the memory and the processor in the detection device. When the target object is detected for the first time, the photographing device is used to take a picture of the target object on the fixture to form a target image so as to process and form a detection reference area, so as to facilitate the subsequent pre-processing, detection, tracking or identification of the target object based on the detection reference area during mass production of the photographing device, so as to obtain an image of the target object. For example: category detection and target tracking of the target object in the detection reference area, etc.
[0054] Please refer to Figure 2 and Figure 3 , Figure 2A flowchart of a method for determining a detection reference area provided in an embodiment of the present application. The method for determining a detection reference area is applied to the above-mentioned detection device, and the method includes:
[0055] S201, obtaining a plurality of target vector points based on a target image input, wherein the plurality of target vector points are input one by one in sequence.
[0056] In this embodiment, the target image can be a blank image, or it can be formed by photographing a target object on a fixture (such as a workpiece, a part or an area in the workpiece) by a photographing device. The target image can contain any two or more of the workpiece, the fixture, a part in the workpiece, a region in the workpiece, etc. A plurality of target vector points are sequentially input by a user, and these target vector points can be coordinate points generated when the user selects the contour of the target object on the target image. A plurality of original points in the target image are sequentially input by the user, and then the detection device performs a deduplication operation on these original points, and the obtained non-repeated points are the plurality of target vector points. Therefore, in one embodiment, obtaining a plurality of target vector points input based on the target image includes: obtaining a plurality of original points input one by one by the user based on the target image; forming a plurality of initial vector points based on the plurality of original points and the order in which the original points are input one by one; performing a deduplication operation on the plurality of initial vector points to obtain a plurality of target vector points. Among them, performing a deduplication operation on the plurality of initial vector points includes: retaining one original point with the same coordinates.
[0057] For details, please see Figure 3 After the detection device obtains the target image and displays it on the screen, the user inputs 8 points of the polygon on the target image based on the screen: {(x1,y1),(x2,y5),(x3,y6),(x5,y6),(x7,y6),(x8,y3),(x6,y4),(x4,y2)}, and the detection device stores the points in the order of the user input points.
[0058] S202: Connecting adjacent target vector points based on the input sequence of the plurality of target vector points to form a plurality of vector edges.
[0059] like Figure 3 As shown, multiple target vector points are Figure 3Points 1 to 8 in the figure, each point has its own horizontal and vertical coordinates. By connecting points 1 to 8 in sequence, 8 vector edges can be obtained. Since the vector edge formed by connecting point 1 and point 2 and the vector edge formed by connecting point 2 and point 3 are on the same straight line, that is, the slopes of the two vector edges formed by connecting the two points are equal, so the common point 2 is deleted, and they can be merged into one; similarly, the vector edge formed by connecting point 3 and point 4 and the vector edge formed by connecting point 4 and point 5 are on the same straight line, and point 4 is deleted, and they can also be merged into one; after the merger is completed, 6 points of the new vector polygon are obtained, as well as vector edges a to vector edges f. It can be seen that this embodiment connects adjacent points in the order of points, and then merges the edges with equal slopes obtained by the connection, so as to obtain multiple vector edges.
[0060] More specifically, the process of forming multiple vector edges includes: the user inputs multiple vector points on the target image in sequence on the screen, then stores these vector points according to the order of the user input points, deletes duplicate points, and then deletes common vertices of adjacent edges that are colinear; then two adjacent points are constructed into a vector edge; wherein, the starting point and the end point of all edges are defined according to the order of input of adjacent points to determine the direction information of the edges.
[0061] S203, scanning each vector edge using a horizontal scan line to determine an array of intersection points of the scan line on each vector edge.
[0062] like Figure 4 As shown in the figure, in the process of scanning each vector edge with a fixed step length using a horizontal scan line, the intersection point of each horizontal scan line and the current vector edge is recorded, and all the intersection points corresponding to the vector edge can form an intersection point array of the horizontal scan line on the vector edge. In other words: the intersection point array on a vector edge records the coordinates of all the intersection points obtained by scanning. Figure 4 As shown, the intersection array Pa on the vector edge a records the following coordinate points: (x1, y1), (u1, y1+1), (u2, y1+2)...(x3, y6), Figure 4 The fixed scan step size of the example is 1; the intersection point arrays Pb~Pf on the vector edge b~vector edge f are deduced in the same way. For details, see Figure 4 .
[0063] In one example, each vector edge is scanned using a horizontal scan line to determine an array of intersection points of the scan line on each vector edge, including: allowing the horizontal scan line to scan multiple vector edges with a fixed step length to determine the intersection point of the horizontal scan line with each vector edge; and determining the array of intersection points on each vector edge based on the intersection point of the horizontal scan line with each vector edge. It should be noted that before scanning each vector edge using a horizontal scan line, the method also includes: determining the slope of the vector edge based on the target vector point, and merging two adjacent vector edges with equal slopes.
[0064] More specifically, for each vector edge, a scan line is used to scan from the starting point to the end point of the edge, and the intersection of the edge and the scan line is calculated each time, so that an array of intersections of the scan line on each vector edge can be obtained. Among them, when the direction information of the edge is not horizontal, the scan line calculates the intersection from top to bottom along the current edge. Each time the scan is performed, the X-axis coordinate calculation formula is: x=(x1-x2)[(i-y2) / (y1-y2)]+x2; i is the row where the scan line is located, (x1,y1) and (x2,y2) are the endpoints of the edge.
[0065] S204: Determine redundant intersection points between two adjacent vector edges based on the directions of the two adjacent vector edges.
[0066] In order to remove redundant intersections, this embodiment performs correlation detection based on the directions of two adjacent vector edges; the directions of the vector edges are as follows: Figure 3 Specifically, the starting and ending points of all edges are defined in the order of storage of adjacent points. The direction information of the vector edge is divided into upward, downward and horizontal, and is defined according to the row coordinates of the starting and ending points of the edge. If the row coordinates of the starting point are greater than the row coordinates of the ending point, it is marked as downward, and if the row coordinates of the starting point are less than the row coordinates of the ending point, it is marked as upward. Similarly, if they are equal, it is marked as horizontal. Figure 3 , the direction information of the complex vector polygon edge is {downward, horizontal, upward, downward, upward, upward}.
[0067] In one embodiment, redundant intersections in two adjacent vector edges are determined based on the directions of the two adjacent vector edges, including: if the extension direction of the two adjacent vector edges is: the previous vector edge extends upward and the latter vector edge extends downward, then it is determined that there are no redundant intersections in the intersection array on the latter vector edge; otherwise, it is determined that there are redundant intersections in the intersection array on the latter vector edge, and optionally, the first position intersection in the intersection array on the latter vector edge is determined as a redundant intersection.
[0068] like Figure 3 As shown, vector edge a and vector edge b are two adjacent vector edges, and the first vector edge a is downward, and the second vector edge is horizontal, which does not meet the rule of "the first vector edge extends upward, and the second vector edge extends downward". Therefore, it is determined that there are redundant intersections in the intersection array on the second vector edge b. Specifically, the first position intersection (i.e., point 2) in the intersection array on the second vector edge b is determined as a redundant intersection. It can be seen that the intersection array on each vector edge records each intersection in the aforementioned scanning order, including: a first position intersection, at least one or zero intermediate intersections, and a final position intersection. In particular, the intersection array on the horizontal vector edge includes: a first position intersection and a final position intersection, and no intermediate intersections.
[0069] S205 , delete redundant intersection points to update the intersection point array on the corresponding vector edge.
[0070] Step S205 deletes redundant intersection points, which can reduce the number of points in the intersection point array on the corresponding vector edge, thereby facilitating subsequent run-length encoding conversion.
[0071] In one example, since the vector edges of adjacent sides have common vertices, the corresponding intersection points exist in the intersection point array. When the extension direction information of the adjacent vector edges is one upward and the other downward, it is confirmed that there are no redundant intersection points in the two adjacent sides and no processing is performed; otherwise, the first intersection point in the intersection point array of the latter side is deleted, thereby completing the deletion of redundant intersection points. For details, refer to Figure 3 For example, side a is facing downward and side b is horizontal, so delete the first intersection point (x3, y6) in the Pb intersection array; side b is horizontal and side c is facing upward, so delete the first intersection point (x7, y6) in the Pc intersection array; side c is facing upward and side d is facing downward, so no processing is done; side d is facing downward and side e is facing upward, so no processing is done; side e is facing upward and side f is facing upward, so delete the first intersection point (x4, y2) in the Pf intersection array; side f is facing upward and side a is facing downward, so no processing is done.
[0072] S206 , converting the updated intersection array on each vector edge into run-length encoding to generate a detection reference area in the target image.
[0073] It should be noted that the run-length encoding consists of a row array, a start column array and an end column array, which is used to represent a two-dimensional area. Using run-length encoding to represent a two-dimensional area can optimize the extraction operation of the area of interest in tasks such as preprocessing, target detection, tracking and recognition.
[0074] In one embodiment, the updated intersection array on each vector edge is converted into run-length coding to generate a detection reference area in the target image, including: traversing the intersection array on each vector edge to extract a row array, a starting column array and an ending column array for representing the run-length coding; wherein the row array records the starting row coordinates and the ending row coordinates of each intersection in each intersection array; the starting column array records the starting column coordinates of each intersection in each intersection array; the ending column array records the ending column coordinates of each intersection in each intersection array; and the detection reference area enclosed by multiple target vector points in the target image is determined according to the row array, the starting column array and the ending column array.
[0075] In one example, the updated intersection array of each vector edge is converted into run-length coding, including: extracting the column coordinates of the intersection points of a row; converting the column coordinates to obtain a row coordinate array, a start column coordinate array, and an end column coordinate array to implement run-length coding. Figure 5As shown, extracting the column coordinates of the intersection points of the same row can obtain many arrays:
[0076] {{x1,x1},…,{q1,x4},…,{q2,q3,x8,x8},…,{q4,x6,x6,q5},…,{x3,x7}}. Among them, traverse the intersection array, and the intersection row coordinate minus the scan line start row coordinate is the array position of the column coordinate (indicating the order of a column coordinate in the corresponding array). The calculation formula is: array position = intersection row coordinate – y1. Correspondingly, the run-length encoding data structure obtained by column coordinate conversion includes: the row coordinate array (i.e., row array) is {y1,…,y2,…,y3,y3,…,y4,y4,…,y5}; the starting column coordinate array (starting column array) is {x1,…,q1,…,q2,x8,…,q4,x6,…,x3}; and the ending column coordinate array (i.e., ending column array) is {x1,…,x4,…,q3,x8,…,x6,q5,…,x7}. It can be seen that this embodiment is based on multiple target vector points input one by one in sequence. First, target vector points with adjacent positions are connected based on the input order of multiple target vector points to form multiple vector edges, and then each vector edge is scanned using a horizontal scan line to determine the intersection array of the scan line on each vector edge. Then, the redundant intersections in the two adjacent vector edges are determined based on the directions of the two adjacent vector edges, and the redundant intersections are deleted to update and reduce the number of points in the intersection array on the corresponding vector edge; finally, the updated intersection array on each vector edge is converted into run-length coding to generate a detection reference area in the target image. This method can use the direction information of the adjacent vector edges to determine the redundant intersections in the two adjacent vector edges, and remove the redundant intersections, thereby reducing the number of points in the intersection array on each vector edge. The efficiency of run-length coding conversion and the generation efficiency of the detection reference area can be improved, and the target detection and tracking process of the image can also be accelerated.
[0077] The detection reference area determination method provided by the present application can reduce the amount of calculation by finding the intersection point between the scan line and the effective vector edge, and solve the problem of low conversion efficiency of run-length coding; by integrating the column coordinates, the intersection column coordinates can be converted into run-length coding, and the problem of the area being represented by run-length coding can be solved; by the direction information of the adjacent vector edges, the representation of redundant runs can be avoided, and the problem of poor conversion run-length accuracy can be solved. The method optimizes the conversion steps of run-length coding and significantly improves the data conversion efficiency.
[0078] The following is an introduction to a detection reference area determination device provided in an embodiment of the present application. The detection reference area determination device described below and the detection reference area determination method described above can be referenced to each other.
[0079] Please refer to Figure 6 , Figure 6A schematic diagram of a detection reference area determination device provided in an embodiment of the present application includes:
[0080] An acquisition module 601 is used to acquire a plurality of target vector points based on a target image input, wherein the input order of the plurality of target vector points is to input them one by one in sequence;
[0081] An edge processing module 602, configured to connect adjacent target vector points based on an input sequence of a plurality of target vector points to form a plurality of vector edges;
[0082] A scanning module 603, configured to scan each vector edge using a horizontal scanning line to determine an array of intersection points of the scanning line on each vector edge;
[0083] A point processing module 604, configured to determine redundant intersection points between two adjacent vector edges based on the directions of the two adjacent vector edges;
[0084] A deletion module 605 is used to delete redundant intersection points to update the intersection point array on the corresponding vector edge;
[0085] The generating module 606 is used to convert the updated intersection array on each vector edge into run-length encoding to generate a detection reference area in the target image.
[0086] In one implementation, the acquisition module is specifically used to:
[0087] Acquire multiple original points input one by one by the user based on the target image;
[0088] Based on the multiple original points and the order in which the original points are input one by one, multiple initial vector points are formed;
[0089] A deduplication operation is performed on multiple initial vector points to obtain multiple target vector points.
[0090] In one implementation, the acquisition module is specifically used to:
[0091] Keep one original point with the same coordinates.
[0092] In one embodiment, the scanning module is specifically used for:
[0093] Allowing a horizontal scan line to scan a plurality of vector edges with a fixed step length to determine an intersection point between the horizontal scan line and each vector edge;
[0094] Based on the intersection points of the horizontal scan line and each vector edge, an array of intersection points on each vector edge is determined.
[0095] In one embodiment, the point processing module is specifically used to:
[0096] If the directions of two adjacent vector edges are: the first vector edge is upward and the second vector edge is downward, it is determined that there are no redundant intersection points in the intersection point array on the second vector edge; otherwise, the first intersection point in the intersection point array on the second vector edge is determined as a redundant intersection point.
[0097] In one embodiment, the generation module is specifically used to:
[0098] Traverse the intersection array on each vector edge to extract the row array, the starting column array and the ending column array for representing the run-length coding; wherein the row array records the starting row coordinates and the ending row coordinates of each intersection in each intersection array; the starting column array records the starting column coordinates of each intersection in each intersection array; and the ending column array records the ending column coordinates of each intersection in each intersection array;
[0099] According to the row array, the start column array and the end column array, a detection reference area enclosed by a plurality of target vector points in the target image is determined.
[0100] In one embodiment, the edge processing module is further configured to:
[0101] The slope of the vector edge is determined based on the target vector point, and two adjacent vector edges with equal slopes are merged.
[0102] It can be seen that this embodiment can use multiple target vector points input by the user as the basis for processing the detection reference area of the workpiece, thereby improving the accuracy of the detection reference area, and determining the redundant intersections in two adjacent vector edges through the direction information of the adjacent vector edges, and removing the redundant intersections, thereby achieving the reduction of the number of points in the intersection array on each vector edge, thereby improving the run-length encoding conversion efficiency and the generation efficiency of the detection reference area, and can also accelerate the target detection and tracking process of the image.
[0103] The computer-readable storage medium provided in the embodiments of the present application is introduced below. The computer-readable storage medium described below and the detection reference area determination method described above can be referenced to each other.
[0104] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method for determining a detection reference area are implemented.
[0105] The computer-readable storage medium may include: a USB flash drive, a scanning hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0106] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0107] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0108] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a scannable disk, a CD-ROM, or any other form of storage medium known in the art.
[0109] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms include, include or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0110] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for determining a detection reference area, characterized in that: include: Acquire a plurality of target vector points based on the target image input, wherein the plurality of target vector points are input one by one in sequence; Connecting the target vector points adjacent to each other based on the input sequence of the plurality of target vector points to form a plurality of vector edges; Scan each of the vector edges using a horizontal scan line to determine an array of intersection points of the scan line on each of the vector edges; Determining redundant intersection points between two adjacent vector edges based on directions of the two adjacent vector edges; Deleting the redundant intersection points to update the intersection point array corresponding to the vector edge; The updated intersection array on each of the vector edges is converted into run-length encoding to generate a detection reference area in the target image.
2. The method according to claim 1, characterized in that: The step of obtaining a plurality of target vector points based on a target image input includes: Acquire multiple original points input one by one by the user based on the target image; Forming a plurality of initial vector points based on the plurality of original points and the order in which the original points are input one by one in sequence; A deduplication operation is performed on the multiple initial vector points to obtain the multiple target vector points.
3. The method according to claim 1, characterized in that The performing a deduplication operation on the plurality of initial vector points comprises: The original point having the same coordinates is retained.
4. The method according to claim 1, characterized in that: The step of scanning each of the vector edges using a horizontal scan line to determine an array of intersection points of the scan line on each of the vector edges comprises: Allowing the horizontal scan line to scan the plurality of vector edges with a fixed step length to determine an intersection point between the horizontal scan line and each of the vector edges; Based on the intersection points of the horizontal scan line and each of the vector edges, the intersection point array on each of the vector edges is determined.
5. The method according to claim 1, characterized in that The determining of redundant intersection points between two adjacent vector edges based on directions of the two adjacent vector edges comprises: If the directions of the two adjacent vector edges are: the first vector edge is upward and the second vector edge is downward, it is determined that the redundant intersection does not exist in the intersection array on the second vector edge; otherwise, the first intersection in the intersection array on the second vector edge is determined as the redundant intersection.
6. The method according to claim 1, characterized in that The step of converting the updated intersection array on each of the vector edges into run-length encoding to generate a detection reference area in the target image includes: Traversing the intersection array on each of the vector edges to extract a row array, a start column array and an end column array for representing the run-length coding; wherein the row array records the start row coordinates and the end row coordinates of each intersection in each intersection array; the start column array records the start column coordinates of each intersection in each intersection array; and the end column array records the end column coordinates of each intersection in each intersection array; The detection reference area enclosed by a plurality of the target vector points in the target image is determined according to the row array, the start column array and the end column array.
7. The method according to claim 1, characterized in that Before scanning each of the vector edges using a horizontal scanning line, the method further includes: The slope of the vector edge is determined based on the target vector point, and two adjacent vector edges with equal slopes are merged.
8. A detection reference area determination device, characterized in that: include: An acquisition module, used for acquiring a plurality of target vector points based on a target image input, wherein the plurality of target vector points are input one by one in sequence; An edge processing module, configured to connect the target vector points adjacent to each other based on the input sequence of the plurality of target vector points to form a plurality of vector edges; A scanning module, used for scanning each of the vector edges using a horizontal scanning line to determine an array of intersection points of the scanning line on each of the vector edges; A point processing module, used for determining redundant intersection points between two adjacent vector edges based on the directions of the two adjacent vector edges; A deletion module, used for deleting the redundant intersection points to update the intersection point array on the corresponding vector edge; A generating module is used to convert the updated intersection array on each of the vector edges into run-length encoding to generate a detection reference area in the target image.
9. A detection device, characterized in that: include: Memory, used to store computer programs; A processor, electrically connected to the memory, and configured to execute the computer program to implement the method according to any one of claims 1 to 7; The photographing device is electrically connected to the memory and the processor, and is used to pre-process, detect, track or identify the target object based on the detection reference area, so as to obtain an image of the target object.
10. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.